MCPcopy Create free account
hub / github.com/atomicdotdev/atomic / walkdir

Function walkdir

atomic-cli/tests/it/shim_census_cb13a_test.rs:58–76  ·  view source on GitHub ↗
(dir: &Path)

Source from the content-addressed store, hash-verified

56}
57
58fn walkdir(dir: &Path) -> std::io::Result<Vec<(String, Vec<u8>)>> {
59 let mut out = Vec::new();
60 if dir.is_file() {
61 let relative = dir.to_string_lossy().into_owned();
62 out.push((relative, fs::read(dir).unwrap_or_default()));
63 return Ok(out);
64 }
65 for entry in fs::read_dir(dir)? {
66 let entry = entry?;
67 let path = entry.path();
68 if path.is_dir() {
69 out.extend(walkdir(&path)?);
70 } else {
71 let relative = path.to_string_lossy().into_owned();
72 out.push((relative, fs::read(&path).unwrap_or_default()));
73 }
74 }
75 Ok(out)
76}
77
78fn bytes_differ(before: &[(String, Vec<u8>)], after: &[(String, Vec<u8>)]) -> Vec<String> {
79 let mut differences = Vec::new();

Calls 6

is_dirMethod · 0.80
extendMethod · 0.80
readFunction · 0.70
is_fileMethod · 0.45
pushMethod · 0.45
pathMethod · 0.45

Tested by

no test coverage detected