This commit is contained in:
SpikeHD
2022-07-09 22:52:04 -07:00
33 changed files with 7594 additions and 7116 deletions

View File

@@ -1,7 +1,3 @@
use std::thread;
use tauri;
use open;
use duct::cmd;
use crate::file_helpers;
@@ -9,11 +5,7 @@ use crate::file_helpers;
#[tauri::command]
pub fn run_program(path: String) {
// Open the program from the specified path.
// Open in new thread to prevent blocking.
thread::spawn(move || {
open::that(&path).unwrap();
});
open::that(&path).unwrap();
}
#[tauri::command]
@@ -31,7 +23,7 @@ pub fn run_jar(path: String, execute_in: String, java_path: String) {
};
// Open the program from the specified path.
match open::with(format!("/k cd /D \"{}\" & {}", &execute_in, &command).to_string(), "C:\\Windows\\System32\\cmd.exe") {
match open::with(format!("/k cd /D \"{}\" & {}", &execute_in, &command), "C:\\Windows\\System32\\cmd.exe") {
Ok(_) => (),
Err(e) => println!("Failed to open jar ({} from {}): {}", &path, &execute_in, e),
};
@@ -46,6 +38,7 @@ pub fn open_in_browser(url: String) {
};
}
#[tauri::command]
pub fn install_location() -> String {
let mut exe_path = std::env::current_exe().unwrap();
@@ -56,7 +49,14 @@ pub fn install_location() -> String {
return exe_path.to_str().unwrap().to_string();
}
#[cfg(windows)]
#[tauri::command]
pub fn is_elevated() -> bool {
return is_elevated::is_elevated();
}
is_elevated::is_elevated()
}
#[cfg(unix)]
#[tauri::command]
pub fn is_elevated() -> bool {
sudo::check() == sudo::RunningAs::Root
}