From d56b6536f95ef928bcb0c690280887d976c60b9b Mon Sep 17 00:00:00 2001 From: RaindropsSys Date: Fri, 10 May 2024 22:46:53 +0200 Subject: Crappy code fix 13/? --- launcher/src/lib.rs | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) (limited to 'launcher/src/lib.rs') diff --git a/launcher/src/lib.rs b/launcher/src/lib.rs index 9e2ef8b..3e5d0fe 100644 --- a/launcher/src/lib.rs +++ b/launcher/src/lib.rs @@ -1,3 +1,5 @@ +mod constants; + use std::ffi::OsStr; use std::path::PathBuf; @@ -13,4 +15,29 @@ impl AppData { AppData::Asar(path) => path.as_ref() } } + + pub fn locate_app(work_dir: &PathBuf) -> Option { + let mut app_data: Option = None; + + let mut app_path_folder = PathBuf::from(work_dir); + app_path_folder.push(constants::APP_FOLDER_PATH); + + let mut app_path_asar = PathBuf::from(work_dir); + app_path_asar.push(constants::APP_ASAR_PATH); + + if app_path_folder.exists() { + app_data = Some(AppData::Folder(app_path_folder)) + } else if app_path_asar.exists() { + app_data = Some(AppData::Asar(app_path_asar)) + } else { + println!( + "atomic-launcher: Warning: Could not find Electron-compatible app.\ + Looked in {} and {}. The default atomic-runtime application will be opened instead.", + app_path_folder.to_str().unwrap(), + app_path_asar.to_str().unwrap() + ); + } + + app_data + } } -- cgit