Skip to main content

absolute_path

Function absolute_path 

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

Absolute, symlink-free spelling of a path when it exists, its lexical absolute otherwise.

std::path::absolute is purely lexical: it follows no symlink and keeps every .. it is handed. macOS reaches one temporary tree through /var and /private/var, so a digest taken over a lexical spelling would split that owner tree across two derived socket directories. Canonicalizing first gives every live tree one spelling. A missing path has nothing to canonicalize, so the fallback collapses .. against the components in front of them, which keeps /srv/a/../b and /srv/b one answer before either directory exists.