1.1 --- a/plugins/include/files.inc Fri Mar 28 06:21:34 2008 +0000
1.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
1.3 @@ -1,259 +0,0 @@
1.4 -/**
1.5 - * vim: set ts=4 :
1.6 - * =============================================================================
1.7 - * SourceMod (C)2004-2007 AlliedModders LLC. All rights reserved.
1.8 - * =============================================================================
1.9 - *
1.10 - * This file is part of the SourceMod/SourcePawn SDK.
1.11 - *
1.12 - * This program is free software; you can redistribute it and/or modify it under
1.13 - * the terms of the GNU General Public License, version 3.0, as published by the
1.14 - * Free Software Foundation.
1.15 - *
1.16 - * This program is distributed in the hope that it will be useful, but WITHOUT
1.17 - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
1.18 - * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
1.19 - * details.
1.20 - *
1.21 - * You should have received a copy of the GNU General Public License along with
1.22 - * this program. If not, see <http://www.gnu.org/licenses/>.
1.23 - *
1.24 - * As a special exception, AlliedModders LLC gives you permission to link the
1.25 - * code of this program (as well as its derivative works) to "Half-Life 2," the
1.26 - * "Source Engine," the "SourcePawn JIT," and any Game MODs that run on software
1.27 - * by the Valve Corporation. You must obey the GNU General Public License in
1.28 - * all respects for all other code used. Additionally, AlliedModders LLC grants
1.29 - * this exception to all derivative works. AlliedModders LLC defines further
1.30 - * exceptions, found in LICENSE.txt (as of this writing, version JULY-31-2007),
1.31 - * or <http://www.sourcemod.net/license.php>.
1.32 - *
1.33 - * Version: $Id$
1.34 - */
1.35 -
1.36 -#if defined _files_included
1.37 - #endinput
1.38 -#endif
1.39 -#define _files_included
1.40 -
1.41 -/* @global All paths in SourceMod natives are relative to the mod folder unless otherwise noted. */
1.42 -
1.43 -/**
1.44 - * File inode types.
1.45 - */
1.46 -enum FileType
1.47 -{
1.48 - FileType_Unknown = 0, /* Unknown file type (device/socket) */
1.49 - FileType_Directory = 1, /* File is a directory */
1.50 - FileType_File = 2, /* File is a file */
1.51 -};
1.52 -
1.53 -/**
1.54 - * File time modes.
1.55 - */
1.56 -enum FileTimeMode
1.57 -{
1.58 - FileTime_LastAccess = 0, /* Last access (does not work on FAT) */
1.59 - FileTime_Created = 1, /* Creation (does not work on FAT) */
1.60 - FileTime_LastChange = 2, /* Last modification */
1.61 -};
1.62 -
1.63 -#define PLATFORM_MAX_PATH 256 /**< Maximum path length. */
1.64 -
1.65 -#define SEEK_SET 0 /**< Seek from start. */
1.66 -#define SEEK_CUR 1 /**< Seek from current position. */
1.67 -#define SEEK_END 2 /**< Seek from end position. */
1.68 -
1.69 -/**
1.70 - * Path types.
1.71 - */
1.72 -enum PathType
1.73 -{
1.74 - Path_SM, /**< SourceMod root folder */
1.75 -};
1.76 -
1.77 -/**
1.78 - * Builds a path relative to the SourceMod folder.
1.79 - *
1.80 - * @param type Type of path to build as the base.
1.81 - * @param buffer Buffer to store the path.
1.82 - * @param maxlength Maximum length of buffer.
1.83 - * @param fmt Format string.
1.84 - * @param ... Format arguments.
1.85 - * @return Number of bytes written to buffer (not including null terminator).
1.86 - */
1.87 -native BuildPath(PathType:type, String:buffer[], maxlength, const String:fmt[], any:...);
1.88 -
1.89 -/**
1.90 - * Opens a directory/folder for contents enumeration.
1.91 - * @note Directories are closed with CloseHandle().
1.92 - * @note Directories Handles can be cloned.
1.93 - *
1.94 - * @param path Path to open.
1.95 - * @return A Handle to the directory, INVALID_HANDLE on open error.
1.96 - */
1.97 -native Handle:OpenDirectory(const String:path[]);
1.98 -
1.99 -/**
1.100 - * Reads the current directory entry as a local filename, then moves to the next file.
1.101 - * @note Contents of buffers are undefined when returning false.
1.102 - * @note Both the '.' and '..' automatic directory entries will be retrieved for Windows and Linux.
1.103 - *
1.104 - * @param dir Handle to a directory.
1.105 - * @param buffer String buffer to hold directory name.
1.106 - * @param maxlength Maximum size of string buffer.
1.107 - * @param type Optional variable to store the file type.
1.108 - * @return True on success, false if there are no more files to read.
1.109 - * @error Invalid or corrupt Handle.
1.110 - */
1.111 -native bool:ReadDirEntry(Handle:dir, String:buffer[], maxlength, &FileType:type=FileType_Unknown);
1.112 -
1.113 -/**
1.114 - * Opens a file.
1.115 - * @note Files are closed with CloseHandle().
1.116 - * @note File Handles can be cloned.
1.117 - *
1.118 - * @param file File to open.
1.119 - * @param mode Open mode.
1.120 - * @return A Handle to the file, INVALID_HANDLE on open error.
1.121 - */
1.122 -native Handle:OpenFile(const String:file[], const String:mode[]);
1.123 -
1.124 -/**
1.125 - * Deletes a file.
1.126 - *
1.127 - * @param path Path of the file to delete.
1.128 - * @return True on success, false otherwise.
1.129 - */
1.130 -native bool:DeleteFile(const String:path[]);
1.131 -
1.132 -/**
1.133 - * Reads a line from a text file.
1.134 - *
1.135 - * @param hndl Handle to the file.
1.136 - * @param buffer String buffer to hold the line.
1.137 - * @param maxlength Maximum size of string buffer.
1.138 - * @return True on success, false otherwise.
1.139 - */
1.140 -native bool:ReadFileLine(Handle:hndl, String:buffer[], maxlength);
1.141 -
1.142 -/**
1.143 - * Tests if the end of file has been reached.
1.144 - *
1.145 - * @param file Handle to the file.
1.146 - * @return True if end of file has been reached, false otherwise.
1.147 - */
1.148 -native bool:IsEndOfFile(Handle:file);
1.149 -
1.150 -/**
1.151 - * Sets the file position indicator.
1.152 - *
1.153 - * @param file Handle to the file.
1.154 - * @param position Position relative to what is specified in whence.
1.155 - * @param whence Look at the SEEK_* definitions.
1.156 - * @return True on success, false otherwise.
1.157 - */
1.158 -native bool:FileSeek(Handle:file, position, whence);
1.159 -
1.160 -/**
1.161 - * Get current position in the file.
1.162 - *
1.163 - * @param file Handle to the file.
1.164 - * @return Value for the file position indicator.
1.165 - */
1.166 -native FilePosition(Handle:file);
1.167 -
1.168 -/**
1.169 - * Checks if a file exists.
1.170 - *
1.171 - * @param path Path to the file.
1.172 - * @return True if the file exists, false otherwise.
1.173 - */
1.174 -native bool:FileExists(const String:path[]);
1.175 -
1.176 -/**
1.177 - * Renames a file.
1.178 - *
1.179 - * @param newpath New path to the file.
1.180 - * @param oldpath Path to the existing file.
1.181 - * @return True on success, false otherwise.
1.182 - */
1.183 -native bool:RenameFile(const String:newpath[], const String:oldpath[]);
1.184 -
1.185 -/**
1.186 - * Checks if a directory exists.
1.187 - *
1.188 - * @param path Path to the directory.
1.189 - * @return True if the directory exists, false otherwise.
1.190 - */
1.191 -native bool:DirExists(const String:path[]);
1.192 -
1.193 -/**
1.194 - * Get the file size in bytes.
1.195 - *
1.196 - * @param path Path to the file.
1.197 - * @return File size in bytes, -1 if file not found.
1.198 - */
1.199 -native FileSize(const String:path[]);
1.200 -
1.201 -/**
1.202 - * Flushes a file's buffered output; any buffered output
1.203 - * is immediately written to the file.
1.204 - *
1.205 - * @param file Handle to the file.
1.206 - * @return True on success, false on failure.
1.207 - */
1.208 -native FlushFile(Handle:file);
1.209 -
1.210 -/**
1.211 - * Removes a directory.
1.212 - * @note On most Operating Systems you cannot remove a directory which has files inside it.
1.213 - *
1.214 - * @param path Path to the directory.
1.215 - * @return True on success, false otherwise.
1.216 - */
1.217 -native bool:RemoveDir(const String:path[]);
1.218 -
1.219 -/**
1.220 - * Writes a line of text in a file.
1.221 - * @note This native will append the newline character.
1.222 - *
1.223 - * @param hndl Handle to the file.
1.224 - * @param format Formatting rules.
1.225 - * @param ... Variable number of format parameters.
1.226 - * @return True on success, false otherwise.
1.227 - */
1.228 -native bool:WriteFileLine(Handle:hndl, const String:format[], any:...);
1.229 -
1.230 -/**
1.231 - * Returns a file timestamp as a unix timestamp.
1.232 - *
1.233 - * @param file File name.
1.234 - * @param tmode Time mode.
1.235 - * @return Time value, or -1 on failure.
1.236 - */
1.237 -native GetFileTime(const String:file[], FileTimeMode:tmode);
1.238 -
1.239 -/**
1.240 - * Same as LogToFile(), except uses an open file Handle. The file must
1.241 - * be opened in text appending mode.
1.242 - *
1.243 - * @param hndl Handle to the file.
1.244 - * @param message Message format.
1.245 - * @param ... Message format parameters.
1.246 - * @noreturn
1.247 - * @error Invalid Handle.
1.248 - */
1.249 -native LogToOpenFile(Handle:hndl, const String:message[], any:...);
1.250 -
1.251 -/**
1.252 - * Same as LogToFileEx(), except uses an open file Handle. The file must
1.253 - * be opened in text appending mode.
1.254 - *
1.255 - * @param hndl Handle to the file.
1.256 - * @param message Message format.
1.257 - * @param ... Message format parameters.
1.258 - * @noreturn
1.259 - * @error Invalid Handle.
1.260 - */
1.261 -native LogToOpenFileEx(Handle:hndl, const String:message[], any:...);
1.262 -