MCPcopy Create free account
hub / github.com/atomicdotdev/atomic / path_beneath_symlink

Function path_beneath_symlink

atomic-repository/src/repository/switch.rs:1730–1743  ·  view source on GitHub ↗

Whether a proper ancestor of `path` (relative to `root`) is a symlink on disk.

(root: &Path, path: &str)

Source from the content-addressed store, hash-verified

1728/// Whether a proper ancestor of `path` (relative to `root`) is a symlink on
1729/// disk.
1730fn path_beneath_symlink(root: &Path, path: &str) -> bool {
1731 let components: Vec<_> = Path::new(path).components().collect();
1732 let mut current = root.to_path_buf();
1733 for component in components.iter().take(components.len().saturating_sub(1)) {
1734 current.push(component);
1735 if std::fs::symlink_metadata(&current)
1736 .map(|metadata| metadata.file_type().is_symlink())
1737 .unwrap_or(false)
1738 {
1739 return true;
1740 }
1741 }
1742 false
1743}

Callers 1

remove_pathMethod · 0.85

Calls 5

componentsMethod · 0.80
collectMethod · 0.45
iterMethod · 0.45
lenMethod · 0.45
pushMethod · 0.45

Tested by

no test coverage detected