#
fs
File system access with restrictions & canonical resolution.
This one allows the use of "..", without breaching the workspace.
Environment Risks
For best security, we recommend you do not run this in a lua_State
that could compromise you by a bad actor.
#
Functions
fs.read(path: string): string
- Reads a file from a given path
fs.write(path: string, data: string)
- Writes to a file provided by the path
fs.isfile(path: string): boolean
- Checks if a filesystem object is a file
fs.isfolder(path: string): boolean
- Checks if a filesystem object is a folder
fs.listfiles(path: string): string[]
- Lists files in the specified path
fs.makefolder(path: string)
- Creates a folder in the specified path
- This is recursive, allowing it to generate multiple folders
fs.delfolder(path: string)
- Deletes a folder from the specified path
fs.delfile(path: string)
- Deletes a file from the specified path
fs.append(path: string, data: string)
- Appends data onto the specified file
fs.forward(path: string): string
- Changes all "\" separators to "/"
fs.backward(path: string): string
- Changes all "/" separators to "\"
fs.join(a: string, b: string): string
- Joins two paths together
fs.extname(path: string, replace?: string): string
- Gets the extension name of a path
- If provided a replacement, will return the replaced path's extension
fs.filename(path: string, replace?: string): string
- Gets the file name of a path
- If provided a replacement, will return the replaced path's file
fs.dirname(path: string, replace?: string): string
- Gets the directory name of a path
- If provided a replacement, will return the replaced path's directory
fs.sanitize(path: string): string
- Removes any oddities in the path, replacing them with "_" instead.