[−][src]Trait mmrbi::PathExt
Utility methods for std::path::Path[Buf]
Required methods
fn cleanup(&self) -> PathBuf
Cleanup/simplify path as much as possible
Examples
use mmrbi::PathExt; assert_eq!(Path::new("a/b").cleanup(), Path::new("a/b")); assert_eq!(Path::new("a/b/..").cleanup(), Path::new("a")); assert_eq!(Path::new("a/b/../..").cleanup(), Path::new(".")); assert_eq!(Path::new("a/b/../../..").cleanup(), Path::new("..")); assert_eq!(Path::new("a/b/../../../..").cleanup(), Path::new("../..")); assert_eq!(Path::new("../../a/b").cleanup(), Path::new("../../a/b")); assert_eq!(Path::new("../../a/b/..").cleanup(), Path::new("../../a")); assert_eq!(Path::new("../../a/b/../..").cleanup(), Path::new("../..")); assert_eq!(Path::new("../../a/b/../../..").cleanup(), Path::new("../../..")); assert_eq!(Path::new("../../a/b/../../../..").cleanup(), Path::new("../../../..")); if cfg!(windows) { assert_eq!(Path::new(r"C:\foo\bar").cleanup(), Path::new(r"C:\foo\bar")); assert_eq!(Path::new(r"\\?\C:\foo\bar").cleanup(), Path::new(r"C:\foo\bar")); }