@vertz/desktop package provides a file system API for Vertz desktop apps running in the native webview. Every operation returns a Result<T, DesktopError> — errors are values, not exceptions.
Setup
Result error if called outside that environment.
Permissions
File system access requires permissions declared in.vertzrc:
| Capability | Methods |
|---|---|
fs:read | readTextFile, readBinaryFile, readBinaryStream, readDir, stat, exists |
fs:write | writeTextFile, writeBinaryFile, writeBinaryStream, createDir, remove, rename |
fs:all | All of the above |
Text files
Reading text
Writing text
Binary files
Binary file operations use HTTP transport instead of JSON IPC, avoiding the 33% overhead of base64 encoding.Reading binary data
Returns the entire file as aUint8Array. Files larger than 2 GiB return an error suggesting readBinaryStream().
Writing binary data
Writes aUint8Array to a file. The write is atomic — data is written to a temp file first, then renamed into place for crash safety. Parent directories are created automatically.
Streaming binary reads
For files larger than 2 GiB or when you want to process data incrementally, usereadBinaryStream(). Returns a ReadableStream<Uint8Array> — no size limit, data arrives chunk by chunk.
Streaming binary writes
Write data from aReadableStream<Uint8Array> to a file. No size limit — data flows chunk by chunk. The write is atomic (temp file + rename).
Directory operations
Check existence
File metadata
List directory
Create directory
Remove
Removes a file or directory. Directories are removed recursively.Rename / move
Timeouts
All operations accept an optionaltimeout (milliseconds):
Error codes
| Code | Meaning |
|---|---|
NOT_FOUND | File or directory does not exist |
PERMISSION_DENIED | OS-level permission denied, or IPC method not allowed |
IO_ERROR | General I/O failure |
TIMEOUT | Operation exceeded the specified timeout |
EXECUTION_FAILED | Not running in the native webview |
Buffered vs streaming — when to use which
Buffered (readBinaryFile / writeBinaryFile) | Streaming (readBinaryStream / writeBinaryStream) | |
|---|---|---|
| Size limit | 2 GiB | No limit |
| Memory | Entire file in memory | Chunk by chunk |
| API | Uint8Array | ReadableStream<Uint8Array> |
| Best for | Images, config, small assets | Video, database dumps, large exports |