Skip to content

Commit cbfcd76

Browse files
Corrects read only example for open function (#3158)
1 parent 30461b4 commit cbfcd76

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

src/content/docs/plugin/file-system.mdx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -256,7 +256,9 @@ Always call `file.close()` when you are done manipulating the file.
256256
read: true,
257257
baseDir: BaseDirectory.AppData,
258258
});
259-
const buf = new Uint8Array();
259+
260+
const stat = await file.stat();
261+
const buf = new Uint8Array(stat.size);
260262
await file.read(buf);
261263
const textContents = new TextDecoder().decode(buf);
262264
await file.close();

0 commit comments

Comments
 (0)