summaryrefslogtreecommitdiffstats
path: root/src/meta/windows_utils.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/meta/windows_utils.rs')
-rw-r--r--src/meta/windows_utils.rs14
1 files changed, 13 insertions, 1 deletions
diff --git a/src/meta/windows_utils.rs b/src/meta/windows_utils.rs
index e647c26..a9db172 100644
--- a/src/meta/windows_utils.rs
+++ b/src/meta/windows_utils.rs
@@ -2,7 +2,7 @@ use std::ffi::{OsStr, OsString};
use std::io;
use std::mem::MaybeUninit;
use std::os::windows::ffi::{OsStrExt, OsStringExt};
-use std::path::Path;
+use std::path::{Path, PathBuf};
use windows::Win32::Foundation::PSID;
use windows::Win32::Security::{self, Authorization::TRUSTEE_W, ACL};
@@ -343,6 +343,18 @@ pub fn is_path_system(path: &Path) -> bool {
)
}
+/// Expands the `~` in a path to the current user's home directory
+pub fn expand_home(path: PathBuf) -> PathBuf {
+ if path.starts_with("~") {
+ if let Some(home) = dirs::home_dir() {
+ let mut expanded = home.to_path_buf();
+ expanded.push(path.strip_prefix("~").unwrap());
+ return expanded;
+ }
+ }
+ path
+}
+
#[cfg(test)]
mod test {
use super::*;