From 35d3563fa543f331743a3358ec0c9a4bc743011f Mon Sep 17 00:00:00 2001 From: DashCruft Date: Wed, 1 Feb 2023 22:18:39 -0800 Subject: [PATCH 1/2] Fixed a problem in regards of adding custom games (backend fs) --- src-tauri/src/main.rs | 22 ++++++++++++++++--- src/components/AllGames.vue | 43 +++++++++++++++++++++---------------- 2 files changed, 43 insertions(+), 22 deletions(-) diff --git a/src-tauri/src/main.rs b/src-tauri/src/main.rs index 6d6713ee..d900c3b4 100644 --- a/src-tauri/src/main.rs +++ b/src-tauri/src/main.rs @@ -145,7 +145,9 @@ fn main() { write_file, d_f_exists, read_dir, - write_binary_file + write_binary_file, + rename_file, + remove_file ]) .run(tauri::generate_context!()) .expect("error while running lazap"); @@ -205,7 +207,9 @@ fn main() { write_file, d_f_exists, read_dir, - write_binary_file + write_binary_file, + rename_file, + remove_file ]) .run(tauri::generate_context!()) .expect("error while running lazap"); @@ -266,7 +270,9 @@ fn main() { write_file, d_f_exists, read_dir, - write_binary_file + write_binary_file, + rename_file, + remove_file ]) .run(tauri::generate_context!()) .expect("error while running lazap"); @@ -361,6 +367,16 @@ async fn d_f_exists(path: String) -> Result { Ok(Path::new(&path).exists()) } +#[tauri::command] +async fn rename_file(from: String, to: String) { + fs::rename(from, to).expect("Unable to rename file."); +} + +#[tauri::command] +async fn remove_file(file_path: String) { + fs::remove_file(file_path).expect("Unable to remove file."); +} + #[tauri::command] async fn read_dir(dir_path: String) -> Vec { let mut file_list = Vec::new(); diff --git a/src/components/AllGames.vue b/src/components/AllGames.vue index 28b6140b..6ad3b838 100644 --- a/src/components/AllGames.vue +++ b/src/components/AllGames.vue @@ -72,7 +72,6 @@