lexical_normalize

Function lexical_normalize 

Source
pub fn lexical_normalize(path: &Path) -> PathBuf
Expand description

Lexically normalizes a path by resolving . and .. components without accessing the filesystem.

This performs purely lexical simplification: it removes . segments, collapses .. where possible, preserves rooted prefixes, and never queries the filesystem.

ยงExamples

use ito_config::ito_dir::lexical_normalize;
use std::path::{Path, PathBuf};

let p = Path::new("a/./b/../c");
assert_eq!(lexical_normalize(p), PathBuf::from("a/c"));

let abs = Path::new("/a/b/../c");
assert_eq!(lexical_normalize(abs), PathBuf::from("/a/c"));

let up = Path::new("../a/../b");
assert_eq!(lexical_normalize(up), PathBuf::from("../b"));