This commit is contained in:
@@ -24,30 +24,32 @@ export default class NodeFileSystemDirectoryHandle extends NodeFileSystemHandle
|
||||
else throw error
|
||||
}
|
||||
}
|
||||
entries(): FileSystemDirectoryHandleAsyncIterator<[string, NodeFileSystemDirectoryHandle | NodeFileSystemFileHandle]> {
|
||||
const entries: Array<[string, NodeFileSystemDirectoryHandle | NodeFileSystemFileHandle]> = []
|
||||
fs.readdirSync(this.path).forEach(name => {
|
||||
if (fs.lstatSync(name).isDirectory()) {
|
||||
entries.push([name, new NodeFileSystemDirectoryHandle(Path.join(this.path, name), { origin: this.origin || this })])
|
||||
async* entries(): FileSystemDirectoryHandleAsyncIterator<[string, NodeFileSystemDirectoryHandle | NodeFileSystemFileHandle]> {
|
||||
for (const name of await asyncfs.readdir(this.path)) {
|
||||
const entryPath = Path.join(this.path, name)
|
||||
const stat = await asyncfs.lstat(entryPath)
|
||||
if (stat.isDirectory()) {
|
||||
yield [name, new NodeFileSystemDirectoryHandle(entryPath, { origin: this.origin || this })]
|
||||
} else {
|
||||
entries.push([name, new NodeFileSystemFileHandle(Path.join(this.path, name), { origin: this.origin || this })])
|
||||
yield [name, new NodeFileSystemFileHandle(entryPath, { origin: this.origin || this })]
|
||||
}
|
||||
})
|
||||
return entries[Symbol.asyncIterator]
|
||||
}
|
||||
}
|
||||
keys(): FileSystemDirectoryHandleAsyncIterator<string> {
|
||||
return fs.readdirSync(this.path)[Symbol.asyncIterator]
|
||||
async* keys(): FileSystemDirectoryHandleAsyncIterator<string> {
|
||||
for (const name of await asyncfs.readdir(this.path)) {
|
||||
yield name
|
||||
}
|
||||
}
|
||||
values(): FileSystemDirectoryHandleAsyncIterator<NodeFileSystemDirectoryHandle | NodeFileSystemFileHandle> {
|
||||
const values: Array<NodeFileSystemDirectoryHandle | NodeFileSystemFileHandle> = [];
|
||||
fs.readdirSync(this.path).forEach(name => {
|
||||
if (fs.lstatSync(name).isDirectory()) {
|
||||
values.push(new NodeFileSystemDirectoryHandle(Path.join(this.path, name), { origin: this.origin || this }))
|
||||
async* values(): FileSystemDirectoryHandleAsyncIterator<NodeFileSystemDirectoryHandle | NodeFileSystemFileHandle> {
|
||||
for (const name of await asyncfs.readdir(this.path)) {
|
||||
const entryPath = Path.join(this.path, name)
|
||||
const stat = await asyncfs.lstat(entryPath)
|
||||
if (stat.isDirectory()) {
|
||||
yield new NodeFileSystemDirectoryHandle(entryPath, { origin: this.origin || this })
|
||||
} else {
|
||||
values.push(new NodeFileSystemFileHandle(Path.join(this.path, name), { origin: this.origin || this }))
|
||||
yield new NodeFileSystemFileHandle(entryPath, { origin: this.origin || this })
|
||||
}
|
||||
})
|
||||
return values[Symbol.asyncIterator]
|
||||
}
|
||||
}
|
||||
#getValidatedPath(name: string) {
|
||||
name = Path.normalize(name)
|
||||
|
||||
Reference in New Issue
Block a user