file
You might be looking for the File class, which has the same name as this library.
The file library provides functions for finding, reading and writing to files.
The following path values are most commonly used:
LUA
searches the lua files (in /lua/, in your gamemodes, in all the addons).GAME
searches all the mounted content (main folder, addons, mounted games etc).MOD
searches only the garrysmod folder.DATA
searches 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.
Methods
Returns the content of a file asynchronously.
All limitations of file. Read also apply.
This function is currently broken in the Menu State and won't be fixed. Bug Report
Deletes a file or empty folder that is relative to the data folder. You can't remove any files outside of data folder.
You are able to delete any file in the Menu state.
Returns a boolean of whether the file or directory exists or not.
If you want to check for a directory, file. IsDir will be faster since it won't check for files.
Returns a list of files and directories inside a single folder.
It seems that paths with capital letters (e. g. lua/MyFolder/*) don't work as expected on Linux.
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 when the file or folder was last modified in Unix time.