Feature: Filter by invert_filter: reverse match

Mimic grep's -v option.

Allows dust to only match files that do not match the given filter
This commit is contained in:
andy.boot
2021-09-05 09:50:45 +01:00
parent 124c19b5c9
commit 9d2e6d2b36
6 changed files with 77 additions and 21 deletions
+7
View File
@@ -64,6 +64,13 @@ pub fn is_filtered_out_due_to_regex(filter_regex: &Option<Regex>, dir: &Path) ->
}
}
pub fn is_filtered_out_due_to_invert_regex(filter_regex: &Option<Regex>, dir: &Path) -> bool {
match filter_regex {
Some(fr) => fr.is_match(&dir.as_os_str().to_string_lossy()),
None => false,
}
}
fn is_a_parent_of<P: AsRef<Path>>(parent: P, child: P) -> bool {
let parent = parent.as_ref();
let child = child.as_ref();