file
Sandboxed filesystem access confined to the Conduit workspace directory.
file.read
Section titled “file.read”file.read(path: string) -> string?, string?
Reads the full contents of a file as a string, returning nil on failure to open, or nil plus an error message if the file exceeds the 64 MiB read limit.
local data = file.read("config.txt")file.write
Section titled “file.write”file.write(path: string, data: string) -> boolean
Overwrites (or creates) a file with the given binary-safe string data, creating parent directories as needed.
file.write("out.txt", "hello")file.append
Section titled “file.append”file.append(path: string, data: string) -> boolean
Appends binary-safe string data to the end of a file, creating it if it does not exist.
file.append("log.txt", "line\n")file.createfile
Section titled “file.createfile”file.createfile(path: string) -> boolean
Creates an empty file at the given path if it does not already exist, without truncating an existing one.
file.createfile("marker.txt")file.mkdir
Section titled “file.mkdir”file.mkdir(path: string) -> boolean
Creates a directory, including any missing parent directories.
file.mkdir("saves/profile1")file.isfile
Section titled “file.isfile”file.isfile(path: string) -> boolean
Returns true if the path exists and is a regular file.
if file.isfile("config.txt") then endfile.isdir
Section titled “file.isdir”file.isdir(path: string) -> boolean
Returns true if the path exists and is a directory.
if file.isdir("saves") then endfile.listdirs
Section titled “file.listdirs”file.listdirs(path: string) -> table<number, string>
Lists subdirectories directly inside the given directory, as paths relative to the workspace root.
for _, d in ipairs(file.listdirs(".")) do print(d) endfile.listobjects
Section titled “file.listobjects”file.listobjects(path: string) -> table<number, string>
Lists all entries (files and directories) directly inside the given directory, as paths relative to the workspace root.
for _, o in ipairs(file.listobjects(".")) do print(o) endfile.listfiles
Section titled “file.listfiles”file.listfiles(path: string) -> table<number, string>
Lists regular files directly inside the given directory, as paths relative to the workspace root.
for _, f in ipairs(file.listfiles(".")) do print(f) end