backpak/filter.rs
1use anyhow::{Context, Result};
2use camino::Utf8Path;
3use regex::RegexSet;
4
5pub fn skip_matching_paths(skips: &[String]) -> Result<impl Fn(&Utf8Path) -> bool> {
6 let skipset = RegexSet::new(skips).context("Skip rules are not valid regex")?;
7
8 let filter = move |path: &Utf8Path| !skipset.is_match(path.as_str());
9 Ok(filter)
10}