diff options
author | RaindropsSys <raindrops@equestria.dev> | 2024-05-10 22:46:53 +0200 |
---|---|---|
committer | RaindropsSys <raindrops@equestria.dev> | 2024-05-10 22:46:53 +0200 |
commit | d56b6536f95ef928bcb0c690280887d976c60b9b (patch) | |
tree | 07fd18f26a574ee1849892d5de55b72156765f7e /launcher/src/lib.rs | |
parent | 0ee8cd040aa7d1c89983454862c3939aea3c3bf1 (diff) | |
download | atomic-d56b6536f95ef928bcb0c690280887d976c60b9b.tar.gz atomic-d56b6536f95ef928bcb0c690280887d976c60b9b.tar.bz2 atomic-d56b6536f95ef928bcb0c690280887d976c60b9b.zip |
Crappy code fix 13/?
Diffstat (limited to 'launcher/src/lib.rs')
-rw-r--r-- | launcher/src/lib.rs | 27 |
1 files changed, 27 insertions, 0 deletions
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<AppData> { + let mut app_data: Option<AppData> = 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 + } } |