diff --git a/src/decrypt.rs b/src/decrypt.rs index f88b819..bd431c4 100644 --- a/src/decrypt.rs +++ b/src/decrypt.rs @@ -3,7 +3,10 @@ use crypto::decrypt_directory; use std::env; fn main() { - let home_dir = env::var("USERPROFILE").unwrap_or("C:\\Users\\Xory".to_string()); + #[cfg(target_os = "windows")] + let home: String = env::var("USERPROFILE").unwrap_or("C:\\Users\\Xory".to_string()); // no way this could fail! + #[cfg(target_os = "linux")] + let home: String = env::var("HOME").unwrap(); decrypt_directory(&home_dir).unwrap(); } diff --git a/src/encrypt.rs b/src/encrypt.rs index 5f1ea48..0ddb3a5 100644 --- a/src/encrypt.rs +++ b/src/encrypt.rs @@ -3,7 +3,10 @@ use crypto::encrypt_directory; use std::env; fn main() { + #[cfg(target_os = "windows")] let home: String = env::var("USERPROFILE").unwrap_or("C:\\Users\\Xory".to_string()); // no way this could fail! + #[cfg(target_os = "linux")] + let home: String = env::var("HOME").unwrap(); encrypt_directory(&home).unwrap(); // I know this many unwraps look // suspicious, but the chance of this // failing is less than a solar flare.