From bb207c5e012a5a74a0a7ab829b56f34dc9486366 Mon Sep 17 00:00:00 2001 From: RaindropsSys Date: Fri, 10 May 2024 20:49:55 +0200 Subject: Crappy code fix 5/? --- launcher/src/main.rs | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) (limited to 'launcher') diff --git a/launcher/src/main.rs b/launcher/src/main.rs index 0afb8aa..3a961a0 100644 --- a/launcher/src/main.rs +++ b/launcher/src/main.rs @@ -112,19 +112,18 @@ fn main() { show_system_info(); println!("atomic-launcher: Compiled against rustc {}", rustc_version_runtime::version()); - let my_path_buf = std::env::current_exe() - .unwrap_or(PathBuf::from("/")); - let my_path = my_path_buf - .parent() - .unwrap_or(Path::new("/")) - .to_str() - .unwrap_or("/"); + let exec_path = std::env::current_exe(); + let work_dir = exec_path.as_ref().map(|p| p.parent()).ok() + .unwrap_or(Some(Path::new("/"))) + .unwrap_or(Path::new("/")); - println!("atomic-launcher: Current directory: {}", my_path); + println!("atomic-launcher: Current directory: {}", work_dir + .to_str() + .unwrap_or("/")); let mut found_app = false; - let app_path_unparsed = &format!("{}/{}", my_path, APP_DATA_PATH); - let app_path = Path::new(app_path_unparsed); + let mut app_path = PathBuf::from(work_dir); + app_path.push(APP_DATA_PATH); if app_path.exists() { found_app = true; -- cgit