The file library provides functions for finding, reading and writing to files.
The following path values are most commonly used:
LUAsearches the lua files (in /lua/, in your gamemodes, in all the addons).
GAMEsearches all the mounted content (main folder, addons, mounted games etc).
MODsearches only the garrysmod folder.
DATAsearches in the data folder.
See File Search Paths for the descriptive list of path values.
For the full list of path values, type
path in the console.
Deletes a file or
empty folder that is relative to the data folder.
You can't remove any files outside of data folder.
Returns a boolean of whether the file or directory exists or not.
Returns a list of files and directories inside a single folder.
Returns whether the given file is a directory or not.
Attempts to open a file with the given mode.
Returns the content of a file.
Beware of casing -- some filesystems are case-sensitive. SRCDS on Linux seems to force file/directory creation to lowercase, but will not modify read operations.
Attempts to rename a file with the given name to another given name.
This function is constrained to the data/ folder.
Returns the file's size in bytes. If the file is not found, returns -1.
Returns when the file or folder was lasted modified in Unix time.