feat(io): add read_file/write_file commands and dialog capability

This commit is contained in:
pj committed 2026-06-20 12:54:01 -04:00
1 parent eb63a6d49d
commit 13f2a70af2
3 files changed
+20 -2

No files matched your search

+7 -1
View File
@@ -1,10 +1,16 @@
mod pdf;
mod project;
#[cfg_attr(mobile, tauri::mobile_entry_point)]
pub fn run() {
tauri::Builder::default()
.plugin(tauri_plugin_opener::init())
.invoke_handler(tauri::generate_handler![pdf::compile_pdf])
.plugin(tauri_plugin_dialog::init())
.invoke_handler(tauri::generate_handler![
pdf::compile_pdf,
project::read_file,
project::write_file
])
.run(tauri::generate_context!())
.expect("error while running margin");
}
+11
View File
@@ -0,0 +1,11 @@
use std::fs;
#[tauri::command]
pub fn read_file(path: String) -> Result<String, String> {
fs::read_to_string(&path).map_err(|e| e.to_string())
}
#[tauri::command]
pub fn write_file(path: String, contents: String) -> Result<(), String> {
fs::write(&path, contents).map_err(|e| e.to_string())
}