1use globwalk::{GlobWalkerBuilder, WalkError};
2use std::path::{Path, PathBuf};
3
4pub fn glob_err<P, S, E>(base: P, pattern: S, on_error: E) -> Vec<PathBuf>
5where
6 P: AsRef<Path>,
7 S: AsRef<str>,
8 E: Fn(WalkError) -> (),
9{
10 let walker = GlobWalkerBuilder::new(base, pattern)
11 .case_insensitive(true)
12 .sort_by(|a, b| a.path().cmp(b.path()))
13 .build()
14 .expect("Unable to build glob walker");
15
16 walker
17 .filter_map(|res| match res {
18 Ok(entry) => Some(entry.into_path()),
19 Err(e) => {
20 on_error(e);
21 None
22 }
23 })
24 .collect()
25}