# HG changeset patch # User Jiri Vanek # Date 1551882103 -3600 # Node ID b60023d6a3a5d4e7adc185a16ac1cda7608e0178 # Parent c65cc4a88808e695e8ed4a805e8068797cf548d9 On windows, use dunce to canonicalize paths * rust-launcher/Cargo.toml: added dunce crate for windows target * rust-launcher/src/dirs_paths_helper.rs: declared canonicalize methods, one for windows, second for not-windows. The windows one is using dunce, other is on PathBuf. * rust-launcher/src/utils.rs:used above method insted PathBuf::canonicalize diff -r c65cc4a88808 -r b60023d6a3a5 ChangeLog --- a/ChangeLog Tue Mar 05 16:18:51 2019 +0100 +++ b/ChangeLog Wed Mar 06 15:21:43 2019 +0100 @@ -1,3 +1,12 @@ +2019-03-06 Jiri Vanek + Lars Herschke + + On windows, use dunce to canonicalize paths + * rust-launcher/Cargo.toml: added dunce crate for windows target + * rust-launcher/src/dirs_paths_helper.rs: declared canonicalize methods, one for windows, second for not-windows. + The windows one is using dunce, other is on PathBuf. + * rust-launcher/src/utils.rs:used above method insted PathBuf::canonicalize + 2019-03-05 Jiri Vanek Lars Herschke diff -r c65cc4a88808 -r b60023d6a3a5 rust-launcher/Cargo.toml --- a/rust-launcher/Cargo.toml Tue Mar 05 16:18:51 2019 +0100 +++ b/rust-launcher/Cargo.toml Wed Mar 06 15:21:43 2019 +0100 @@ -4,5 +4,5 @@ authors = ["https://icedtea.classpath.org/wiki/IcedTea-Web"] [dependencies] - - +[target.'cfg(windows)'.dependencies] +dunce = "0.1.1" diff -r c65cc4a88808 -r b60023d6a3a5 rust-launcher/src/dirs_paths_helper.rs --- a/rust-launcher/src/dirs_paths_helper.rs Tue Mar 05 16:18:51 2019 +0100 +++ b/rust-launcher/src/dirs_paths_helper.rs Wed Mar 06 15:21:43 2019 +0100 @@ -1,8 +1,12 @@ use os_access; use std; +use std::io; use std::env; +#[cfg(windows)] extern crate dunce; + + pub static ICEDTEA_WEB: &'static str = "icedtea-web"; pub static DEPLOYMENT_PROPERTIES: &'static str = "deployment.properties"; @@ -77,6 +81,18 @@ String::from(current_program().file_name().expect("unwrap of pgm name failed").to_str().expect("unwrap of pgm name failed")) } +#[cfg(not(windows))] +pub fn canonicalize(full_path: &std::path::PathBuf) -> Result { + full_path.canonicalize() +} + + +#[cfg(windows)] +pub fn canonicalize(full_path: &std::path::PathBuf) -> Result { + dunce::canonicalize(&full_path) +} + + /*tests*/ #[cfg(test)] mod tests { diff -r c65cc4a88808 -r b60023d6a3a5 rust-launcher/src/utils.rs --- a/rust-launcher/src/utils.rs Tue Mar 05 16:18:51 2019 +0100 +++ b/rust-launcher/src/utils.rs Wed Mar 06 15:21:43 2019 +0100 @@ -83,7 +83,7 @@ write!(&mut info1, "itw-rust-debug: trying {}", full_path.to_str().expect("unwrap failed")).expect("unwrap failed"); os.log(&info1); if dirs_paths_helper::is_file(&full_path) { - let can = match full_path.canonicalize() { + let can = match dirs_paths_helper::canonicalize(&full_path) { Ok(resolved) => { //.../bin/java resolved @@ -159,7 +159,7 @@ #[test] fn try_jre_exists_on_path() { - let top_dir = fake_jre(true).canonicalize().expect("canonicalize failed"); + let top_dir = dirs_paths_helper::canonicalize(&fake_jre(true)).expect("canonicalize failed"); let mut master_dir = top_dir.clone(); master_dir.push("bin"); let v1 = super::get_jdk_from_path_conditionally_testable(Some(fo::from(master_dir.clone())), hardcoded_paths::ItwLibSearch::DISTRIBUTION, &TestLogger::create_new()); @@ -196,7 +196,7 @@ let v3 = super::get_jdk_from_path_conditionally_testable(Some(fo::from(master_dir.clone())), hardcoded_paths::ItwLibSearch::BOTH, &TestLogger::create_new()); debuggable_remove_dir(&master_dir); assert_eq!(None, v1); - let parent = std::path::PathBuf::from(master_dir.parent().expect("just created")).canonicalize().expect("canonicalize failed"); + let parent = dirs_paths_helper::canonicalize(&std::path::PathBuf::from(master_dir.parent().expect("just created"))).expect("canonicalize failed"); assert_eq!(Some(parent.clone()), v2); assert_eq!(Some(parent.clone()), v3); }