MCPcopy Index your code
hub / github.com/AI45Lab/Code / list_dir

Method list_dir

core/src/tools/mod.rs:663–689  ·  view source on GitHub ↗
(&self, path: &WorkspacePath)

Source from the content-addressed store, hash-verified

661 }
662
663 async fn list_dir(&self, path: &WorkspacePath) -> WorkspaceResult<Vec<WorkspaceDirEntry>> {
664 let prefix = if path.is_root() {
665 String::new()
666 } else {
667 format!("{}/", path.as_str())
668 };
669 let files = self.files.read().unwrap();
670 let mut entries = Vec::new();
671 for name in files.keys() {
672 if !name.starts_with(&prefix) {
673 continue;
674 }
675 let remaining = &name[prefix.len()..];
676 if remaining.is_empty() || remaining.contains('/') {
677 continue;
678 }
679 entries.push(WorkspaceDirEntry {
680 name: remaining.to_string(),
681 kind: WorkspaceFileType::File,
682 size: files
683 .get(name)
684 .map(|content| content.len() as u64)
685 .unwrap_or(0),
686 });
687 }
688 Ok(entries)
689 }
690 }
691
692 struct MockCommandRunner;

Callers

nothing calls this directly

Calls 5

is_rootMethod · 0.80
containsMethod · 0.80
lenMethod · 0.45
is_emptyMethod · 0.45
getMethod · 0.45

Tested by

no test coverage detected