pub struct PathAliases { /* private fields */ }Expand description
Alternative spellings of a path, implied by the absolute patterns in a configuration.
A pattern names a location the way the user wrote it (/var/folders/** on
macOS); the file it is matched against arrives canonicalized
(/private/var/folders/…), so the two never meet. Each pair recorded here
is one symlinked prefix some pattern reached a location through: the
canonical form of that pattern’s leading literal components, and the
spelling the pattern used for them.
Rewriting the path rather than the pattern leaves globset the only
authority on what a pattern means, and cannot invent a match:
canonicalize(as_written) == canonical together with path == canonical + rest say that as_written + rest names that same file. Brace alternations
are expanded only to find more prefixes to canonicalize, so an expansion
that disagrees with globset can cost a spelling, never fabricate one.
Implementations§
Source§impl PathAliases
impl PathAliases
Sourcepub fn new<'a>(patterns: impl IntoIterator<Item = &'a str>) -> Self
pub fn new<'a>(patterns: impl IntoIterator<Item = &'a str>) -> Self
Collect the symlinked prefixes patterns reach locations through.
Each pattern is canonicalized once here, at cache-build time, so per-file matching pays no syscall.
pub fn is_empty(&self) -> bool
Sourcepub fn spellings_of(&self, path: &Path) -> Vec<String>
pub fn spellings_of(&self, path: &Path) -> Vec<String>
The spellings of path reachable through a recorded prefix, as glob
match candidates. Empty when no pattern reached path’s location
through a symlink, which is every configuration that has none.