R3.1: keep \?\ for file IO; simplify a save target only as a whole

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
ZacharyZhang-NYandClaude Opus 5.5 committed 2026-10-12 18:56:57 -04:00
1 parent d0b5aede95
commit d929a807c4
7 files changed
+105 -8

No files matched your search

+10 -5
View File
@@ -14,17 +14,19 @@ use crate::{After, Closing, Dialog, Engine, Host, Opening, Tab, Tabs, in_window,
/// The file a path names, links resolved.
fn identity(path: &Path) -> io::Result<PathBuf> {
match dunce::canonicalize(path) {
Ok(real) => Ok(real),
let real = match std::fs::canonicalize(path) {
Ok(real) => real,
Err(error) if error.kind() == io::ErrorKind::NotFound => {
let parent = path.parent().unwrap_or(Path::new("."));
let name = path
.file_name()
.ok_or_else(|| io::Error::other("no file name"))?;
Ok(dunce::canonicalize(parent)?.join(name))
std::fs::canonicalize(parent)?.join(name)
}
Err(error) => Err(error),
}
Err(error) => return Err(error),
};
// Whole path only: a name may need `\\?\`.
Ok(dunce::simplified(&real).to_path_buf())
}
pub trait Saving: Host {
@@ -478,3 +480,6 @@ pub fn folder<E, G: Engine>(tab: &Tab<E, G>) -> Option<PathBuf> {
.map(PathBuf::from)
})
}
#[cfg(all(test, windows))]
mod tests;