1
0
Fork 0
mirror of synced 2024-06-14 16:35:23 +12:00
This commit is contained in:
Rafał Mikrut 2023-10-15 22:21:26 +02:00
parent a5a300c520
commit 577bf47471

View file

@ -134,19 +134,24 @@ impl Directories {
} }
// Try to canonicalize them // Try to canonicalize them
if let Ok(dir) = directory.canonicalize() {
directory = dir;
dbg!("Is canonicalize", &directory);
}
if cfg!(windows) { if cfg!(windows) {
dbg!("Before windows", &directory); // Only canonicalize if it's not a network path
let path_str = directory.to_string_lossy().to_string(); // This can be check by checking if path starts with \\?\UNC\
if let Some(path_str) = path_str.strip_prefix(r"\\?\") { if let Ok(dir_can) = directory.canonicalize() {
if path_str.chars().nth(1) == Some(':') { let dir_can_str = dir_can.to_string_lossy().to_string();
directory = PathBuf::from(path_str); if dir_can_str.starts_with(r"\\?\") && dir_can_str.chars().nth(5) == Some(':') {
directory = PathBuf::from(dir_can_str);
} }
directory = dir_can;
dbg!("After canonicalize", &directory);
}
} else {
if let Ok(dir) = directory.canonicalize() {
directory = dir;
dbg!("Is canonicalize UNIX", &directory);
} }
dbg!("After windows", &directory);
} }
(Some(directory), messages) (Some(directory), messages)
} }