Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use ChangeTime instead of CreationTime in mingw_stat() and fscache_stat() #3707

Open
dscho opened this issue Feb 20, 2022 · 0 comments
Open
Labels
Help Wanted help is requested from collaborators, please!

Comments

@dscho
Copy link
Member

dscho commented Feb 20, 2022

As pointed out in this StackOverflow post, Windows' CreationTime is less similar to Unix' ctime concept than we previously assumed: on Windows, it does not necessarily change when a file is deleted and recreated again. Indeed, even when renaming a file and then renaming another file to the former's former name, the CreationTime won't change.

Instead, ChangeTime is what we're after. It changes when the file's metadata changes, such as its file name or its location.

This should also help the funny issue where editing a file using Excel might not change the LastWriteTime, and neither the CreationTime, but the ChangeTime.

Originally, we used CreationTime because ctime was interpreted to mean "create time".

Then, we could not change it because we used the FindFirstFile()/FindNextFile() functions in the FSCache, which have access to CreationTime but not to ChangeTime.

In the meantime, however, we use NtQueryDirectoryFile() instead (because it is actually faster), which does have access to ChangeTime.

The regular non-FSCache mingw_stat() uses GetFileInformationByHandle(), which does not have access to the ChangeTime. We might be able to remedy that by switching to GetFileAttributesExW(), GetFileInformationByHandleEx() or some other API function that does have access.

Note: we might want to use this opportunity to switch to using FILE_ID_FULL_DIR_INFORMATION in fscache_stat() to get the equivalent of inodes, and the equivalent nFileIndexHigh/nFileIndexLow in mingw_stat().

@dscho dscho added the Help Wanted help is requested from collaborators, please! label Feb 20, 2022
@dscho dscho changed the title Use ChangeTime instead of CreationTime" in mingw_stat() and fcache_stat()` Use ChangeTime instead of CreationTime in mingw_stat() and fcache_stat() Feb 20, 2022
@dscho dscho changed the title Use ChangeTime instead of CreationTime in mingw_stat() and fcache_stat() Use ChangeTime instead of CreationTime in mingw_stat() and fscache_stat() Sep 10, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Help Wanted help is requested from collaborators, please!
Projects
None yet
Development

No branches or pull requests

1 participant