Method Maps2
SymbolDescription
DirectoryListingA DirectoryListing iterates over the contents of a directory. To obtain a DirectoryListing handle, call OpenDirectory().
FileA File object can be obtained by calling OpenFile(). File objects should be closed with delete or Close(). Note that, "delete file" does not actually delete the file, it just closes the handle.
Enumerations4
SymbolDescription
FileOpResultResults reported by asynchronous filesystem operations.
FileTimeModeFile time modes.
FileTypeFile inode types.
PathTypePath types.
Type Definitions5
SymbolDescription
FileDirectoryCallbackCalled when an asynchronous directory snapshot has been materialized. On success, listing contains a fully-materialized DirectoryListing and must be closed by the callback. It is independent of later filesystem changes. On failure, listing is null.
FileExistsCallbackCalled when an asynchronous existence check completes.
FileOpCallbackCalled when an asynchronous filesystem operation completes.
FileReadCallbackCalled when an asynchronous whole-file read completes. contents contains the raw file bytes. It is binary-safe, including embedded NUL bytes, and its length is given by size. Do not use string-focused natives on it unless the data is known to be a string.
FileSizeCallbackCalled when an asynchronous file-size query completes.
Defines13
SymbolDescription
FPERM_G_EXECGroup can exec.
FPERM_G_READGroup can read.
FPERM_G_WRITEGroup can write.
FPERM_O_EXECAnyone can exec.
FPERM_O_READAnyone can read.
FPERM_O_WRITEAnyone can write.
FPERM_U_EXECUser can exec.
FPERM_U_READUser can read.
FPERM_U_WRITEUser can write.
PLATFORM_MAX_PATHMaximum path length.
SEEK_CURSeek from current position.
SEEK_ENDSeek from end position.
SEEK_SETSeek from start.
Functions40
SymbolDescription
BuildPathBuilds a path relative to the SourceMod folder. This should be used instead of directly referencing addons/sourcemod, in case users change the name of their folder layout.
CopyFileCopies a file. If the destination file already exists, it is overwritten.
CopyFileAsyncCopies a file without blocking the game thread. Existing destinations are overwritten.
CreateDirectoryCreates a directory.
CreateDirectoryAsyncCreates a directory without blocking the game thread.
DeleteFileDeletes a file.
DeleteFileAsyncDeletes a file without blocking the game thread.
DirExistsChecks if a directory exists.
DirExistsAsyncChecks for a directory without blocking the game thread.
FileExistsChecks if a file exists.
FileExistsAsyncChecks for a regular file without blocking the game thread.
FilePositionGet current position in the file.
FileSeekSets the file position indicator.
FileSizeGet the file size in bytes.
FileSizeAsyncGets a file's size without blocking the game thread.
FlushFileFlushes a file's buffered output; any buffered output is immediately written to the file.
GetFilePermissionsRetrieves a file or directories permissions.
GetFileTimeReturns a file timestamp as a unix timestamp.
IsEndOfFileTests if the end of file has been reached.
LogToOpenFileSame as LogToFile(), except uses an open file Handle. The file must be opened in text appending mode.
LogToOpenFileExSame as LogToFileEx(), except uses an open file Handle. The file must be opened in text appending mode.
OpenDirectoryOpens a directory/folder for contents enumeration.
OpenDirectoryAsyncEnumerates an OS filesystem directory without blocking the game thread. The callback receives a fully-materialized DirectoryListing snapshot.
OpenFileOpens or creates a file, returning a File handle on success. File handles should be closed with delete or CloseHandle(). The open mode may be one of the following strings: "r": Open an existing file for reading. "w": Create a file for writing, or truncate (delete the contents of) an existing file and then open it for writing. "wx": Create file for writing, fails if file already exists. "a": Create a file for writing, or open an existing file such that writes will be appended to the end. "r+": Open an existing file for both reading and writing. "w+": Create a file for reading and writing, or truncate an existing file and then open it for reading and writing. "a+": Create a file for both reading and writing, or open an existing file such that writes will be appended to the end. The open mode may also contain an additional character after "r", "w", or "a", but before the "+" sign. This character may be "b" (indicating binary mode) or "t" (indicating text mode). By default, "text" mode is implied. On Linux and Mac, this has no distinction from binary mode. On Windows, it causes the '\n' character (0xA) to be written as "\r\n" (0xD, 0xA). Example: "rb" opens a binary file for reading; "at" opens a text file for appending.
ReadDirEntryReads the current directory entry as a local filename, then moves to the next file.
ReadFileReads binary data from a file.
ReadFileAsyncReads a whole file without blocking the game thread.
ReadFileCellReads a single binary cell from a file.
ReadFileLineReads a line from a text file.
ReadFileStringReads a UTF8 or ANSI string from a file.
RemoveDirRemoves a directory.
RemoveDirectoryAsyncRemoves an empty OS filesystem directory without blocking the game thread.
RenameFileRenames a file.
RenameFileAsyncRenames a file without blocking the game thread.
SetFilePermissionsChanges a file or directories permissions.
WriteFileWrites binary data to a file.
WriteFileAsyncWrites size raw bytes from contents without blocking the game thread.
WriteFileCellWrites a single binary cell to a file.
WriteFileLineWrites a line of text to a text file. A newline is automatically appended.
WriteFileStringWrites a binary string to a file.