1
0
mirror of https://github.com/esp8266/Arduino.git synced 2025-04-19 23:22:16 +03:00

Add creation timestamp to LittleFS directories (#9127)

* Add creation timestamp to LittleFS directories

Partial fix #9120.  This is simple enough to include and does not increase
the amount of flash writes on file updates significantly (which a
modified-time 't' attribute would).

* Fix typo in debug message on error
This commit is contained in:
Earle F. Philhower, III 2024-06-15 12:31:24 -07:00 committed by GitHub
parent f741521abc
commit 96ee7dfb8e
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -167,6 +167,14 @@ public:
return false; return false;
} }
int rc = lfs_mkdir(&_lfs, path); int rc = lfs_mkdir(&_lfs, path);
if ((rc == 0) && _timeCallback) {
time_t now = _timeCallback();
// Add metadata with creation time to the directory marker
int rc = lfs_setattr(&_lfs, path, 'c', (const void *)&now, sizeof(now));
if (rc < 0) {
DEBUGV("Unable to set creation time on '%s' to %ld\n", path, (long)now);
}
}
return (rc==0); return (rc==0);
} }