normalize_path

Function normalize_path 

Source
pub fn normalize_path(p: impl AsRef<Path>) -> PathBuf
Expand description

Similiar to std::fs::canonicalize, but normalizes inexistent paths, and with a few differences.

For Windows, any \\?\X:, X:, or \\?\UNC\ prefixes are ensured to be uppercase and UNC host names and rest characters are always returned in lowercase form.

assert_eq!(PathBuf::from_str(r"\\?\C:\program files").unwrap(), normalize_path(r"C:/Program Files/"));
assert_eq!(PathBuf::from_str(r"\\?\UNC\server\foo").unwrap(), normalize_path(r"\\server\foo\"));
assert_eq!(PathBuf::from_str(r"\\?\C:\foo").unwrap(), normalize_path(r"\\?\c:/foo/"));
assert_eq!(PathBuf::from_str(r"\\?\UNC\server\foo").unwrap(), normalize_path(r"\\?\unc\server\Foo\"));