Skip to main content

soft_canonicalize

Function soft_canonicalize 

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

Canonicalize the longest existing prefix of path and append the rest.

Where the player is going may not exist yet (a cd to a typo), and the workspace may live below a symlink (macOS /tmp is /private/tmp), so strict canonicalize is too brittle for comparing directories. The existing part is resolved physically by the OS; the missing tail is appended lexically (. dropped, .. cancels the previous component). It never fails: with nothing resolvable the lexical normalization of the input is returned.

Expects an absolute path; a relative one is resolved by the OS against the process working directory, which the engine never relies on.