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

Method list_dir

atomic-core/src/output/filesystem/walk.rs:22–36  ·  view source on GitHub ↗

List files in a directory. Returns a sorted list of entries as `(filename, is_directory)` tuples. # Errors Returns an error if the path is not a directory or cannot be read.

(&self, path: &str)

Source from the content-addressed store, hash-verified

20 ///
21 /// Returns an error if the path is not a directory or cannot be read.
22 pub fn list_dir(&self, path: &str) -> io::Result<Vec<(String, bool)>> {
23 let abs_path = self.resolve_path(path)?;
24 let mut entries = Vec::new();
25
26 for entry in fs::read_dir(&abs_path)? {
27 let entry = entry?;
28 let file_name = entry.file_name().to_string_lossy().to_string();
29 let file_type = entry.file_type()?;
30 entries.push((file_name, file_type.is_dir()));
31 }
32
33 // Sort for consistent ordering
34 entries.sort_by(|a, b| a.0.cmp(&b.0));
35 Ok(entries)
36 }
37
38 /// Walk the directory tree recursively.
39 ///

Callers 3

test_list_dirFunction · 0.80
test_list_dir_sortedFunction · 0.80
test_list_dir_not_foundFunction · 0.80

Calls 5

file_nameMethod · 0.80
is_dirMethod · 0.80
cmpMethod · 0.80
resolve_pathMethod · 0.45
pushMethod · 0.45

Tested by 3

test_list_dirFunction · 0.64
test_list_dir_sortedFunction · 0.64
test_list_dir_not_foundFunction · 0.64