mirror of
https://github.com/RGBCube/uutils-coreutils
synced 2025-07-28 11:37:44 +00:00
tests/pwd: fix broken Windows test
Due to canonicalize()'s use of GetFinalPathNameByHandleW() on Windows, the resolved path starts with '\\?\' to extend the limit of a given path to 32,767 wide characters. To address this issue, we remove this prepended string if available.
This commit is contained in:
parent
e0c21b99c5
commit
ec14be84aa
1 changed files with 15 additions and 1 deletions
|
@ -252,7 +252,21 @@ impl AtPath {
|
||||||
|
|
||||||
pub fn root_dir_resolved(&self) -> String {
|
pub fn root_dir_resolved(&self) -> String {
|
||||||
log_info("current_directory_resolved", "");
|
log_info("current_directory_resolved", "");
|
||||||
self.subdir.canonicalize().unwrap().to_str().unwrap().to_owned()
|
let s = self.subdir.canonicalize().unwrap().to_str().unwrap().to_owned();
|
||||||
|
|
||||||
|
// Due to canonicalize()'s use of GetFinalPathNameByHandleW() on Windows, the resolved path
|
||||||
|
// starts with '\\?\' to extend the limit of a given path to 32,767 wide characters.
|
||||||
|
//
|
||||||
|
// To address this issue, we remove this prepended string if available.
|
||||||
|
//
|
||||||
|
// Source:
|
||||||
|
// http://stackoverflow.com/questions/31439011/getfinalpathnamebyhandle-without-prepended
|
||||||
|
let prefix = "\\\\?\\";
|
||||||
|
if s.starts_with(prefix) {
|
||||||
|
String::from(&s[prefix.len()..])
|
||||||
|
} else {
|
||||||
|
s
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue