add reader

This commit is contained in:
cast1e
2024-09-27 23:24:24 +08:00
parent 08b61c9779
commit 989aaf73a8
4 changed files with 7 additions and 2 deletions
+5 -2
View File
@@ -12,6 +12,7 @@ fn main() {
tauri::Builder::default()
.setup(setup::init)
.invoke_handler(tauri::generate_handler![test_command])
.invoke_handler(tauri::generate_handler![read_resource_dir])
.run(tauri::generate_context!())
.expect("error while running tauri application");
}
@@ -24,8 +25,10 @@ async fn test_command() -> String {
#[tauri::command]
async fn read_resource_dir() -> String {
let mut file_map = reader::FileMap::new();
let file_map = reader::FileMap::new();
let path = Path::new("./resource");
fs::exists(path).is_err_and(|_|{fs::create_dir(path);return true;});
if let Ok(false) = fs::exists(path){
fs::create_dir(path).expect("Can't create dir");
}
serde_json::to_string(&file_map).unwrap()
}