readfile Synchronous
readfileasync
Read a workspace file and return its contents as a string. The file is read as bytes, so the same function works for saved text, images, and other binary data. Use it to load saved settings or inspect a local data file. When a file is optional, check isfile first; a missing file raises an error.
readfile(path: string) -> stringParameters
| Parameter | Type | Description |
|---|---|---|
path | string | Path inside the Kawaii workspace, for example settings/theme.json. |
Returns
stringThe complete file contents. An empty file produces an empty string; reading does not decode JSON, Base64, or an image format.
Usage notes
Paths are relative to the workspace. Missing or inaccessible files raise an error. File reads and writes enforce Kawaii’s path and file-type restrictions.
Differences from Volt
Volt documents access through explicitly created workspace symlinks. Kawaii rejects symlinks in workspace paths; all workspace operations remain subject to its path containment checks.
Example
writefile("greeting.txt", "Hello, Kawaii!")
local greeting = readfile("greeting.txt")
print(greeting)