MCPcopy Index your code
hub / github.com/ColmapView/Colmapview.github.io / scanEntry

Function scanEntry

src/utils/fileScanning.ts:24–58  ·  view source on GitHub ↗
(
  entry: FileSystemEntry,
  path: string,
  files: Map<string, File>
)

Source from the content-addressed store, hash-verified

22 * Recursively scan drag/drop FileSystemEntry trees from webkitGetAsEntry().
23 */
24export async function scanEntry(
25 entry: FileSystemEntry,
26 path: string,
27 files: Map<string, File>
28): Promise<void> {
29 const fullPath = path ? `${path}/${entry.name}` : entry.name;
30
31 try {
32 if (isFileSystemFileEntry(entry)) {
33 const file = await new Promise<File>((resolve, reject) => {
34 entry.file(resolve, reject);
35 });
36 files.set(fullPath, file);
37 } else if (isFileSystemDirectoryEntry(entry)) {
38 const dirReader = entry.createReader();
39
40 let allEntries: FileSystemEntry[] = [];
41 let entries: FileSystemEntry[];
42
43 do {
44 entries = await new Promise<FileSystemEntry[]>((resolve, reject) => {
45 dirReader.readEntries(resolve, reject);
46 });
47 allEntries = allEntries.concat(entries);
48 } while (entries.length > 0);
49
50 for (let i = 0; i < allEntries.length; i += DIRECTORY_ENTRY_BATCH_SIZE) {
51 const batch = allEntries.slice(i, i + DIRECTORY_ENTRY_BATCH_SIZE);
52 await Promise.all(batch.map((childEntry) => scanEntry(childEntry, fullPath, files)));
53 }
54 }
55 } catch (err) {
56 appLogger.warn(`Failed to scan entry: ${fullPath}`, err);
57 }
58}
59
60/**
61 * Recursively scan File System Access API directory handles from showDirectoryPicker().

Callers 2

collectDroppedFilesFunction · 0.85

Calls 4

isFileSystemFileEntryFunction · 0.85
fileMethod · 0.80
createReaderMethod · 0.80

Tested by

no test coverage detected