From 281bfb5cea3580224774014d5fa06279ccb933e9 Mon Sep 17 00:00:00 2001 From: SpikeHD Date: Tue, 26 Jul 2022 22:30:25 -0700 Subject: [PATCH] cheeky key path fix --- src-tauri/src/main.rs | 5 +++++ src-tauri/src/metadata_patcher.rs | 7 ++++++- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/src-tauri/src/main.rs b/src-tauri/src/main.rs index c8db8e1..23fb3bf 100644 --- a/src-tauri/src/main.rs +++ b/src-tauri/src/main.rs @@ -24,6 +24,11 @@ mod web; static WATCH_GAME_PROCESS: Lazy> = Lazy::new(|| Mutex::new(String::new())); fn main() { + // Always set CWD to the location of the executable. + let mut exe_path = std::env::current_exe().unwrap(); + exe_path.pop(); + std::env::set_current_dir(&exe_path).unwrap(); + tauri::Builder::default() .invoke_handler(tauri::generate_handler![ enable_process_watcher, diff --git a/src-tauri/src/metadata_patcher.rs b/src-tauri/src/metadata_patcher.rs index 7965676..9e0d0d1 100644 --- a/src-tauri/src/metadata_patcher.rs +++ b/src-tauri/src/metadata_patcher.rs @@ -111,7 +111,12 @@ fn replace_keys(data: &[u8]) -> Vec { fn replace_rsa_key(old_data: &str, to_replace: &str, file_name: &str) -> String { // Read dispatch key file unsafe { - let mut new_key_file = match File::open(&("keys/".to_owned() + file_name)) { + // Get key folder from exe path + let mut exe_path = std::env::current_exe().unwrap(); + exe_path.pop(); + + let key_folder = exe_path.to_str().unwrap().to_string(); + let mut new_key_file = match File::open(format!("{}/keys/{}", key_folder, file_name)) { Ok(file) => file, Err(e) => { println!("Failed to open keys/{}: {}", file_name, e);