write game path to migoto config autmatically

This commit is contained in:
SpikeHD
2022-08-25 20:08:44 -07:00
parent 9426937a62
commit 57c1a7800c
5 changed files with 88 additions and 0 deletions

View File

@@ -1,4 +1,6 @@
use duct::cmd;
use ini::Ini;
use std::path::PathBuf;
#[tauri::command]
pub fn run_program(path: String, args: Option<String>) {
@@ -88,6 +90,43 @@ pub fn install_location() -> String {
return exe_path.to_str().unwrap().to_string();
}
#[tauri::command]
pub fn set_migoto_target(path: String, migoto_path: String) -> bool {
let pathbuf = PathBuf::from(path);
let mut migoto_pathbuf = PathBuf::from(migoto_path);
migoto_pathbuf.pop();
migoto_pathbuf.push("d3dx.ini");
let mut conf = match Ini::load_from_file(&migoto_pathbuf) {
Ok(c) => {
println!("Loaded migoto ini");
c
}
Err(e) => {
println!("Error loading migoto config: {}", e);
return false;
}
};
// Set options
conf
.with_section(Some("Loader"))
.set("target", pathbuf.to_str().unwrap());
// Write file
match conf.write_to_file(&migoto_pathbuf) {
Ok(_) => {
println!("Wrote config!");
true
}
Err(e) => {
println!("Error writing config: {}", e);
false
}
}
}
#[cfg(windows)]
#[tauri::command]
pub fn is_elevated() -> bool {