zephyr.io
Sandboxed file storage. Paths are virtual, rooted at the module's persistent data directory (`ZEPHYR_DATA_DIR/modules/<module_id>`); absolute-looking paths are still scoped there and parent traversal is rejected. Reads and writes use raw Lua-string bytes. All functions require the `io` permission.
7 functions
write
zephyr.io.write(path, data)Write raw bytes to a file, creating or replacing it.
Parameters
pathstringVirtual module path.
datastringRaw bytes to write.
Returns
Nothing.
Raises an error if
- the
iopermission is not granted
Example
zephyr.io.write("/cache/song.mp3", bytes)read
zephyr.io.read(path)Read a file's contents as raw bytes.
Parameters
pathstringVirtual module path.
Returns
The file contents as a raw byte string.
Raises an error if
- the
iopermission is not granted
exists
zephyr.io.exists(path)Check whether a path exists.
Parameters
pathstringVirtual module path.
Returns
true if the path exists.
Raises an error if
- the
iopermission is not granted
delete
zephyr.io.delete(path)Delete a file or directory.
Parameters
pathstringVirtual module path.
Returns
Nothing.
Raises an error if
- the
iopermission is not granted
mkdir
zephyr.io.mkdir(path)Create a directory (and any missing parents).
Parameters
pathstringVirtual module path.
Returns
Nothing.
Raises an error if
- the
iopermission is not granted
Example
zephyr.io.mkdir("/cache")metadata
zephyr.io.metadata(path)Return metadata about a path.
Parameters
pathstringVirtual module path.
Returns
Metadata with path, kind (file/directory/other), and size (bytes, or nil for directories).
Raises an error if
- the
iopermission is not granted
list
zephyr.io.list(path?)List directory entries.
Parameters
pathstringoptionalVirtual module path. Defaults to the module root.
Returns
Entries with name, path, kind, and size.
Raises an error if
- the
iopermission is not granted