-
Notifications
You must be signed in to change notification settings - Fork 360
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
Support getting file metadata on Windows #4067
base: master
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you also add a test that directly calls the relevant Windows API functions? std sometimes changes what it uses and then we lose test coverge, which is not great.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added a windows-fs test for the shims directly
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks! Here are some comments for the first and last commit, I skipped the second one for now.
Before we get too much further on this PR, I'd like to point out 296d806 (which I just pushed) on the big PR. It's the changes needed to FileDescription methods to make them platform-agnostic enough for Windows use-cases. If they look fine, we can continue, but if you think it's a bad design then the FileDescription trait will need entirely split in two, which will change code even in this PR. |
Reducing the places where we have to use global state like errno seems like an improvement. But please use |
@rustbot ready |
src/shims/windows/fs.rs
Outdated
const TIME_TO_EPOCH: u64 = 31_556_926 * 369 * 10_000_000; | ||
match time.ok() { | ||
Some(time) => { | ||
let duration = system_time_to_duration(&time)?; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should probably rename this to system_time_since_unix_epoch
. (Can be a future PR though.)
Okay I finally had a look at the core new file in this PR. :) |
@rustbot ready |
☔ The latest upstream changes (presumably #4068) made this pull request unmergeable. Please resolve the merge conflicts. |
src/shims/windows/fs.rs
Outdated
if !(file_attribute_normal | file_flag_backup_semantics | file_flag_open_reparse_point) | ||
& flags_and_attributes | ||
!= 0 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is another one of these bitmasks where validation is separate from interpretation. I don't understand all these flags so I am not sure, can this be done in a better way? There should be one if
for each of these 3 cases, performing whatever action the respective flag should perform.
Maybe Windows file flag parsing is so complicated that we should have a separate function that takes in the raw flaws as u32
s and returns some nice typed representation?
file_flag_backup_semantics
is sus because it is considered supported here but entirely ignored later.
@rustbot author |
… enough to get file metadata.
…test for this case.
…nts to code about various quirks
2e11722
to
75e8284
Compare
@rustbot review |
Main changes are the first two commits - one refactors handles a bit to make their usage more consistent and adds the file variant, the other actually adds the metadata shims.
This also changes miri to never return invalid handle errors, instead always treating them as an error. This behavior matches that of code running under the MSVC debugger - invalid handles are treated as exceptions in debug contexts.
Split off #4043