readfile Synchronous
readfileasync
Read a workspace file as a Luau string. Strings can hold arbitrary bytes, so the same call can load settings text or an image you plan to pass to another API.
Luau
readfile(path: string) -> stringParameters
| Parameter | Type | Description |
|---|---|---|
path | string | Workspace-relative file path. |
Returns
stringThe complete file contents as a string.
Usage notes
A missing file or invalid workspace path raises. Check isfile first when the file is optional.
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
Luau
local path = "settings.json"
if isfile(path) then
print("Saved settings:", readfile(path))
else
print("No saved settings yet")
end