uucore(windows): rewrite fsext with safe Win32 wrappers, real free space and mount paths; df(windows): resolve paths by mount prefix - #14455
Conversation
|
@lhecker if you have an opinion :) |
…ace and mount paths; df(windows): resolve paths by mount prefix
aac8d79 to
c12fd33
Compare
|
much easier to review ! |
|
I still have no idea how to use stacks though, lol it's just two separate PRs now, I don't know how to combine them so they're visible here in the UI as a stack
that it is, agreed |
|
GNU testsuite comparison: |
| let path = path.as_ref(); | ||
| let file = path.as_os_str().to_owned(); | ||
| // Not `canonicalize`: it resolves SUBST drives and junctions away and | ||
| // yields `\\?\` prefixes that never match a mount directory. | ||
| let absolute = std::path::absolute(path).map_err(|_| FsError::InvalidPath)?; | ||
| absolute.metadata().map_err(|_| FsError::InvalidPath)?; | ||
| let longest = mounts | ||
| .iter() | ||
| .filter(|m| absolute.starts_with(&m.mount_dir)) | ||
| .max_by_key(|m| m.mount_dir.len()); | ||
| let mount_info = if let Some(mount_info) = longest { | ||
| mount_info.clone() | ||
| } else { | ||
| let root = uucore::fs::volume_path_name(&absolute).map_err(|_| FsError::MountMissing)?; | ||
| MountInfo::from_mount_dir(root.into_os_string()) | ||
| }; | ||
| Filesystem::new(mount_info, Some(file)).ok_or(FsError::MountMissing) |
There was a problem hiding this comment.
I'm not sure I understand what this does.
There was a problem hiding this comment.
old Filesystem::from_path(mounts, path) was unix only and I didn't want to introduce a windows fix there
biggest conflict will be with this PR #14456 since you introduced the nt module I think it would be better to merge your PR first, I'll adjust to those changes |
|
Ah yeah, I forgot about #14456. That PR is really nice. |
|
sorry, 2 conflicts |
No description provided.