Whether a proper ancestor of `path` (relative to `root`) is a symlink on disk.
(root: &Path, path: &str)
| 1728 | /// Whether a proper ancestor of `path` (relative to `root`) is a symlink on |
| 1729 | /// disk. |
| 1730 | fn 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(¤t) |
| 1736 | .map(|metadata| metadata.file_type().is_symlink()) |
| 1737 | .unwrap_or(false) |
| 1738 | { |
| 1739 | return true; |
| 1740 | } |
| 1741 | } |
| 1742 | false |
| 1743 | } |
no test coverage detected