diff --git a/lib/wasi-virt.js b/lib/wasi-virt.js index a4814f0..c716119 100644 --- a/lib/wasi-virt.js +++ b/lib/wasi-virt.js @@ -300,6 +300,19 @@ class Descriptor { return new WriteStream(this.entry, offset); } + setSize(size) { + if (this.entry instanceof Directory) + throw 'is-directory'; + size = Number(size); + if (size > this.entry.data.length) { + const newData = new Uint8Array(size); + newData.set(this.entry.data); + this.entry.data = newData; + } else if (size < this.entry.data.length) { + this.entry.data = this.entry.data.subarray(0, size); + } + } + readDirectory() { return new DirectoryEntryStream(this.entry); }