( dirHandle: FileSystemDirectoryHandle, path: string, files: Map<string, File> )
| 61 | * Recursively scan File System Access API directory handles from showDirectoryPicker(). |
| 62 | */ |
| 63 | export async function scanDirectoryHandle( |
| 64 | dirHandle: FileSystemDirectoryHandle, |
| 65 | path: string, |
| 66 | files: Map<string, File> |
| 67 | ): Promise<void> { |
| 68 | try { |
| 69 | for await (const entry of dirHandle.values()) { |
| 70 | const fullPath = path ? `${path}/${entry.name}` : entry.name; |
| 71 | if (isFileSystemFileHandle(entry)) { |
| 72 | const file = await entry.getFile(); |
| 73 | files.set(fullPath, file); |
| 74 | } else if (isFileSystemDirectoryHandle(entry)) { |
| 75 | await scanDirectoryHandle(entry, fullPath, files); |
| 76 | } |
| 77 | } |
| 78 | } catch (err) { |
| 79 | appLogger.warn(`Failed to scan directory: ${path}`, err); |
| 80 | } |
| 81 | } |
no test coverage detected