Skip to main content

Mountain/ProcessManagement/NodeResolver/
ExpandHome.rs

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