Collect all files in a directory tree with their relative paths
(dir: &Path, base: &Path)
| 20 | let compiled = patterns |
| 21 | .iter() |
| 22 | .map(|pattern| CompiledPathPattern::new(pattern)) |
| 23 | .collect(); |
| 24 | let mut active = PATH_EXCLUSIONS.write().expect("path exclusion lock"); |
| 25 | let previous = std::mem::replace(&mut *active, compiled); |
| 26 | PathExclusionGuard { previous } |
| 27 | } |
| 28 | |
| 29 | impl Drop for PathExclusionGuard { |
| 30 | fn drop(&mut self) { |
| 31 | *PATH_EXCLUSIONS.write().expect("path exclusion lock") = std::mem::take(&mut self.previous); |
| 32 | } |
| 33 | } |
| 34 | |
| 35 | /// Glob pattern with its `/`-segments split once at construction, so matching |
| 36 | /// many paths (or one path against many patterns) skips the per-call split. |
| 37 | #[derive(Clone, Debug)] |
| 38 | pub struct CompiledPathPattern { |
| 39 | segments: Box<[Box<str>]>, |
| 40 | } |