fix reshade

This commit is contained in:
SpikeHD
2022-07-26 20:59:33 -07:00
parent 0971f5b826
commit 79891238b6
3 changed files with 18 additions and 1 deletions

View File

@@ -26,13 +26,28 @@ pub fn run_program_relative(path: String, args: Option<String>) {
}
#[tauri::command]
pub fn run_command(program: &str, args: Vec<&str>) {
pub fn run_command(program: &str, args: Vec<&str>, relative: Option<bool>) {
let prog = program.to_string();
let args = args.iter().map(|s| s.to_string()).collect::<Vec<String>>();
// Commands should not block (this is for the reshade injector mostly)
std::thread::spawn(move || {
// Save the current working directory
let cwd = std::env::current_dir().unwrap();
if relative.unwrap_or(false) {
// Set the new working directory to the path before the executable
let mut path_buf = std::path::PathBuf::from(&prog);
path_buf.pop();
// Set new working directory
std::env::set_current_dir(&path_buf).unwrap();
}
cmd(prog, args).run().unwrap();
// Restore the original working directory
std::env::set_current_dir(&cwd).unwrap();
});
}