readDir
readDir(path): AsyncIterable<DirEntry>
Returns an AsyncIterable that yields DirEntry objects for each
entry within path, one at a time. The directory handle is automatically
closed when iteration completes or the loop is exited early.
Parameters
| Parameter | Type | Description |
|---|---|---|
path | PathLike | Path of the directory to read. |
Returns
AsyncIterable<DirEntry>
Examples
for await (const entry of Switch.readDir('sdmc:/')) {
console.log(entry.name, entry.isFile ? 'file' : 'dir');
}To collect all entries into an array:
const entries = await Array.fromAsync(Switch.readDir('sdmc:/'));