MCPcopy Create free account
hub / github.com/bytecodealliance/wasmtime / iterate_files

Function iterate_files

cranelift/src/utils.rs:28–48  ·  view source on GitHub ↗

Iterate over all of the files passed as arguments, recursively iterating through directories.

(files: &'a [PathBuf])

Source from the content-addressed store, hash-verified

26
27/// Iterate over all of the files passed as arguments, recursively iterating through directories.
28pub fn iterate_files<'a>(files: &'a [PathBuf]) -> impl Iterator<Item = PathBuf> + 'a {
29 files
30 .iter()
31 .flat_map(WalkDir::new)
32 .filter(|f| match f {
33 Ok(d) => {
34 // Filter out hidden files (starting with .).
35 !d.file_name().to_str().map_or(false, |s| s.starts_with('.'))
36 // Filter out directories.
37 && !d.file_type().is_dir()
38 }
39 Err(e) => {
40 println!("Unable to read file: {e}");
41 false
42 }
43 })
44 .map(|f| {
45 f.expect("this should not happen: we have already filtered out the errors")
46 .into_path()
47 })
48}

Callers 3

runFunction · 0.85
runFunction · 0.85
runFunction · 0.85

Calls 6

to_strMethod · 0.80
file_nameMethod · 0.80
is_dirMethod · 0.80
mapMethod · 0.45
iterMethod · 0.45
expectMethod · 0.45

Tested by

no test coverage detected