feat: add tier-1 platform support for change_time by juliusl · Pull Request #128256 · rust-lang/rust (original) (raw)
Okay wow this was a trip to research. So apparently cpython ran into a similar issue which eventually led windows to add this api:
https://learn.microsoft.com/windows/win32/api/winbase/nf-winbase-getfileinformationbyname
This API can return an information class type that returns a struct called FILE_STAT_BASIC_INFORMATION. This struct has all of the previous information, plus the ChangeTime
I'm trying to get to.
Here's the real cool part. According to documentation, this api doesn't open the file in order to return metadata, which means that it should actually improve performance along this code path since GetFileInformationByHandle
/GetFileInformationByHandleEx
actually need to open/close a file handle.
This routine returns the requested information about the file specified by FileName. It does so without opening and returning a handle to the file.
Also, the struct includes the reparse tag if set, meaning the current additional syscall can be avoided when the reparse attribute is set.
For now, I'll try it out and see if I can get it working and I'll update the PR accordingly.