diff --git a/Cargo.toml b/Cargo.toml index d991b4d..d979b9e 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -5,4 +5,5 @@ edition = "2018" authors = ["Einjerjar"] description = "Simple alias implementation for windows using doskey" -[dependencies] \ No newline at end of file +[dependencies] +dirs = "5.0" \ No newline at end of file diff --git a/src/main.rs b/src/main.rs index 680df1b..e158831 100644 --- a/src/main.rs +++ b/src/main.rs @@ -3,8 +3,9 @@ use std::fs; use std::io::{Read, Write}; use std::process::Command; use std::path::Path; +use dirs; -const CONFIG_PATH: &str = "cmd_alias"; +const CONFIG_PATH: &str = "AppData\\Roaming\\cmd_alias"; const CONFIG_NAME: &str = "aliases.cmd"; fn main() -> Result<(), Box>{ @@ -31,9 +32,9 @@ fn main() -> Result<(), Box>{ } }; - let config_root = Path::new("C:\\Users\\E\\AppData\\Roaming"); + let home_dir = dirs::home_dir().expect("Failed to get home directory"); - let config_root = config_root.join(CONFIG_PATH); + let config_root = home_dir.join(CONFIG_PATH); let config_file = config_root.join(CONFIG_NAME); let _ = fs::create_dir_all(&config_root).unwrap();