Closed NotASingleSingelton closed 2 years ago
You can do this, but note that it won't work on browsers that don't support the File System Access API. Here's a snippet:
const blobs = await directoryOpen({ recursive:true });
const processed = [];
blobs.forEach(async (blob) => {
if (!blob.directoryHandle) {
return;
}
if (processed.includes(blob.directoryHandle)) {
return;
}
processed.push(blob.directoryHandle);
for await (const entry of blob.directoryHandle.values()) {
if (entry.kind === 'directory') {
console.log(entry.kind, entry.name);
}
}
});
You can see this in action at https://wary-kaput-cupboard.glitch.me/ (click the Open Directory button and check the console. This lists empty folders. You can keep track of the nesting if you're interested.
Hello,
currently there is an issue with directoryOpen and the returning FileWithDirectoryAndFileHandle[] which does not contain information about empty folders which I would require for a projection of the whole tree structure.
Is there an way which I don't see? Would it be possible to make this possible like adding a array which represents the tree structure or something?