From 52da44b86c7d8fd879821b98744d658ff09bafe2 Mon Sep 17 00:00:00 2001 From: abose Date: Sat, 3 Feb 2024 18:09:41 +0530 Subject: [PATCH] chore: add get_current_working_dir tauri api --- src-tauri/src/main.rs | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src-tauri/src/main.rs b/src-tauri/src/main.rs index dceb0bbd..1420809c 100644 --- a/src-tauri/src/main.rs +++ b/src-tauri/src/main.rs @@ -5,12 +5,11 @@ windows_subsystem = "windows" use std::env; use tauri::{Manager}; +use std::path::PathBuf; #[cfg(target_os = "linux")] use std::fs::metadata; #[cfg(target_os = "linux")] -use std::path::PathBuf; -#[cfg(target_os = "linux")] use gtk::{glib::ObjectExt, prelude::WidgetExt}; use std::process::Command; @@ -61,6 +60,10 @@ fn _get_commandline_args() -> Option> { Some(env::args().collect()) } +#[tauri::command] +fn get_current_working_dir() -> Result { + env::current_dir().map_err(|e| e.to_string()) +} #[tauri::command] fn _rename_path(old_path: &str, new_path: &str) -> Result<(), String> { @@ -287,7 +290,7 @@ fn main() { .on_window_event(|event| process_window_event(&event)) .invoke_handler(tauri::generate_handler![ get_mac_deep_link_requests, - toggle_devtools, console_log, console_error, _get_commandline_args, + toggle_devtools, console_log, console_error, _get_commandline_args, get_current_working_dir, _get_window_labels, _get_windows_drives, _rename_path, show_in_folder, zoom_window, _get_clipboard_files]) .setup(|app| {