This commit is contained in:
+5
-2
@@ -5,8 +5,11 @@ const cwd_directory_handle = new NodeFileSystemDirectoryHandle('.')
|
||||
const test_directory_handle = await cwd_directory_handle.getDirectoryHandle('test', { 'create': true })
|
||||
for (let i = 0; i < 10000; i++) {
|
||||
const file_handle = await test_directory_handle.getFileHandle(i+'.txt', { 'create': true })
|
||||
const writable = await file_handle.createWritable()
|
||||
await writable.write('Hello World!')
|
||||
let writable = await file_handle.createWritable()
|
||||
await writable.write(textText+textText)
|
||||
await writable.close()
|
||||
writable = await file_handle.createWritable()
|
||||
await writable.write(textText)
|
||||
await writable.close()
|
||||
const file = await file_handle.getFile()
|
||||
const text = await file.text()
|
||||
|
||||
@@ -14,8 +14,9 @@ export default class NodeFileSystemWritableFileStream extends WritableStream imp
|
||||
constructor(name: string, options: FileSystemCreateWritableOptions = {}) {
|
||||
name = path.normalize(name)
|
||||
let flags = 'w'
|
||||
if (!options.keepExistingData) flags = 'r+'
|
||||
if (options.keepExistingData) flags = 'r+'
|
||||
const fd = fs.openSync(name, flags)
|
||||
if (!options.keepExistingData) fs.ftruncateSync(fd, 0)
|
||||
super(Writable.toWeb(fs.createWriteStream(name, { "fd": fd })))
|
||||
this.#fd = fd
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user