fn set_proper_home_dir(cfg_str: &str) -> StringExpand description
Expands the tilde (~) character to the user’s home directory path.
Replaces the leading ~ in a path string with the absolute path to the
user’s home directory. If no ~ is present, returns the string unchanged.
§Arguments
cfg_str- A path string that may contain a leading~
§Returns
A String with ~ expanded to the full home directory path
§Panics
Panics if the user’s home directory cannot be determined
(via the dirs::home_dir() function).
§Examples
ⓘ
// On Linux/macOS with home at /home/user
let expanded = set_proper_home_dir("~/Documents/Obsidian");
assert_eq!(expanded, "/home/user/Documents/Obsidian");
// Path without tilde is returned unchanged
let unchanged = set_proper_home_dir("/absolute/path");
assert_eq!(unchanged, "/absolute/path");§Platform Behavior
- Linux/macOS: Expands to
/home/usernameor/Users/username - Windows: Expands to
C:\Users\username
§Used By
This function is called by: