From a39a4c8a962e7583ad63389bd1d90f506396f7e9 Mon Sep 17 00:00:00 2001 From: Xory Date: Mon, 17 Jun 2024 14:53:59 +0300 Subject: [PATCH] feat: linux compat fix --- src/decrypt.rs | 5 ++++- src/encrypt.rs | 3 +++ 2 files changed, 7 insertions(+), 1 deletion(-) 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.