CAI-Watchdog/src/mods/mod_fs.rs
2025-01-27 21:27:46 +03:00

27 lines
618 B
Rust

//! CAI-Watchdog filesystem module
//! Author: Alexander I. Chebykin (CAI) <alex.chebykin@gmail.com>
use std::env;
use std::path::PathBuf;
/// Return executable path
///
/// Return executable path or . if can't determine it
pub fn get_exe_path() -> String {
let mut dir;
let exe_path: String;
match env::current_exe() {
Ok(full_name) => {
dir = PathBuf::from(full_name);
dir.pop();
exe_path = dir.clone().into_os_string().into_string().unwrap();
},
Err(_e) => {
exe_path = ".".to_string();
},
}
return exe_path;
}