Recursively search for a [`DirEntry`] with a particular path.
(&self, path: S)
| 38 | |
| 39 | /// Recursively search for a [`DirEntry`] with a particular path. |
| 40 | pub fn get_entry<S: AsRef<Path>>(&self, path: S) -> Option<&'a DirEntry<'a>> { |
| 41 | let path = path.as_ref(); |
| 42 | |
| 43 | for entry in self.entries() { |
| 44 | if entry.path() == path { |
| 45 | return Some(entry); |
| 46 | } |
| 47 | |
| 48 | if let DirEntry::Dir(d) = entry { |
| 49 | if let Some(nested) = d.get_entry(path) { |
| 50 | return Some(nested); |
| 51 | } |
| 52 | } |
| 53 | } |
| 54 | |
| 55 | None |
| 56 | } |
| 57 | |
| 58 | /// Look up a file by name. |
| 59 | pub fn get_file<S: AsRef<Path>>(&self, path: S) -> Option<&'a File<'a>> { |