File I/O
Sandboxed file operations restricted to the project directory. Relative paths resolve from the project root. Absolute paths must be inside the project directory.
Read File
Section titled “Read File”local content = pl.read_file("notes.txt")Returns the file contents as a string. Errors if the file doesn’t exist or exceeds 1 MB.
Write File
Section titled “Write File”pl.write_file("output/result.txt", "Hello from Lua!")Writes content to a file. Creates parent directories if needed. Max 1 MB.
Check Existence
Section titled “Check Existence”if pl.file_exists("config.json") then local cfg = pl.read_file("config.json")endList Directory
Section titled “List Directory”local entries = pl.list_dir(".")Returns an array of entries:
| Field | Type | Description |
|---|---|---|
name | string | File or directory name |
isDir | bool | true for directories |
Example
Section titled “Example”local entries = pl.list_dir(".")for _, e in ipairs(entries) do local kind = e.isDir and "[dir]" or "[file]" pl.log(kind .. " " .. e.name)endSecurity
Section titled “Security”- All paths are sandboxed to the project directory
- Path traversal (
../) is blocked after canonicalization - Maximum file size: 1 MB per read/write
- Symlinks that escape the project directory are rejected