aboutsummaryrefslogtreecommitdiff
path: root/launcher/src
diff options
context:
space:
mode:
Diffstat (limited to 'launcher/src')
-rw-r--r--launcher/src/main.rs35
1 files changed, 22 insertions, 13 deletions
diff --git a/launcher/src/main.rs b/launcher/src/main.rs
index 73b6862..4a87c81 100644
--- a/launcher/src/main.rs
+++ b/launcher/src/main.rs
@@ -1,6 +1,21 @@
+use std::ffi::OsStr;
use std::path::PathBuf;
use std::process;
+enum AppData {
+ Folder(PathBuf),
+ Asar(PathBuf)
+}
+
+impl AppData {
+ fn get_path(&self) -> &OsStr {
+ match self {
+ AppData::Folder(path) => path.as_ref(),
+ AppData::Asar(path) => path.as_ref()
+ }
+ }
+}
+
fn get_home() -> PathBuf {
dirs::home_dir().unwrap_or(PathBuf::from("/"))
}
@@ -146,8 +161,7 @@ fn main() {
work_dir.to_str().unwrap()
);
- let mut found_app = false;
- let mut app_is_asar = false;
+ let mut app_data: Option<AppData> = None;
let mut app_path_folder = PathBuf::from(work_dir);
app_path_folder.push(APP_FOLDER_PATH);
@@ -156,10 +170,9 @@ fn main() {
app_path_asar.push(APP_ASAR_PATH);
if app_path_folder.exists() {
- found_app = true;
+ app_data = Some(AppData::Folder(app_path_folder))
} else if app_path_asar.exists() {
- found_app = true;
- app_is_asar = true;
+ app_data = Some(AppData::Asar(app_path_asar))
} else {
println!(
"atomic-launcher: Warning: Could not find Electron-compatible app.\
@@ -190,16 +203,12 @@ fn main() {
"atomic-launcher: Found atomic-runtime at {}",
path.to_str().unwrap()
);
- let mut cmd = process::Command::new(path)
- .env("ATOMIC_LAUNCHER_VERSION", VERSION);
+ let mut cmd = process::Command::new(path);
+ cmd.env("ATOMIC_LAUNCHER_VERSION", VERSION);
println!("atomic-launcher: Executing: {:?}", cmd);
- if found_app {
- cmd.arg(if app_is_asar {
- app_path_asar
- } else {
- app_path_folder
- })
+ if let Some(app_data) = app_data {
+ cmd.arg(app_data.get_path());
}
if let Ok(status) = cmd.status() {