mod constants; use std::ffi::OsStr; use std::path::PathBuf; pub enum AppData { Folder(PathBuf), Asar(PathBuf) } impl AppData { pub fn get_path(&self) -> &OsStr { match self { AppData::Folder(path) => path.as_ref(), 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 } }