-
-
Notifications
You must be signed in to change notification settings - Fork 14.2k
fix: std::sys::fs use_with_native_path for read_dir for windows #148045
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
base: main
Are you sure you want to change the base?
Conversation
|
rustbot has assigned @Mark-Simulacrum. Use |
This comment was marked as outdated.
This comment was marked as outdated.
85f3ca8 to
0527ec1
Compare
|
@rustbot label +O-windows |
|
cc @ChrisDenton |
|
|
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 does not seem to fix the issue. It just converts the path to wide and then back again, which is a quite expensive no-op.
But it is beginning of fixing the purpose using this function on all platforms. I covered it on windows, expensive no-op it is the function 'use_with_native_path' at all |
|
The purpose of the fixme is to clearly show that there's an issue to be fixed. This PR doesn't fix the issue, it merely hides the issue one level deeper and removes the fixme note. The performance impact of this is why it's a fixme instead of being implemented that way to start with. |
I didnt remove fixme comment Also i see some moments like: pub fn copy(from: &Path, to: &Path) -> io::Result<u64> {
// FIXME: use with_native_path on all platforms
#[cfg(not(windows))]
return imp::copy(from, to);
#[cfg(windows)]
with_native_path(from, &|from| with_native_path(to, &|to| imp::copy(from, to)))
}is it also expensive no-op? |
|
Yes, if |
|
r? @ChrisDenton |
|
Requested reviewer is already assigned to this pull request. Please choose another assignee. |
| // We push a `*` to the end of the path which cause the empty path to be | ||
| // treated as the current directory. So, for consistency with other platforms, | ||
| // we explicitly error on the empty path. | ||
| if p.as_os_str().is_empty() { | ||
| if p.is_empty() { | ||
| // Return an error code consistent with other ways of opening files. | ||
| // E.g. fs::metadata or File::open. | ||
| return Err(io::Error::from_raw_os_error(c::ERROR_PATH_NOT_FOUND as i32)); | ||
| } |
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 comment and check should stay the first thing this function does; there is no sense in creating an empty Vec, but then fail here...
| pub const fn to_wchars_with_null_unchecked(&self) -> &[u16] { | ||
| &self.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.
I'd probably just inline this.
Fix the read_dir function in windows for using with native_path
r? @ChrisDenton