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

Method list_dir

core/src/agent_api/tests.rs:102–130  ·  view source on GitHub ↗
(
        &self,
        path: &crate::workspace::WorkspacePath,
    )

Source from the content-addressed store, hash-verified

100 }
101
102 async fn list_dir(
103 &self,
104 path: &crate::workspace::WorkspacePath,
105 ) -> crate::workspace::WorkspaceResult<Vec<crate::workspace::WorkspaceDirEntry>> {
106 let prefix = if path.is_root() {
107 String::new()
108 } else {
109 format!("{}/", path.as_str())
110 };
111 let files = self.files.read().unwrap();
112 let mut entries = Vec::new();
113
114 for (file_path, content) in files.iter() {
115 if !file_path.starts_with(&prefix) {
116 continue;
117 }
118 let remaining = &file_path[prefix.len()..];
119 if remaining.is_empty() || remaining.contains('/') {
120 continue;
121 }
122 entries.push(crate::workspace::WorkspaceDirEntry {
123 name: remaining.to_string(),
124 kind: crate::workspace::WorkspaceFileType::File,
125 size: content.len() as u64,
126 });
127 }
128
129 Ok(entries)
130 }
131}
132
133#[derive(Default)]

Callers

nothing calls this directly

Calls 4

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

Tested by

no test coverage detected