mirror of
https://github.com/esp8266/Arduino.git
synced 2025-07-27 18:02:17 +03:00
Track creation time of LittleFS FS (#7873)
This commit is contained in:
@ -221,6 +221,26 @@ public:
|
||||
return false;
|
||||
}
|
||||
|
||||
if(_timeCallback && _tryMount()) {
|
||||
// Mounting is required to set attributes
|
||||
|
||||
time_t t = _timeCallback();
|
||||
rc = lfs_setattr(&_lfs, "/", 'c', &t, 8);
|
||||
if (rc != 0) {
|
||||
DEBUGV("lfs_format, lfs_setattr 'c': rc=%d\n", rc);
|
||||
return false;
|
||||
}
|
||||
|
||||
rc = lfs_setattr(&_lfs, "/", 't', &t, 8);
|
||||
if (rc != 0) {
|
||||
DEBUGV("lfs_format, lfs_setattr 't': rc=%d\n", rc);
|
||||
return false;
|
||||
}
|
||||
|
||||
lfs_unmount(&_lfs);
|
||||
_mounted = false;
|
||||
}
|
||||
|
||||
if (wasMounted) {
|
||||
return _tryMount();
|
||||
}
|
||||
@ -228,6 +248,19 @@ public:
|
||||
return true;
|
||||
}
|
||||
|
||||
time_t getCreationTime() override {
|
||||
time_t t;
|
||||
uint32_t t32b;
|
||||
|
||||
if (lfs_getattr(&_lfs, "/", 'c', &t, 8) == 8) {
|
||||
return t;
|
||||
} else if (lfs_getattr(&_lfs, "/", 'c', &t32b, 4) == 4) {
|
||||
return (time_t)t32b;
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
protected:
|
||||
friend class LittleFSFileImpl;
|
||||
|
Reference in New Issue
Block a user