@setoelkahfi / svara / commits / 8dd84da

feat: added command to open files in default user app

mellbacon committed Nov 1, 2023 at 00:57 UTC 8dd84dafcc8230f5bfe021786e1cdbb6d3be3a66
1 file changed +13 -2
src-tauri/src/main.rs
+13 -2
@@ -39,6 +39,16 @@ fn open_in_explorer(path: &str) {
39 }
40 }
41
42 +#[tauri::command]
43 +fn open_in_default(path: &str) {
44 + if env::consts::OS == "windows" {
45 + Command::new("powershell")
46 + .args(["&", path])
47 + .spawn()
48 + .unwrap();
49 + }
50 +}
51 +
52 #[tauri::command]
53 fn is_file(path: &str) -> bool {
54 fs::metadata(path).unwrap().is_file()
@@ -219,7 +229,7 @@ fn configure_log_path(app: &mut App) {
229 .format(&format)
230 .unwrap();
231 let log_name = format!("nucleus_log-{}.log", time);
222 -
232 +
233 // changing the default log name to something more meaningful
234 let new_log_path = app_log_dir.join(log_name);
235 fs::rename(old_log_path, new_log_path).unwrap();
@@ -286,7 +296,8 @@ fn main() {
296 is_file,
297 is_folder,
298 read_file,
289 - write_file
299 + write_file,
300 + open_in_default
301 ])
302 .plugin(tauri_plugin_fs_watch::init())
303 .plugin(tauri_plugin_store::Builder::default().build())