Skip to content

Commit 6c22ea3

Browse files
Set creation time on LittleFS directory creation (#2108)
1 parent 1be28b5 commit 6c22ea3

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

libraries/LittleFS/src/LittleFS.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,14 @@ class LittleFSImpl : public FSImpl {
157157
return false;
158158
}
159159
int rc = lfs_mkdir(&_lfs, path);
160+
if ((rc == 0) && _timeCallback) {
161+
time_t now = _timeCallback();
162+
// Add metadata with creation time to the directory marker
163+
int rc = lfs_setattr(&_lfs, path, 'c', (const void *)&now, sizeof(now));
164+
if (rc < 0) {
165+
DEBUGV("Unable to set creation time on '%s' to %ld\n", path, (long)now);
166+
}
167+
}
160168
return (rc == 0);
161169
}
162170

0 commit comments

Comments
 (0)