Update spcomp and includes to latest 1.10-fork
disable warning 241: Array-based enum structs will be removed in 1.11
This commit is contained in:
Vendored
+201
-191
@@ -9,7 +9,7 @@
|
||||
* This program is free software; you can redistribute it and/or modify it under
|
||||
* the terms of the GNU General Public License, version 3.0, as published by the
|
||||
* Free Software Foundation.
|
||||
*
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
|
||||
@@ -39,13 +39,13 @@
|
||||
* @global All paths in SourceMod natives are relative to the mod folder
|
||||
* unless otherwise noted.
|
||||
*
|
||||
* Most functions in SourceMod (at least, ones that deal with direct
|
||||
* Most functions in SourceMod (at least, ones that deal with direct
|
||||
* file manipulation) will support an alternate path specification.
|
||||
*
|
||||
* If the path starts with the string "file://" and the PathType is
|
||||
* not relative, then the "file://" portion is stripped off, and the
|
||||
* rest of the path is used without any modification (except for
|
||||
* correcting slashes). This can be used to override the path
|
||||
* If the path starts with the string "file://" and the PathType is
|
||||
* not relative, then the "file://" portion is stripped off, and the
|
||||
* rest of the path is used without any modification (except for
|
||||
* correcting slashes). This can be used to override the path
|
||||
* builder to supply alternate absolute paths. Examples:
|
||||
*
|
||||
* file://C:/Temp/file.txt
|
||||
@@ -57,9 +57,9 @@
|
||||
*/
|
||||
enum FileType
|
||||
{
|
||||
FileType_Unknown = 0, /* Unknown file type (device/socket) */
|
||||
FileType_Directory = 1, /* File is a directory */
|
||||
FileType_File = 2, /* File is a file */
|
||||
FileType_Unknown = 0, /* Unknown file type (device/socket) */
|
||||
FileType_Directory = 1, /* File is a directory */
|
||||
FileType_File = 2 /* File is a file */
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -67,23 +67,23 @@ enum FileType
|
||||
*/
|
||||
enum FileTimeMode
|
||||
{
|
||||
FileTime_LastAccess = 0, /* Last access (does not work on FAT) */
|
||||
FileTime_Created = 1, /* Creation (does not work on FAT) */
|
||||
FileTime_LastChange = 2, /* Last modification */
|
||||
FileTime_LastAccess = 0, /* Last access (does not work on FAT) */
|
||||
FileTime_Created = 1, /* Creation (does not work on FAT) */
|
||||
FileTime_LastChange = 2 /* Last modification */
|
||||
};
|
||||
|
||||
#define PLATFORM_MAX_PATH 256 /**< Maximum path length. */
|
||||
#define PLATFORM_MAX_PATH 256 /**< Maximum path length. */
|
||||
|
||||
#define SEEK_SET 0 /**< Seek from start. */
|
||||
#define SEEK_CUR 1 /**< Seek from current position. */
|
||||
#define SEEK_END 2 /**< Seek from end position. */
|
||||
#define SEEK_SET 0 /**< Seek from start. */
|
||||
#define SEEK_CUR 1 /**< Seek from current position. */
|
||||
#define SEEK_END 2 /**< Seek from end position. */
|
||||
|
||||
/**
|
||||
* Path types.
|
||||
*/
|
||||
enum PathType
|
||||
{
|
||||
Path_SM, /**< SourceMod root folder */
|
||||
Path_SM, /**< SourceMod root folder */
|
||||
};
|
||||
|
||||
// A DirectoryListing iterates over the contents of a directory. To obtain a
|
||||
@@ -92,9 +92,9 @@ methodmap DirectoryListing < Handle
|
||||
{
|
||||
// Reads the current directory entry as a local filename, then moves to the
|
||||
// next file.
|
||||
//
|
||||
//
|
||||
// Note: Both the '.' and '..' automatic directory entries will be retrieved.
|
||||
//
|
||||
//
|
||||
// @param buffer String buffer to hold directory name.
|
||||
// @param maxlength Maximum size of string buffer.
|
||||
// @param type Optional variable to store the file type.
|
||||
@@ -104,24 +104,24 @@ methodmap DirectoryListing < Handle
|
||||
|
||||
// A File object can be obtained by calling OpenFile(). File objects should be
|
||||
// closed with delete or Close(). Note that, "delete file" does not
|
||||
// actually a file, it just closes it.
|
||||
// actually delete the file, it just closes the handle.
|
||||
methodmap File < Handle
|
||||
{
|
||||
// Close the file handle. This is the same as using CloseHandle) or delete.
|
||||
// Close the file handle. This is the same as using CloseHandle() or delete.
|
||||
public void Close() {
|
||||
CloseHandle(this);
|
||||
}
|
||||
|
||||
// Reads a line of text from a file.
|
||||
//
|
||||
//
|
||||
// @param buffer String buffer to hold the line.
|
||||
// @param maxlength Maximum size of string buffer.
|
||||
// @param maxlength Maximum size of string buffer.
|
||||
// @return True on success, false otherwise.
|
||||
public native bool ReadLine(char[] buffer, int maxlength);
|
||||
|
||||
// Reads binary data from a file.
|
||||
//
|
||||
// @param items Array to store each item read.
|
||||
//
|
||||
// @param items Array to store each item read.
|
||||
// @param num_items Number of items to read into the array.
|
||||
// @param size Size of each element, in bytes, to be read.
|
||||
// Valid sizes are 1, 2, or 4.
|
||||
@@ -129,40 +129,40 @@ methodmap File < Handle
|
||||
public native int Read(int[] items, int num_items, int size);
|
||||
|
||||
// Reads a UTF8 or ANSI string from a file.
|
||||
//
|
||||
//
|
||||
// @param buffer Buffer to store the string.
|
||||
// @param max_size Maximum size of the string buffer.
|
||||
// @param read_count If -1, reads until a null terminator is encountered in
|
||||
// the file. Otherwise, read_count bytes are read
|
||||
// into the buffer provided. In this case the buffer
|
||||
// is not explicitly null terminated, and the buffer
|
||||
// @param read_count If -1, reads until a null terminator is encountered in
|
||||
// the file. Otherwise, read_count bytes are read
|
||||
// into the buffer provided. In this case the buffer
|
||||
// is not explicitly null terminated, and the buffer
|
||||
// will contain any null terminators read from the file.
|
||||
// @return Number of characters written to the buffer, or -1
|
||||
// @return Number of characters written to the buffer, or -1
|
||||
// if an error was encountered.
|
||||
// @error read_count > max_size.
|
||||
public native int ReadString(char[] buffer, int max_size, int read_count=-1);
|
||||
|
||||
// Writes binary data to a file.
|
||||
//
|
||||
// @param items Array of items to write. The data is read directly.
|
||||
// That is, in 1 or 2-byte mode, the lower byte(s) in
|
||||
// each cell are used directly, rather than performing
|
||||
// @param items Array of items to write. The data is read directly.
|
||||
// That is, in 1 or 2-byte mode, the lower byte(s) in
|
||||
// each cell are used directly, rather than performing
|
||||
// any casts from a 4-byte number to a smaller number.
|
||||
// @param num_items Number of items in the array.
|
||||
// @param size Size of each item in the array in bytes.
|
||||
// @param size Size of each item in the array in bytes.
|
||||
// Valid sizes are 1, 2, or 4.
|
||||
// @return True on success, false on error.
|
||||
public native bool Write(const int[] items, int num_items, int size);
|
||||
|
||||
// Writes a binary string to a file.
|
||||
//
|
||||
//
|
||||
// @param buffer String to write.
|
||||
// @param term True to append NUL terminator, false otherwise.
|
||||
// @return True on success, false on error.
|
||||
public native bool WriteString(const char[] buffer, bool term);
|
||||
|
||||
// Writes a line of text to a text file. A newline is automatically appended.
|
||||
//
|
||||
//
|
||||
// @param hndl Handle to the file.
|
||||
// @param format Formatting rules.
|
||||
// @param ... Variable number of format parameters.
|
||||
@@ -222,7 +222,7 @@ methodmap File < Handle
|
||||
public native bool WriteInt32(int data);
|
||||
|
||||
// Tests if the end of file has been reached.
|
||||
//
|
||||
//
|
||||
// @return True if end of file has been reached, false otherwise.
|
||||
public native bool EndOfFile();
|
||||
|
||||
@@ -233,6 +233,13 @@ methodmap File < Handle
|
||||
// @return True on success, false otherwise.
|
||||
public native bool Seek(int position, int where);
|
||||
|
||||
// Flushes a file's buffered output; any buffered output
|
||||
// is immediately written to the file.
|
||||
//
|
||||
// @return True on success or use_valve_fs specified with OpenFile,
|
||||
// otherwise false on failure.
|
||||
public native bool Flush();
|
||||
|
||||
// Get the current position in the file; returns -1 on failure.
|
||||
property int Position {
|
||||
public native get();
|
||||
@@ -240,16 +247,16 @@ methodmap File < Handle
|
||||
}
|
||||
|
||||
/**
|
||||
* Builds 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
|
||||
* Builds 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.
|
||||
*
|
||||
* @param type Type of path to build as the base.
|
||||
* @param buffer Buffer to store the path.
|
||||
* @param maxlength Maximum length of buffer.
|
||||
* @param fmt Format string.
|
||||
* @param ... Format arguments.
|
||||
* @return Number of bytes written to buffer (not including null terminator).
|
||||
* @param type Type of path to build as the base.
|
||||
* @param buffer Buffer to store the path.
|
||||
* @param maxlength Maximum length of buffer.
|
||||
* @param fmt Format string.
|
||||
* @param ... Format arguments.
|
||||
* @return Number of bytes written to buffer (not including null terminator).
|
||||
*/
|
||||
native int BuildPath(PathType type, char[] buffer, int maxlength, const char[] fmt, any ...);
|
||||
|
||||
@@ -260,13 +267,13 @@ native int BuildPath(PathType type, char[] buffer, int maxlength, const char[] f
|
||||
* @note Directories Handles can be cloned.
|
||||
* @note OpenDirectory() supports the "file://" notation.
|
||||
*
|
||||
* @param path Path to open.
|
||||
* @param path Path to open.
|
||||
* @param use_valve_fs If true, the Valve file system will be used instead.
|
||||
* This can be used to find files existing in any of
|
||||
* the Valve search paths, rather than solely files
|
||||
* existing directly in the gamedir.
|
||||
* @param valve_path_id If use_valve_fs, a search path from gameinfo or NULL_STRING for all search paths.
|
||||
* @return A Handle to the directory, null on error.
|
||||
* @param valve_path_id If use_valve_fs, a search path from gameinfo or NULL_STRING for all search paths.
|
||||
* @return A Handle to the directory, null on error.
|
||||
*/
|
||||
native DirectoryListing OpenDirectory(const char[] path, bool use_valve_fs=false, const char[] valve_path_id="GAME");
|
||||
|
||||
@@ -275,13 +282,13 @@ native DirectoryListing OpenDirectory(const char[] path, bool use_valve_fs=false
|
||||
*
|
||||
* @note Contents of buffers are undefined when returning false.
|
||||
* @note Both the '.' and '..' automatic directory entries will be retrieved for Windows and Linux.
|
||||
*
|
||||
* @param dir Handle to a directory.
|
||||
* @param buffer String buffer to hold directory name.
|
||||
* @param maxlength Maximum size of string buffer.
|
||||
* @param type Optional variable to store the file type.
|
||||
* @return True on success, false if there are no more files to read.
|
||||
* @error Invalid or corrupt Handle.
|
||||
*
|
||||
* @param dir Handle to a directory.
|
||||
* @param buffer String buffer to hold directory name.
|
||||
* @param maxlength Maximum size of string buffer.
|
||||
* @param type Optional variable to store the file type.
|
||||
* @return True on success, false if there are no more files to read.
|
||||
* @error Invalid or corrupt Handle.
|
||||
*/
|
||||
native bool ReadDirEntry(Handle dir, char[] buffer, int maxlength, FileType &type=FileType_Unknown);
|
||||
|
||||
@@ -310,227 +317,229 @@ native bool ReadDirEntry(Handle dir, char[] buffer, int maxlength, FileType &typ
|
||||
* Example: "rb" opens a binary file for writing; "at" opens a text file for
|
||||
* appending.
|
||||
*
|
||||
* @param file File to open.
|
||||
* @param mode Open mode.
|
||||
* @param file File to open.
|
||||
* @param mode Open mode.
|
||||
* @param use_valve_fs If true, the Valve file system will be used instead.
|
||||
* This can be used to find files existing in valve
|
||||
* search paths, rather than solely files existing directly
|
||||
* in the gamedir.
|
||||
* @param valve_path_id If use_valve_fs, a search path from gameinfo or NULL_STRING for all search paths.
|
||||
* @return A File handle, or null if the file could not be opened.
|
||||
* search paths, rather than solely files existing directly
|
||||
* in the gamedir.
|
||||
* @param valve_path_id If use_valve_fs, a search path from gameinfo or NULL_STRING for all search paths.
|
||||
* @return A File handle, or null if the file could not be opened.
|
||||
*/
|
||||
native File OpenFile(const char[] file, const char[] mode, bool use_valve_fs=false, const char[] valve_path_id="GAME");
|
||||
|
||||
/**
|
||||
* Deletes a file.
|
||||
*
|
||||
* @param path Path of the file to delete.
|
||||
* @param path Path of the file to delete.
|
||||
* @param use_valve_fs If true, the Valve file system will be used instead.
|
||||
* This can be used to delete files existing in the Valve
|
||||
* search path, rather than solely files existing directly
|
||||
* in the gamedir.
|
||||
* @param valve_path_id If use_valve_fs, a search path from gameinfo or NULL_STRING for all search paths.
|
||||
* @return True on success, false on failure or if file not immediately removed.
|
||||
* in the gamedir.
|
||||
* @param valve_path_id If use_valve_fs, a search path from gameinfo or NULL_STRING for all search paths.
|
||||
* @return True on success, false on failure or if file not immediately removed.
|
||||
*/
|
||||
native bool DeleteFile(const char[] path, bool use_valve_fs=false, const char[] valve_path_id="DEFAULT_WRITE_PATH");
|
||||
|
||||
/**
|
||||
* Reads a line from a text file.
|
||||
*
|
||||
* @param hndl Handle to the file.
|
||||
* @param buffer String buffer to hold the line.
|
||||
* @param maxlength Maximum size of string buffer.
|
||||
* @return True on success, false otherwise.
|
||||
* @param hndl Handle to the file.
|
||||
* @param buffer String buffer to hold the line.
|
||||
* @param maxlength Maximum size of string buffer.
|
||||
* @return True on success, false otherwise.
|
||||
*/
|
||||
native bool ReadFileLine(Handle hndl, char[] buffer, int maxlength);
|
||||
|
||||
/**
|
||||
* Reads binary data from a file.
|
||||
*
|
||||
* @param hndl Handle to the file.
|
||||
* @param items Array to store each item read.
|
||||
* @param num_items Number of items to read into the array.
|
||||
* @param size Size of each element, in bytes, to be read.
|
||||
* Valid sizes are 1, 2, or 4.
|
||||
* @return Number of elements read, or -1 on error.
|
||||
* @param hndl Handle to the file.
|
||||
* @param items Array to store each item read.
|
||||
* @param num_items Number of items to read into the array.
|
||||
* @param size Size of each element, in bytes, to be read.
|
||||
* Valid sizes are 1, 2, or 4.
|
||||
* @return Number of elements read, or -1 on error.
|
||||
*/
|
||||
native int ReadFile(Handle hndl, int[] items, int num_items, int size);
|
||||
|
||||
/**
|
||||
* Reads a UTF8 or ANSI string from a file.
|
||||
*
|
||||
* @param hndl Handle to the file.
|
||||
* @param buffer Buffer to store the string.
|
||||
* @param max_size Maximum size of the string buffer.
|
||||
* @param read_count If -1, reads until a null terminator is encountered in
|
||||
* the file. Otherwise, read_count bytes are read
|
||||
* into the buffer provided. In this case the buffer
|
||||
* is not explicitly null terminated, and the buffer
|
||||
* will contain any null terminators read from the file.
|
||||
* @return Number of characters written to the buffer, or -1
|
||||
* if an error was encountered.
|
||||
* @error Invalid Handle, or read_count > max_size.
|
||||
* @param hndl Handle to the file.
|
||||
* @param buffer Buffer to store the string.
|
||||
* @param max_size Maximum size of the string buffer.
|
||||
* @param read_count If -1, reads until a null terminator is encountered in
|
||||
* the file. Otherwise, read_count bytes are read
|
||||
* into the buffer provided. In this case the buffer
|
||||
* is not explicitly null terminated, and the buffer
|
||||
* will contain any null terminators read from the file.
|
||||
* @return Number of characters written to the buffer, or -1
|
||||
* if an error was encountered.
|
||||
* @error Invalid Handle, or read_count > max_size.
|
||||
*/
|
||||
native int ReadFileString(Handle hndl, char[] buffer, int max_size, int read_count=-1);
|
||||
|
||||
/**
|
||||
* Writes binary data to a file.
|
||||
*
|
||||
* @param hndl Handle to the file.
|
||||
* @param items Array of items to write. The data is read directly.
|
||||
* That is, in 1 or 2-byte mode, the lower byte(s) in
|
||||
* each cell are used directly, rather than performing
|
||||
* any casts from a 4-byte number to a smaller number.
|
||||
* @param num_items Number of items in the array.
|
||||
* @param size Size of each item in the array in bytes.
|
||||
* Valid sizes are 1, 2, or 4.
|
||||
* @return True on success, false on error.
|
||||
* @error Invalid Handle.
|
||||
* @param hndl Handle to the file.
|
||||
* @param items Array of items to write. The data is read directly.
|
||||
* That is, in 1 or 2-byte mode, the lower byte(s) in
|
||||
* each cell are used directly, rather than performing
|
||||
* any casts from a 4-byte number to a smaller number.
|
||||
* @param num_items Number of items in the array.
|
||||
* @param size Size of each item in the array in bytes.
|
||||
* Valid sizes are 1, 2, or 4.
|
||||
* @return True on success, false on error.
|
||||
* @error Invalid Handle.
|
||||
*/
|
||||
native bool WriteFile(Handle hndl, const int[] items, int num_items, int size);
|
||||
|
||||
/**
|
||||
* Writes a binary string to a file.
|
||||
*
|
||||
* @param hndl Handle to the file.
|
||||
* @param buffer String to write.
|
||||
* @param term True to append NUL terminator, false otherwise.
|
||||
* @return True on success, false on error.
|
||||
* @error Invalid Handle.
|
||||
* @param hndl Handle to the file.
|
||||
* @param buffer String to write.
|
||||
* @param term True to append NUL terminator, false otherwise.
|
||||
* @return True on success, false on error.
|
||||
* @error Invalid Handle.
|
||||
*/
|
||||
native bool WriteFileString(Handle hndl, const char[] buffer, bool term);
|
||||
|
||||
/**
|
||||
* Writes a line of text to a text file. A newline is automatically appended.
|
||||
*
|
||||
* @param hndl Handle to the file.
|
||||
* @param format Formatting rules.
|
||||
* @param ... Variable number of format parameters.
|
||||
* @return True on success, false otherwise.
|
||||
* @error Invalid Handle.
|
||||
* @param hndl Handle to the file.
|
||||
* @param format Formatting rules.
|
||||
* @param ... Variable number of format parameters.
|
||||
* @return True on success, false otherwise.
|
||||
* @error Invalid Handle.
|
||||
*/
|
||||
native bool WriteFileLine(Handle hndl, const char[] format, any ...);
|
||||
|
||||
/**
|
||||
* Reads a single binary cell from a file.
|
||||
*
|
||||
* @param hndl Handle to the file.
|
||||
* @param data Variable to store the data read.
|
||||
* @param size Size of the data to read in bytes. Valid
|
||||
* sizes are 1, 2, or 4 bytes.
|
||||
* @return Number of elements read (max 1), or -1 on error.
|
||||
* @error Invalid Handle.
|
||||
* @param hndl Handle to the file.
|
||||
* @param data Variable to store the data read.
|
||||
* @param size Size of the data to read in bytes. Valid
|
||||
* sizes are 1, 2, or 4 bytes.
|
||||
* @return Number of elements read (max 1), or -1 on error.
|
||||
* @error Invalid Handle.
|
||||
*/
|
||||
stock int ReadFileCell(Handle hndl, int &data, int size)
|
||||
{
|
||||
int ret;
|
||||
int array[1];
|
||||
|
||||
|
||||
if ((ret = ReadFile(hndl, array, 1, size)) == 1)
|
||||
{
|
||||
data = array[0];
|
||||
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
/**
|
||||
* Writes a single binary cell to a file.
|
||||
*
|
||||
* @param hndl Handle to the file.
|
||||
* @param data Cell to write to the file.
|
||||
* @param size Size of the data to read in bytes. Valid
|
||||
* sizes are 1, 2, or 4 bytes. If the size
|
||||
* is less than 4 bytes, the data is truncated
|
||||
* rather than casted. That is, only the lower
|
||||
* bits will be read.
|
||||
* @return True on success, false on error.
|
||||
* @error Invalid Handle.
|
||||
* @param hndl Handle to the file.
|
||||
* @param data Cell to write to the file.
|
||||
* @param size Size of the data to read in bytes. Valid
|
||||
* sizes are 1, 2, or 4 bytes. If the size
|
||||
* is less than 4 bytes, the data is truncated
|
||||
* rather than casted. That is, only the lower
|
||||
* bits will be read.
|
||||
* @return True on success, false on error.
|
||||
* @error Invalid Handle.
|
||||
*/
|
||||
stock bool WriteFileCell(Handle hndl, int data, int size)
|
||||
{
|
||||
int array[1];
|
||||
|
||||
array[0] = data;
|
||||
|
||||
return WriteFile(hndl, array, 1, size);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Tests if the end of file has been reached.
|
||||
*
|
||||
* @param file Handle to the file.
|
||||
* @return True if end of file has been reached, false otherwise.
|
||||
* @error Invalid Handle.
|
||||
* @param file Handle to the file.
|
||||
* @return True if end of file has been reached, false otherwise.
|
||||
* @error Invalid Handle.
|
||||
*/
|
||||
native bool IsEndOfFile(Handle file);
|
||||
|
||||
/**
|
||||
* Sets the file position indicator.
|
||||
*
|
||||
* @param file Handle to the file.
|
||||
* @param position Position relative to what is specified in whence.
|
||||
* @param where SEEK_ constant value of where to see from.
|
||||
* @return True on success, false otherwise.
|
||||
* @error Invalid Handle.
|
||||
* @param file Handle to the file.
|
||||
* @param position Position relative to what is specified in whence.
|
||||
* @param where SEEK_ constant value of where to see from.
|
||||
* @return True on success, false otherwise.
|
||||
* @error Invalid Handle.
|
||||
*/
|
||||
native bool FileSeek(Handle file, int position, int where);
|
||||
|
||||
/**
|
||||
* Get current position in the file.
|
||||
*
|
||||
* @param file Handle to the file.
|
||||
* @return Value for the file position indicator.
|
||||
* @error Invalid Handle.
|
||||
* @param file Handle to the file.
|
||||
* @return Value for the file position indicator.
|
||||
* @error Invalid Handle.
|
||||
*/
|
||||
native int FilePosition(Handle file);
|
||||
|
||||
/**
|
||||
* Checks if a file exists.
|
||||
*
|
||||
* @param path Path to the file.
|
||||
* @param use_valve_fs If true, the Valve file system will be used instead.
|
||||
* This can be used to find files existing in any of
|
||||
* the Valve search paths, rather than solely files
|
||||
* existing directly in the gamedir.
|
||||
* @param valve_path_id If use_valve_fs, a search path from gameinfo or NULL_STRING for all search paths.
|
||||
* @return True if the file exists, false otherwise.
|
||||
* @param path Path to the file.
|
||||
* @param use_valve_fs If true, the Valve file system will be used instead.
|
||||
* This can be used to find files existing in any of
|
||||
* the Valve search paths, rather than solely files
|
||||
* existing directly in the gamedir.
|
||||
* @param valve_path_id If use_valve_fs, a search path from gameinfo or NULL_STRING for all search paths.
|
||||
* @return True if the file exists, false otherwise.
|
||||
*/
|
||||
native bool FileExists(const char[] path, bool use_valve_fs=false, const char[] valve_path_id="GAME");
|
||||
|
||||
/**
|
||||
* Renames a file.
|
||||
*
|
||||
* @param newpath New path to the file.
|
||||
* @param oldpath Path to the existing file.
|
||||
* @param newpath New path to the file.
|
||||
* @param oldpath Path to the existing file.
|
||||
* @param use_valve_fs If true, the Valve file system will be used instead.
|
||||
* This can be used to rename files in the game's
|
||||
* Valve search paths, rather than directly in the gamedir.
|
||||
* @param valve_path_id If use_valve_fs, a search path from gameinfo or NULL_STRING for all search paths.
|
||||
* @return True on success or use_valve_fs specified, false otherwise.
|
||||
* @param valve_path_id If use_valve_fs, a search path from gameinfo or NULL_STRING for all search paths.
|
||||
* @return True on success or use_valve_fs specified, false otherwise.
|
||||
*/
|
||||
native bool RenameFile(const char[] newpath, const char[] oldpath, bool use_valve_fs=false, const char[] valve_path_id="DEFAULT_WRITE_PATH");
|
||||
|
||||
/**
|
||||
* Checks if a directory exists.
|
||||
*
|
||||
* @param path Path to the directory.
|
||||
* @param path Path to the directory.
|
||||
* @param use_valve_fs If true, the Valve file system will be used instead.
|
||||
* This can be used to find files existing in any of
|
||||
* the Valve search paths, rather than solely files
|
||||
* existing directly in the gamedir.
|
||||
* @param valve_path_id If use_valve_fs, a search path from gameinfo or NULL_STRING for all search paths.
|
||||
* @return True if the directory exists, false otherwise.
|
||||
* @param valve_path_id If use_valve_fs, a search path from gameinfo or NULL_STRING for all search paths.
|
||||
* @return True if the directory exists, false otherwise.
|
||||
*/
|
||||
native bool DirExists(const char[] path, bool use_valve_fs=false, const char[] valve_path_id="GAME");
|
||||
|
||||
/**
|
||||
* Get the file size in bytes.
|
||||
*
|
||||
* @param path Path to the file.
|
||||
* @param use_valve_fs If true, the Valve file system will be used instead.
|
||||
* This can be used to find files existing in any of
|
||||
* the Valve search paths, rather than solely files
|
||||
* existing directly in the gamedir.
|
||||
* @param valve_path_id If use_valve_fs, a search path from gameinfo or NULL_STRING for all search paths.
|
||||
* @return File size in bytes, -1 if file not found.
|
||||
* @param path Path to the file.
|
||||
* @param use_valve_fs If true, the Valve file system will be used instead.
|
||||
* This can be used to find files existing in any of
|
||||
* the Valve search paths, rather than solely files
|
||||
* existing directly in the gamedir.
|
||||
* @param valve_path_id If use_valve_fs, a search path from gameinfo or NULL_STRING for all search paths.
|
||||
* @return File size in bytes, -1 if file not found.
|
||||
*/
|
||||
native int FileSize(const char[] path, bool use_valve_fs=false, const char[] valve_path_id="GAME");
|
||||
|
||||
@@ -538,8 +547,8 @@ native int FileSize(const char[] path, bool use_valve_fs=false, const char[] val
|
||||
* Flushes a file's buffered output; any buffered output
|
||||
* is immediately written to the file.
|
||||
*
|
||||
* @param file Handle to the file.
|
||||
* @return True on success or use_valve_fs specified with OpenFile,
|
||||
* @param file Handle to the file.
|
||||
* @return True on success or use_valve_fs specified with OpenFile,
|
||||
* otherwise false on failure.
|
||||
*/
|
||||
native bool FlushFile(Handle file);
|
||||
@@ -548,71 +557,72 @@ native bool FlushFile(Handle file);
|
||||
* Removes a directory.
|
||||
* @note On most Operating Systems you cannot remove a directory which has files inside it.
|
||||
*
|
||||
* @param path Path to the directory.
|
||||
* @return True on success, false otherwise.
|
||||
* @param path Path to the directory.
|
||||
* @return True on success, false otherwise.
|
||||
*/
|
||||
native bool RemoveDir(const char[] path);
|
||||
|
||||
#define FPERM_U_READ 0x0100 /* User can read. */
|
||||
#define FPERM_U_WRITE 0x0080 /* User can write. */
|
||||
#define FPERM_U_EXEC 0x0040 /* User can exec. */
|
||||
#define FPERM_G_READ 0x0020 /* Group can read. */
|
||||
#define FPERM_G_WRITE 0x0010 /* Group can write. */
|
||||
#define FPERM_G_EXEC 0x0008 /* Group can exec. */
|
||||
#define FPERM_O_READ 0x0004 /* Anyone can read. */
|
||||
#define FPERM_O_WRITE 0x0002 /* Anyone can write. */
|
||||
#define FPERM_O_EXEC 0x0001 /* Anyone can exec. */
|
||||
#define FPERM_U_READ 0x0100 /* User can read. */
|
||||
#define FPERM_U_WRITE 0x0080 /* User can write. */
|
||||
#define FPERM_U_EXEC 0x0040 /* User can exec. */
|
||||
#define FPERM_G_READ 0x0020 /* Group can read. */
|
||||
#define FPERM_G_WRITE 0x0010 /* Group can write. */
|
||||
#define FPERM_G_EXEC 0x0008 /* Group can exec. */
|
||||
#define FPERM_O_READ 0x0004 /* Anyone can read. */
|
||||
#define FPERM_O_WRITE 0x0002 /* Anyone can write. */
|
||||
#define FPERM_O_EXEC 0x0001 /* Anyone can exec. */
|
||||
|
||||
/**
|
||||
* Creates a directory.
|
||||
*
|
||||
* @param path Path to create.
|
||||
* @param mode Permissions (default is o=rx,g=rx,u=rwx). Note that folders must have
|
||||
* the execute bit set on Linux. On Windows, the mode is ignored.
|
||||
* @param path Path to create.
|
||||
* @param mode Permissions (default is o=rx,g=rx,u=rwx). Note that folders must have
|
||||
* the execute bit set on Linux. On Windows, the mode is ignored.
|
||||
* @param use_valve_fs If true, the Valve file system will be used instead.
|
||||
* This can be used to create folders in the game's
|
||||
* Valve search paths, rather than directly in the gamedir.
|
||||
* @param valve_path_id If use_valve_fs, a search path from gameinfo or NULL_STRING for default.
|
||||
* @param valve_path_id If use_valve_fs, a search path from gameinfo or NULL_STRING for default.
|
||||
* In this case, mode is ignored.
|
||||
* @return True on success, false otherwise.
|
||||
*/
|
||||
native bool CreateDirectory(const char[] path, int mode, bool use_valve_fs=false, const char[] valve_path_id="DEFAULT_WRITE_PATH");
|
||||
|
||||
/**
|
||||
* Changes a file or directories permissions.
|
||||
*
|
||||
* @param path Path to the file.
|
||||
* @param mode Permissions to set.
|
||||
* @return True on success, false otherwise.
|
||||
* @param path Path to the file.
|
||||
* @param mode Permissions to set.
|
||||
* @return True on success, false otherwise.
|
||||
*/
|
||||
native bool SetFilePermissions(const char[] path, int mode);
|
||||
|
||||
/**
|
||||
* Returns a file timestamp as a unix timestamp.
|
||||
*
|
||||
* @param file File name.
|
||||
* @param tmode Time mode.
|
||||
* @return Time value, or -1 on failure.
|
||||
* @param file File name.
|
||||
* @param tmode Time mode.
|
||||
* @return Time value, or -1 on failure.
|
||||
*/
|
||||
native int GetFileTime(const char[] file, FileTimeMode tmode);
|
||||
|
||||
/**
|
||||
* Same as LogToFile(), except uses an open file Handle. The file must
|
||||
* Same as LogToFile(), except uses an open file Handle. The file must
|
||||
* be opened in text appending mode.
|
||||
*
|
||||
* @param hndl Handle to the file.
|
||||
* @param message Message format.
|
||||
* @param ... Message format parameters.
|
||||
* @error Invalid Handle.
|
||||
* @param hndl Handle to the file.
|
||||
* @param message Message format.
|
||||
* @param ... Message format parameters.
|
||||
* @error Invalid Handle.
|
||||
*/
|
||||
native void LogToOpenFile(Handle hndl, const char[] message, any ...);
|
||||
|
||||
/**
|
||||
* Same as LogToFileEx(), except uses an open file Handle. The file must
|
||||
* Same as LogToFileEx(), except uses an open file Handle. The file must
|
||||
* be opened in text appending mode.
|
||||
*
|
||||
* @param hndl Handle to the file.
|
||||
* @param message Message format.
|
||||
* @param ... Message format parameters.
|
||||
* @error Invalid Handle.
|
||||
* @param hndl Handle to the file.
|
||||
* @param message Message format.
|
||||
* @param ... Message format parameters.
|
||||
* @error Invalid Handle.
|
||||
*/
|
||||
native void LogToOpenFileEx(Handle hndl, const char[] message, any ...);
|
||||
|
||||
Reference in New Issue
Block a user