Add read_dir_entries_recursive
in run_make_support
This commit is contained in:
parent
18d62008d4
commit
e2fd0c0f9a
1 changed files with 15 additions and 0 deletions
|
@ -84,3 +84,18 @@ pub fn has_suffix<P: AsRef<Path>>(path: P, suffix: &str) -> bool {
|
|||
pub fn filename_contains<P: AsRef<Path>>(path: P, needle: &str) -> bool {
|
||||
path.as_ref().file_name().is_some_and(|name| name.to_str().unwrap().contains(needle))
|
||||
}
|
||||
|
||||
/// Helper for reading entries in a given directory and its children.
|
||||
pub fn read_dir_entries_recursive<P: AsRef<Path>, F: FnMut(&Path)>(dir: P, mut callback: F) {
|
||||
fn read_dir_entries_recursive_inner<P: AsRef<Path>, F: FnMut(&Path)>(dir: P, callback: &mut F) {
|
||||
for entry in rfs::read_dir(dir) {
|
||||
let path = entry.unwrap().path();
|
||||
callback(&path);
|
||||
if path.is_dir() {
|
||||
read_dir_entries_recursive_inner(path, callback);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
read_dir_entries_recursive_inner(dir, &mut callback);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue