Skip to content

Commit 96ee7df

Browse files
Add creation timestamp to LittleFS directories (esp8266#9127)
* Add creation timestamp to LittleFS directories Partial fix esp8266#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
1 parent f741521 commit 96ee7df

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

libraries/LittleFS/src/LittleFS.h

+8
Original file line numberDiff line numberDiff line change
@@ -167,6 +167,14 @@ class LittleFSImpl : public FSImpl
167167
return false;
168168
}
169169
int rc = lfs_mkdir(&_lfs, path);
170+
if ((rc == 0) && _timeCallback) {
171+
time_t now = _timeCallback();
172+
// Add metadata with creation time to the directory marker
173+
int rc = lfs_setattr(&_lfs, path, 'c', (const void *)&now, sizeof(now));
174+
if (rc < 0) {
175+
DEBUGV("Unable to set creation time on '%s' to %ld\n", path, (long)now);
176+
}
177+
}
170178
return (rc==0);
171179
}
172180

0 commit comments

Comments
 (0)