FileSystem¶
The FileSystem library provides function to manipulate files and directories.
Usage¶
Lua | |
---|---|
Functions¶
open¶
fs.open( path, mode )
Open a file handle.
Parameters¶
path
: string - Path of the file to open.mode
: string - How to open the file.
Returns¶
If mode
is "r"
:
If mode
is "w"
or "a"
:
If mode
is "rb"
:
If mode
is "wb"
or "ab"
:
list¶
fs.list( path )
Get an array containing files and directories in a path.
Parameters¶
path
: string - Path of the directory to list.
Returns¶
list
: string[] - List of files and directories.
Throws¶
- If the directory is not found.
combine¶
fs.combine( ...path )
Combine and resolves path segments together.
Parameters¶
...path
: string - Path segment.
Returns¶
path
: string - Combined path.
getName¶
fs.getName( path )
Get the name of the path.
Example¶
Parameters¶
path
: string - Path.
Returns¶
name
: string - Name of path.
getDir¶
fs.getDir( path )
get the name of the directory in path.
Parameters¶
path
: string - Path.
Returns¶
name
: string - Name of directory in path.
getSize¶
fs.getSize( path )
Get the file size in bytes.
Parameters¶
path
: string - Path.
Returns¶
size
: number - Size of file in bytes.
exists¶
fs.exists( path )
Check whether a path exists.
Parameters¶
path
: string - Path.
Returns¶
exists
: boolean - Whether it exists.
isReadOnly¶
fs.isReadOnly( path )
Check if a file or directory is read-only.
Parameters¶
path
: string - Path.
Returns¶
isReadOnly
: boolean - Whether it is read only.
makeDir¶
fs.makeDir( path )
Create a new directory.
Parameters¶
path
: string - Path.
move¶
fs.move( source, destination )
Move a file or directory from a source to a destination path.
Parameters¶
source
: string - Source path.destination
: string - Destination path.
copy¶
fs.copy( source, destination )
Copy a file from source to a destination path.
Parameters¶
source
: string - Source path.destination
: string - Destination path.
delete¶
fs.delete( path, [ recursive ] )
Delete a path. Enable recursive
to delete a directory with files.
Parameters¶
path
: string - Path to delete.recursive
: boolean - Delete path recursively.
attributes¶
fs.attributes( path )
Get attributes of a path.
Parameters¶
path
: string - Path.
Returns¶
attributes
: table - Table containing attributes of the path.size
: number - Size of file. 0 if directory.isDirectory
: boolean - Whether the path is a directory.isReadOnly
: boolean - Whether the path is read only.created
: integer - Timestamp of creation date of the path.modified
: integer - Timestamp of last modified date of the path.
isDir¶
fs.isDir( path )
Check whether a path is a directory
Parameters¶
path
: string - Path.
Returns¶
isDirectory
: boolean - Whether there is a directory in the path.
Created: March 11, 2023