mirror of
https://github.com/esp8266/Arduino.git
synced 2025-07-24 19:42:27 +03:00
Rationalize File timestamp callback (#7785)
Fixes #7775 Clean up the passing/setting of custom File time callbacks and add a host test verifying they work. Existing core was not passing custom timeCallbacks set at the FS level down to open()ed files, resulting in them calling the default time(nullptr) and reporting wrong file modify times.
This commit is contained in:
committed by
GitHub
parent
f1dc6e90ee
commit
35d22edeec
@ -70,14 +70,14 @@ FileImplPtr LittleFSImpl::open(const char* path, OpenMode openMode, AccessMode a
|
||||
}
|
||||
|
||||
time_t creation = 0;
|
||||
if (timeCallback && (openMode & OM_CREATE)) {
|
||||
if (_timeCallback && (openMode & OM_CREATE)) {
|
||||
// O_CREATE means we *may* make the file, but not if it already exists.
|
||||
// See if it exists, and only if not update the creation time
|
||||
int rc = lfs_file_open(&_lfs, fd.get(), path, LFS_O_RDONLY);
|
||||
if (rc == 0) {
|
||||
lfs_file_close(&_lfs, fd.get()); // It exists, don't update create time
|
||||
} else {
|
||||
creation = timeCallback(); // File didn't exist or otherwise, so we're going to create this time
|
||||
creation = _timeCallback(); // File didn't exist or otherwise, so we're going to create this time
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user