Skip to main content

Mountain/ProcessManagement/NodeResolver/
ExpandHome.rs

1
2//! Expand a leading `~/` against `$HOME`. Returns the input unchanged if
3//! `HOME` is unset or the path doesn't start with `~/`.
4
5use std::path::PathBuf;
6
7pub fn Fn(Raw:&str) -> PathBuf {
8	if let Some(Stripped) = Raw.strip_prefix("~/") {
9		if let Ok(Home) = std::env::var("HOME") {
10			return PathBuf::from(Home).join(Stripped);
11		}
12	}
13
14	PathBuf::from(Raw)
15}