| 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; |