chipsenkbeil / typed-path

Provides typed variants of Path and PathBuf for Unix and Windows
38 stars 6 forks source link

Relaive paths not behaving like std::path::Path #6

Closed hjmallon closed 1 year ago

hjmallon commented 1 year ago

Easiest to show this in an example:

let atype = UnixPath::new("file.txt");
let btype = atype.parent().expect("should have parent").join("file2.txt");
println!("TYPED WAS: {}", atype.display());
// TYPED WAS: file.txt 
println!("TYPED NOW: {}", btype.display());
// TYPED NOW: /file2.txt <= (where has the Root / come from?)

let astd = std::path::Path::new("file.txt");
let bstd = astd.parent().expect("should have parent").join("file2.txt");
println!("STD WAS: {}", astd.display());
// STD WAS: file.txt
println!("STD NOW: {}", bstd.display());
// STD NOW: file2.txt
chipsenkbeil commented 1 year ago

Thanks for filing the issue! Looked into it and it's caused by this line: https://github.com/chipsenkbeil/typed-path/blob/main/src/unix/non_utf8.rs#L77

I'll look at correcting this soon.

chipsenkbeil commented 1 year ago

Please try 0.3.1 as a potential fix! If it is not resolved, we can reopen this issue :)

hjmallon commented 1 year ago

Thanks that works for me!