Metadata of `relative` when every component of the path exists on disk under its exact name and every ancestor is a real directory. Returns `Ok(None)` when any component is missing, differs by case, or sits behind a symlinked or regular-file ancestor. A component matches an entry that differs only in Unicode normalization, and the walk continues under the entry's own spelling. Symlinks are never
(&mut self, relative: &Path)
| 51 | /// followed; the final component's own metadata is returned as-is (a |
| 52 | /// symlink reports itself). |
| 53 | pub fn exact_metadata(&mut self, relative: &Path) -> io::Result<Option<fs::Metadata>> { |
| 54 | let mut current = self.root.clone(); |
| 55 | for component in relative.components() { |
| 56 | let Component::Normal(name) = component else { |
| 57 | return Ok(None); |
| 58 | }; |
| 59 | let spelled = self |
| 60 | .listing(¤t)? |
| 61 | .and_then(|listing| listing.spelling_of(name)) |
| 62 | .map(OsStr::to_os_string); |
| 63 | let Some(spelled) = spelled else { |
| 64 | return Ok(None); |
| 65 | }; |
| 66 | current.push(spelled); |
| 67 | } |
| 68 | match fs::symlink_metadata(¤t) { |
| 69 | Ok(metadata) => Ok(Some(metadata)), |
| 70 | Err(error) if error.kind() == io::ErrorKind::NotFound => Ok(None), |
| 71 | Err(error) => Err(error), |
| 72 | } |
| 73 | } |
| 74 | |
| 75 | fn listing(&mut self, directory: &Path) -> io::Result<Option<&DirectoryListing>> { |
| 76 | let listing = match self.listings.entry(directory.to_path_buf()) { |