8000 Add fileCreation/getCreation create-time accessors by earlephilhower · Pull Request #7000 · esp8266/Arduino · GitHub
[go: up one dir, main page]

Skip to content

Add fileCreation/getCreation create-time accessors #7000

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 12 commits into from
Feb 22, 2020
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Replace "Creation" w/"CreationTime" in FS accessor
Per review, `getCreation` -> `getCreationTime`, `fileCreation` ->
`fileCreationTime`.

The names `fileTime()` and `getLastWrite()` are inherited from ESP32
implementation and unchanged.
  • Loading branch information
earlephilhower committed Jan 11, 2020
commit b06959f7f05c3557daced277b5b0dcaed2d59ff0
8 changes: 4 additions & 4 deletions cores/esp8266/FS.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -187,11 +187,11 @@ time_t File::getLastWrite() {
return _p->getLastWrite();
}

time_t File::getCreation() {
time_t File::getCreationTime() {
if (!_p)
return 0;

return _p->getCreation();
return _p->getCreationTime();
}

void File::setTimeCallback(time_t (*cb)(void)) {
Expand Down Expand Up @@ -231,10 +231,10 @@ time_t Dir::fileTime() {
return _impl->fileTime();
}

time_t Dir::fileCreation() {
time_t Dir::fileCreationTime() {
if (!_impl)
return 0;
return _impl->fileCreation();
return _impl->fileCreationTime();
}

size_t Dir::fileSize() {
Expand Down
4 changes: 2 additions & 2 deletions cores/esp8266/FS.h
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ class File : public Stream
String readString() override;

time_t getLastWrite();
time_t getCreation();
time_t getCreationTime();
void setTimeCallback(time_t (*cb)(void));

protected:
Expand All @@ -132,7 +132,7 @@ class Dir {
String fileName();
size_t fileSize();
time_t fileTime();
time_t fileCreation();
time_t fileCreationTime();
bool isFile() const;
bool isDirectory() const;

Expand Down
4 changes: 2 additions & 2 deletions cores/esp8266/FSImpl.h
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ class FileImpl {
// time present in the filesystem metadata (often the last time the file was closed)
virtual time_t getLastWrite() { return 0; } // Default is to not support timestamps
// Same for creation time.
virtual time_t getCreation() { return 0; } // Default is to not support timestamps
virtual time_t getCreationTime() { return 0; } // Default is to not support timestamps

protected:
time_t (*timeCallback)(void) = nullptr;
Expand Down Expand Up @@ -81,7 +81,7 @@ class DirImpl {
// as the FS is allowed to return either the time of the last write() operation or the
// time present in the filesystem metadata (often the last time the file was closed)
virtual time_t fileTime() { return 0; } // By default, FS doesn't report file times
virtual time_t fileCreation() { return 0; } // By default, FS doesn't report file times
virtual time_t fileCreationTime() { return 0; } // By default, FS doesn't report file times
virtual bool isFile() const = 0;
virtual bool isDirectory() const = 0;
virtual bool next() = 0;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ void listDir(const char * dirname) {
Serial.print(root.fileName());
Serial.print(" SIZE: ");
Serial.print(file.size());
time_t cr = file.getCreation();
time_t cr = file.getCreationTime();
time_t lw = file.getLastWrite();
file.close();
struct tm * tmstruct = localtime(&cr);
Expand Down
4 changes: 2 additions & 2 deletions libraries/LittleFS/src/LittleFS.h
Original file line number Diff line number Diff line change
Expand Up @@ -447,7 +447,7 @@ class LittleFSFileImpl : public FileImpl
return ftime;
}

time_t getCreation() override {
time_t getCreationTime() override {
time_t ftime = 0;
if (_opened && _fd) {
int rc = lfs_getattr(_fs->getFS(), _name.get(), 'c', (void *)&ftime, sizeof(ftime));
Expand Down Expand Up @@ -554,7 +554,7 @@ class LittleFSDirImpl : public DirImpl
return (time_t)_getAttr4('t');
}

time_t fileCreation() override {
time_t fileCreationTime() override {
return (time_t)_getAttr4('c');
}

Expand Down
4 changes: 2 additions & 2 deletions libraries/SDFS/src/SDFS.h
Original file line number Diff line number Diff line change
Expand Up @@ -363,7 +363,7 @@ class SDFSFileImpl : public FileImpl
return ftime;
}

time_t getCreation() override {
time_t getCreationTime() override {
time_t ftime = 0;
if (_opened && _fd) {
sdfat::dir_t tmp;
Expand Down Expand Up @@ -438,7 +438,7 @@ class SDFSDirImpl : public DirImpl
return _time;
}

time_t fileCreation() override
time_t fileCreationTime() override
{
if (!_valid) {
return 0;
Expand Down
0