Skip to content

Commit d6ab99d

Browse files
committed
feat: add move_to_trash api
1 parent 0fac504 commit d6ab99d

File tree

4 files changed

+37
-3
lines changed

4 files changed

+37
-3
lines changed

package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src-tauri/Cargo.lock

Lines changed: 26 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src-tauri/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ once_cell = "1.19.0"
1919
percent-encoding = "2.3.1"
2020
regex = "1.10.4"
2121
clipboard-files = "0.1.1"
22+
trash = "3"
2223
serde = { version = "1.0.200", features = ["derive"] }
2324
tauri = { version = "1.6.2", features = [ "updater", "cli", "api-all", "devtools", "linux-protocol-headers"] }
2425
winapi = { version = "0.3.9", features = ["fileapi"] }

src-tauri/src/main.rs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ use tauri::GlobalWindowEvent;
3333
mod init;
3434
mod utilities;
3535
mod boot_config;
36+
use trash;
3637

3738
mod platform;
3839
use tauri_plugin_window_state::StateFlags;
@@ -74,6 +75,12 @@ fn _rename_path(old_path: &str, new_path: &str) -> Result<(), String> {
7475
platform::rename_path(old_path, new_path)
7576
}
7677

78+
#[tauri::command]
79+
fn move_to_trash(delete_path: &str) -> Result<(), String> {
80+
trash::delete(delete_path)
81+
.map_err(|e| e.to_string())
82+
}
83+
7784
#[tauri::command]
7885
fn _get_window_labels(app: tauri::AppHandle) -> Vec<String> {
7986
app.windows()
@@ -344,7 +351,7 @@ fn main() {
344351
toggle_devtools, console_log, console_error, _get_commandline_args, get_current_working_dir,
345352
_get_window_labels,
346353
put_item, get_item, get_all_items, delete_item,
347-
_get_windows_drives, _rename_path, show_in_folder, zoom_window, _get_clipboard_files])
354+
_get_windows_drives, _rename_path, show_in_folder, move_to_trash, zoom_window, _get_clipboard_files])
348355
.setup(|app| {
349356
init::init_app(app);
350357
#[cfg(target_os = "linux")]

0 commit comments

Comments
 (0)