Skip to content

Commit 52da44b

Browse files
committed
chore: add get_current_working_dir tauri api
1 parent 951a665 commit 52da44b

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

src-tauri/src/main.rs

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,11 @@ windows_subsystem = "windows"
55
use std::env;
66

77
use tauri::{Manager};
8+
use std::path::PathBuf;
89

910
#[cfg(target_os = "linux")]
1011
use std::fs::metadata;
1112
#[cfg(target_os = "linux")]
12-
use std::path::PathBuf;
13-
#[cfg(target_os = "linux")]
1413
use gtk::{glib::ObjectExt, prelude::WidgetExt};
1514

1615
use std::process::Command;
@@ -61,6 +60,10 @@ fn _get_commandline_args() -> Option<Vec<String>> {
6160
Some(env::args().collect())
6261
}
6362

63+
#[tauri::command]
64+
fn get_current_working_dir() -> Result<PathBuf, String> {
65+
env::current_dir().map_err(|e| e.to_string())
66+
}
6467

6568
#[tauri::command]
6669
fn _rename_path(old_path: &str, new_path: &str) -> Result<(), String> {
@@ -287,7 +290,7 @@ fn main() {
287290
.on_window_event(|event| process_window_event(&event))
288291
.invoke_handler(tauri::generate_handler![
289292
get_mac_deep_link_requests,
290-
toggle_devtools, console_log, console_error, _get_commandline_args,
293+
toggle_devtools, console_log, console_error, _get_commandline_args, get_current_working_dir,
291294
_get_window_labels,
292295
_get_windows_drives, _rename_path, show_in_folder, zoom_window, _get_clipboard_files])
293296
.setup(|app| {

0 commit comments

Comments
 (0)