Visits all files in a directory tree, calling the provided callback for each file.
(dir: &Path, callback: &mut F)
| 2 | collections::HashSet, |
| 3 | fs, io, |
| 4 | path::{Path, PathBuf}, |
| 5 | sync::{LazyLock, RwLock}, |
| 6 | }; |
| 7 | |
| 8 | #[cfg(windows)] |
| 9 | use std::os::windows::fs::MetadataExt; |
| 10 | |
| 11 | static PATH_EXCLUSIONS: LazyLock<RwLock<Vec<CompiledPathPattern>>> = |
| 12 | LazyLock::new(|| RwLock::new(Vec::new())); |
| 13 | |
| 14 | #[must_use = "dropping the guard restores prior path exclusions"] |
| 15 | pub struct PathExclusionGuard { |
| 16 | previous: Vec<CompiledPathPattern>, |
| 17 | } |
| 18 | |
| 19 | pub fn push_path_exclusions(patterns: Vec<String>) -> PathExclusionGuard { |
| 20 | let compiled = patterns |
| 21 | .iter() |
| 22 | .map(|pattern| CompiledPathPattern::new(pattern)) |
no test coverage detected