Library

fs

table

Sandboxed filesystem access scoped to the Madius workspace. Supports synchronous and asynchronous read, write, append, and directory enumeration.

Functions

10

#fs.create_file(path: string) → nil

since 1.4.2-alpha

Creates an empty file at path. Errors if the path already exists as a file or directory.

Aliasescreatefile

Parameters

pathstring

File path to create.

#fs.create_directory(path: string) → nil

since 1.4.2-alpha

Creates a directory (and any missing parents) at path. Errors if the path already exists as a file or directory.

Aliasescreatedirectory

Parameters

pathstring

Directory path to create.

#fs.write_async(path: string, data: buffer) → nil

yieldssince 1.4.2-alpha

Overwrites the file at path with the contents of data. The file must already exist. Yields until the write completes.

Aliaseswriteasync

Parameters

pathstring

File path relative to the Workspace directory.

databuffer

Data to write.

Errors

  • LuaError internal error -- VM engine context unavailable.

#fs.read_async(path: string) → buffer

yieldssince 1.4.2-alpha

Reads the entire contents of the file at path into a buffer. The file must exist and be smaller than the internal buffer size limit. Yields until the read completes.

Aliasesreadasync

Parameters

pathstring

File path relative to the Workspace directory.

Errors

  • LuaError internal error -- VM engine context unavailable.

#fs.append_async(path: string, data: buffer) → nil

yieldssince 1.4.2-alpha

Appends the contents of data to the end of the file at path. The file must already exist. Yields until the write completes.

Aliasesappendasync

Parameters

pathstring

File path relative to the Workspace directory.

databuffer

Data to append.

Errors

  • LuaError internal error -- VM engine context unavailable.

#fs.is_file(path: string) → boolean

since 1.4.2-alpha

Returns whether path points to an existing regular file.

Aliasesisfile

Parameters

pathstring

Path to check.

#fs.is_directory(path: string) → boolean

since 1.4.2-alpha

Returns whether path points to an existing directory.

Aliasesisdirectory

Parameters

pathstring

Path to check.

#fs.list_directories(directory: string) → { string }

since 1.4.2-alpha

Returns an array of paths for all subdirectories inside directory.

Aliaseslistdirectories

Parameters

directorystring

Directory path.

#fs.list_objects(directory: string) → { string }

since 1.4.2-alpha

Returns an array of paths for all entries (files and directories) inside directory.

Aliaseslistobjects

Parameters

directorystring

Directory path.

#fs.list_files(directory: string) → { string }

since 1.4.2-alpha

Returns an array of paths for all regular files inside directory.

Aliaseslistfiles

Parameters

directorystring

Directory path.