normalize_absolute_path

Function normalize_absolute_path 

Source
pub fn normalize_absolute_path(path: &Path) -> Result<PathBuf, Error>
Expand description

Normalize a path, removing things like . and ...

Source: https://github.com/rust-lang/cargo/blob/b48c41aedbd69ee3990d62a0e2006edbb506a480/crates/cargo-util/src/paths.rs#L76C1-L109C2

CAUTION: Assumes that the path is already absolute.

CAUTION: This does not resolve symlinks (unlike std::fs::canonicalize). This may cause incorrect or surprising behavior at times. This should be used carefully. Unfortunately, std::fs::canonicalize can be hard to use correctly, since it can often fail, or on Windows returns annoying device paths.

ยงErrors

When a relative path is provided with .. components that extend beyond the base directory. For example, ./a/../../b cannot be normalized because it escapes the base directory.