+6
-1
@@ -16,7 +16,12 @@ for (let i = 0; i < 10000; i++) {
|
||||
const text = await file.text()
|
||||
if (text !== textText) throw new Error("failed to read back written data")
|
||||
}
|
||||
for await (const [name, handle] of test_directory_handle) { }
|
||||
for await (const [name, handle] of cwd_directory_handle) {
|
||||
console.log(`${name} is a ${handle.kind}`)
|
||||
if (handle.kind !== "directory" && handle.kind !== "file") {
|
||||
throw new Error("invalid handle kind")
|
||||
}
|
||||
}
|
||||
console.log("iterable pass")
|
||||
const result = await cwd_directory_handle.getFileHandle('test/test.txt').catch(error => 'blocked path traversal')
|
||||
if (typeof result === 'string') console.log(result)
|
||||
|
||||
@@ -16,6 +16,7 @@ export default class NodeFileSystemDirectoryHandle extends NodeFileSystemHandle
|
||||
declare kind: "directory";
|
||||
constructor(path: string, options: FileSystemGetDirectoryOptions & { origin?: NodeFileSystemDirectoryHandle } = {}) {
|
||||
super(path, options)
|
||||
this.kind="directory"
|
||||
try {
|
||||
const stats = fs.statSync(this.path)
|
||||
if (!stats.isDirectory()) throw new Error("tried to open file as directory: " + this.path)
|
||||
|
||||
@@ -17,6 +17,7 @@ export default class NodeFileSystemFileHandle extends NodeFileSystemHandle imple
|
||||
declare kind: "file";
|
||||
constructor(path: string, options: FileSystemGetFileOptions & { origin?: NodeFileSystemDirectoryHandle } = {}) {
|
||||
super(path,options)
|
||||
this.kind="file"
|
||||
let flags = fs.constants.O_RDWR
|
||||
if (options.create) flags |= fs.constants.O_CREAT
|
||||
fs.closeSync(fs.openSync(this.path, flags))
|
||||
|
||||
Reference in New Issue
Block a user