readfile
Reads and returns the full contents of a file.
function readfile(path: string): stringSynopsis
How it works
Reads the entire contents of a file from the executor’s sandboxed workspace directory. The path is relative to the workspace root. Internally uses the Win32 API sequence:
CreateFileA(path, GENERIC_READ, FILE_SHARE_READ,
NULL, OPEN_EXISTING, 0, NULL);
GetFileSize(handle, NULL);
ReadFile(handle, buffer, fileSize, &bytesRead, NULL);
CloseHandle(handle);
Returns the file content as a Lua string. Binary files (images, compressed data) are returned verbatim — Lua strings can contain any byte value including \0.Sandbox
All filesystem operations are confined to the executor’s workspace folder. The executor resolves the path relative to a fixed root directory and strips or rejects path traversal components (
.., absolute paths). This prevents scripts from reading arbitrary system files like C:\Windows\System32 or credential files.Usage
Read a config file
local data = readfile("config.json")
print(data)Parameters
path string Path to the file (relative to workspace).
Returns
string The file contents as a string.