@amxts/core 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (247) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +162 -0
  3. package/README.ru.md +162 -0
  4. package/amxmodx/base/include/amxconst.inc +594 -0
  5. package/amxmodx/base/include/amxmisc.inc +902 -0
  6. package/amxmodx/base/include/amxmodx.inc +3447 -0
  7. package/amxmodx/base/include/amxmodx_version.inc +20 -0
  8. package/amxmodx/base/include/cellarray.inc +525 -0
  9. package/amxmodx/base/include/cellstack.inc +166 -0
  10. package/amxmodx/base/include/celltrie.inc +412 -0
  11. package/amxmodx/base/include/core.inc +202 -0
  12. package/amxmodx/base/include/csstats.inc +298 -0
  13. package/amxmodx/base/include/csstats_const.inc +29 -0
  14. package/amxmodx/base/include/cstrike.inc +1287 -0
  15. package/amxmodx/base/include/cstrike_const.inc +521 -0
  16. package/amxmodx/base/include/csx.inc +259 -0
  17. package/amxmodx/base/include/cvars.inc +547 -0
  18. package/amxmodx/base/include/datapack.inc +161 -0
  19. package/amxmodx/base/include/dbi.inc +154 -0
  20. package/amxmodx/base/include/dodconst.inc +152 -0
  21. package/amxmodx/base/include/dodfun.inc +152 -0
  22. package/amxmodx/base/include/dodstats.inc +69 -0
  23. package/amxmodx/base/include/dodx.inc +161 -0
  24. package/amxmodx/base/include/engine.inc +1343 -0
  25. package/amxmodx/base/include/engine_const.inc +310 -0
  26. package/amxmodx/base/include/engine_stocks.inc +248 -0
  27. package/amxmodx/base/include/esf.inc +70 -0
  28. package/amxmodx/base/include/esf_const.inc +74 -0
  29. package/amxmodx/base/include/fakemeta.inc +1127 -0
  30. package/amxmodx/base/include/fakemeta_const.inc +793 -0
  31. package/amxmodx/base/include/fakemeta_stocks.inc +395 -0
  32. package/amxmodx/base/include/fakemeta_util.inc +882 -0
  33. package/amxmodx/base/include/file.inc +666 -0
  34. package/amxmodx/base/include/float.inc +422 -0
  35. package/amxmodx/base/include/fun.inc +333 -0
  36. package/amxmodx/base/include/gameconfig.inc +93 -0
  37. package/amxmodx/base/include/geoip.inc +264 -0
  38. package/amxmodx/base/include/ham_const.inc +4352 -0
  39. package/amxmodx/base/include/hamsandwich.inc +439 -0
  40. package/amxmodx/base/include/hlsdk_const.inc +808 -0
  41. package/amxmodx/base/include/json.inc +777 -0
  42. package/amxmodx/base/include/lang.inc +119 -0
  43. package/amxmodx/base/include/message_const.inc +1130 -0
  44. package/amxmodx/base/include/message_stocks.inc +161 -0
  45. package/amxmodx/base/include/messages.inc +604 -0
  46. package/amxmodx/base/include/newmenus.inc +387 -0
  47. package/amxmodx/base/include/ns.inc +754 -0
  48. package/amxmodx/base/include/ns_const.inc +196 -0
  49. package/amxmodx/base/include/nvault.inc +154 -0
  50. package/amxmodx/base/include/regex.inc +348 -0
  51. package/amxmodx/base/include/sockets.inc +183 -0
  52. package/amxmodx/base/include/sorting.inc +107 -0
  53. package/amxmodx/base/include/sqlx.inc +582 -0
  54. package/amxmodx/base/include/string.inc +786 -0
  55. package/amxmodx/base/include/string_const.inc +156 -0
  56. package/amxmodx/base/include/string_stocks.inc +325 -0
  57. package/amxmodx/base/include/textparse_ini.inc +214 -0
  58. package/amxmodx/base/include/textparse_smc.inc +261 -0
  59. package/amxmodx/base/include/tfcconst.inc +84 -0
  60. package/amxmodx/base/include/tfcstats.inc +62 -0
  61. package/amxmodx/base/include/tfcx.inc +148 -0
  62. package/amxmodx/base/include/time.inc +118 -0
  63. package/amxmodx/base/include/tsconst.inc +154 -0
  64. package/amxmodx/base/include/tsfun.inc +198 -0
  65. package/amxmodx/base/include/tsstats.inc +65 -0
  66. package/amxmodx/base/include/tsx.inc +88 -0
  67. package/amxmodx/base/include/vault.inc +60 -0
  68. package/amxmodx/base/include/vector.inc +131 -0
  69. package/amxmodx/base/include/xs.inc +1570 -0
  70. package/as/amxts.d.ts +153 -0
  71. package/as/constants.ts +4730 -0
  72. package/as/effects.ts +1449 -0
  73. package/as/entities.ts +5482 -0
  74. package/as/events.ts +3054 -0
  75. package/as/facade.ts +4639 -0
  76. package/as/flags.ts +299 -0
  77. package/as/fs.ts +287 -0
  78. package/as/hooks.ts +18536 -0
  79. package/as/kit.ts +25 -0
  80. package/as/lib/check.ts +86 -0
  81. package/as/modules/http.ts +184 -0
  82. package/as/natives.ts +11845 -0
  83. package/as/os.ts +30 -0
  84. package/as/promise.ts +1392 -0
  85. package/as/promise.types.d.ts +82 -0
  86. package/as/remote.ts +288 -0
  87. package/as/tsconfig.json +22 -0
  88. package/as/vector.ts +65 -0
  89. package/bin/amxts.mjs +10 -0
  90. package/includes/menu_core.inc +355 -0
  91. package/includes/order.txt +54 -0
  92. package/includes/sources.json +27 -0
  93. package/includes/universal_config.inc +355 -0
  94. package/lint/oxlint-plugin.mjs +77 -0
  95. package/node_modules/assemblyscript/LICENSE +201 -0
  96. package/node_modules/assemblyscript/NOTICE +93 -0
  97. package/node_modules/assemblyscript/package.json +63 -0
  98. package/node_modules/assemblyscript/std/README.md +6 -0
  99. package/node_modules/assemblyscript/std/assembly/array.ts +526 -0
  100. package/node_modules/assemblyscript/std/assembly/arraybuffer.ts +77 -0
  101. package/node_modules/assemblyscript/std/assembly/atomics.ts +127 -0
  102. package/node_modules/assemblyscript/std/assembly/bindings/asyncify.ts +16 -0
  103. package/node_modules/assemblyscript/std/assembly/bindings/dom.ts +291 -0
  104. package/node_modules/assemblyscript/std/assembly/bindings/node.ts +6 -0
  105. package/node_modules/assemblyscript/std/assembly/builtins.ts +2631 -0
  106. package/node_modules/assemblyscript/std/assembly/compat.ts +2 -0
  107. package/node_modules/assemblyscript/std/assembly/console.ts +42 -0
  108. package/node_modules/assemblyscript/std/assembly/crypto.ts +9 -0
  109. package/node_modules/assemblyscript/std/assembly/dataview.ts +181 -0
  110. package/node_modules/assemblyscript/std/assembly/date.ts +373 -0
  111. package/node_modules/assemblyscript/std/assembly/diagnostics.ts +11 -0
  112. package/node_modules/assemblyscript/std/assembly/error.ts +44 -0
  113. package/node_modules/assemblyscript/std/assembly/function.ts +38 -0
  114. package/node_modules/assemblyscript/std/assembly/index.d.ts +2822 -0
  115. package/node_modules/assemblyscript/std/assembly/iterator.ts +35 -0
  116. package/node_modules/assemblyscript/std/assembly/map.ts +260 -0
  117. package/node_modules/assemblyscript/std/assembly/math.ts +3289 -0
  118. package/node_modules/assemblyscript/std/assembly/memory.ts +123 -0
  119. package/node_modules/assemblyscript/std/assembly/number.ts +388 -0
  120. package/node_modules/assemblyscript/std/assembly/object.ts +36 -0
  121. package/node_modules/assemblyscript/std/assembly/performance.ts +9 -0
  122. package/node_modules/assemblyscript/std/assembly/polyfills.ts +27 -0
  123. package/node_modules/assemblyscript/std/assembly/process.ts +50 -0
  124. package/node_modules/assemblyscript/std/assembly/reference.ts +48 -0
  125. package/node_modules/assemblyscript/std/assembly/regexp.ts +12 -0
  126. package/node_modules/assemblyscript/std/assembly/rt/README.md +83 -0
  127. package/node_modules/assemblyscript/std/assembly/rt/common.ts +81 -0
  128. package/node_modules/assemblyscript/std/assembly/rt/index-incremental.ts +2 -0
  129. package/node_modules/assemblyscript/std/assembly/rt/index-minimal.ts +2 -0
  130. package/node_modules/assemblyscript/std/assembly/rt/index-stub.ts +1 -0
  131. package/node_modules/assemblyscript/std/assembly/rt/index.d.ts +37 -0
  132. package/node_modules/assemblyscript/std/assembly/rt/itcms.ts +419 -0
  133. package/node_modules/assemblyscript/std/assembly/rt/rtrace.ts +15 -0
  134. package/node_modules/assemblyscript/std/assembly/rt/stub.ts +133 -0
  135. package/node_modules/assemblyscript/std/assembly/rt/tcms.ts +254 -0
  136. package/node_modules/assemblyscript/std/assembly/rt/tlsf.ts +592 -0
  137. package/node_modules/assemblyscript/std/assembly/rt.ts +87 -0
  138. package/node_modules/assemblyscript/std/assembly/set.ts +220 -0
  139. package/node_modules/assemblyscript/std/assembly/shared/feature.ts +65 -0
  140. package/node_modules/assemblyscript/std/assembly/shared/runtime.ts +11 -0
  141. package/node_modules/assemblyscript/std/assembly/shared/target.ts +11 -0
  142. package/node_modules/assemblyscript/std/assembly/shared/tsconfig.json +11 -0
  143. package/node_modules/assemblyscript/std/assembly/shared/typeinfo.ts +72 -0
  144. package/node_modules/assemblyscript/std/assembly/staticarray.ts +401 -0
  145. package/node_modules/assemblyscript/std/assembly/string.ts +847 -0
  146. package/node_modules/assemblyscript/std/assembly/symbol.ts +114 -0
  147. package/node_modules/assemblyscript/std/assembly/table.ts +16 -0
  148. package/node_modules/assemblyscript/std/assembly/tsconfig.json +6 -0
  149. package/node_modules/assemblyscript/std/assembly/typedarray.ts +1945 -0
  150. package/node_modules/assemblyscript/std/assembly/uri.ts +17 -0
  151. package/node_modules/assemblyscript/std/assembly/util/bytes.ts +107 -0
  152. package/node_modules/assemblyscript/std/assembly/util/casemap.ts +497 -0
  153. package/node_modules/assemblyscript/std/assembly/util/error.ts +54 -0
  154. package/node_modules/assemblyscript/std/assembly/util/hash.ts +117 -0
  155. package/node_modules/assemblyscript/std/assembly/util/math.ts +1922 -0
  156. package/node_modules/assemblyscript/std/assembly/util/memory.ts +290 -0
  157. package/node_modules/assemblyscript/std/assembly/util/number.ts +873 -0
  158. package/node_modules/assemblyscript/std/assembly/util/sort.ts +313 -0
  159. package/node_modules/assemblyscript/std/assembly/util/string.ts +1202 -0
  160. package/node_modules/assemblyscript/std/assembly/util/uri.ts +275 -0
  161. package/node_modules/assemblyscript/std/assembly/vector.ts +4 -0
  162. package/node_modules/assemblyscript/std/assembly.json +16 -0
  163. package/node_modules/assemblyscript/std/portable/index.d.ts +462 -0
  164. package/node_modules/assemblyscript/std/portable/index.js +416 -0
  165. package/node_modules/assemblyscript/std/portable.json +11 -0
  166. package/node_modules/assemblyscript/std/types/assembly/index.d.ts +1 -0
  167. package/node_modules/assemblyscript/std/types/assembly/package.json +3 -0
  168. package/node_modules/assemblyscript/std/types/portable/index.d.ts +1 -0
  169. package/node_modules/assemblyscript/std/types/portable/package.json +3 -0
  170. package/node_modules/assemblyscript/tsconfig-base.json +13 -0
  171. package/package.json +112 -0
  172. package/runtime/deps/assemblyscript/LICENSE +201 -0
  173. package/runtime/deps/assemblyscript/NOTICE +93 -0
  174. package/runtime/deps/assemblyscript/bin/asc.js +35 -0
  175. package/runtime/deps/assemblyscript/dist/asc.js +25035 -0
  176. package/runtime/deps/assemblyscript/dist/assemblyscript.js +337 -0
  177. package/runtime/deps/assemblyscript/node_modules/binaryen/LICENSE +201 -0
  178. package/runtime/deps/assemblyscript/node_modules/binaryen/index.js +28905 -0
  179. package/runtime/deps/assemblyscript/node_modules/binaryen/package.json +50 -0
  180. package/runtime/deps/assemblyscript/node_modules/long/LICENSE +202 -0
  181. package/runtime/deps/assemblyscript/node_modules/long/index.js +1581 -0
  182. package/runtime/deps/assemblyscript/node_modules/long/package.json +58 -0
  183. package/runtime/deps/assemblyscript/package.json +114 -0
  184. package/runtime/host/amxts.inc +85 -0
  185. package/runtime/licenses/AMXX-LICENSE.txt +34 -0
  186. package/runtime/licenses/AssemblyScript-LICENSE +201 -0
  187. package/runtime/licenses/AssemblyScript-NOTICE +93 -0
  188. package/runtime/licenses/Binaryen-LICENSE +201 -0
  189. package/runtime/licenses/Bun-LICENSE.md +84 -0
  190. package/runtime/licenses/GPL-3.0.txt +674 -0
  191. package/runtime/licenses/LLVM-LICENSE.TXT +279 -0
  192. package/runtime/licenses/README.md +25 -0
  193. package/runtime/licenses/WAMR-LICENSE +219 -0
  194. package/runtime/natives.txt +1095 -0
  195. package/runtime/patches/README.md +59 -0
  196. package/runtime/patches/assemblyscript-0.28.20-amxts.patch +14174 -0
  197. package/runtime/patches/wamr-2.4.5-amxts.patch +364 -0
  198. package/scripts/apply-docs.ts +508 -0
  199. package/scripts/asc.ts +27 -0
  200. package/scripts/auto-imports.ts +258 -0
  201. package/scripts/build-wasm.ts +595 -0
  202. package/scripts/check.ts +93 -0
  203. package/scripts/compile-cache.ts +179 -0
  204. package/scripts/compile.ts +401 -0
  205. package/scripts/docker-server.ts +73 -0
  206. package/scripts/docs/as/amxts.ts +210 -0
  207. package/scripts/docs/as/effects.ts +1684 -0
  208. package/scripts/docs/as/facade.ts +3302 -0
  209. package/scripts/docs/as/fs.ts +173 -0
  210. package/scripts/docs/as/lib/check.ts +68 -0
  211. package/scripts/docs/as/modules/http.ts +66 -0
  212. package/scripts/docs/as/os.ts +16 -0
  213. package/scripts/docs/as/promise.ts +132 -0
  214. package/scripts/docs/as/promise.types.ts +63 -0
  215. package/scripts/docs/as/vector.ts +48 -0
  216. package/scripts/docs/entities.ts +2338 -0
  217. package/scripts/docs/events.ts +245 -0
  218. package/scripts/docs/game.ts +497 -0
  219. package/scripts/docs/messages.ts +148 -0
  220. package/scripts/file-contents.ts +74 -0
  221. package/scripts/includes.ts +134 -0
  222. package/scripts/player-fields.ts +866 -0
  223. package/scripts/plugin-cache.ts +92 -0
  224. package/scripts/plugin-natives.ts +1157 -0
  225. package/scripts/prebuilt.ts +268 -0
  226. package/scripts/prepare.ts +134 -0
  227. package/scripts/project.ts +973 -0
  228. package/scripts/run.ts +28 -0
  229. package/scripts/shared-modules.ts +906 -0
  230. package/scripts/system.ts +33 -0
  231. package/scripts/tracked-fs.ts +115 -0
  232. package/scripts/typed-configs.ts +788 -0
  233. package/scripts/ui.ts +77 -0
  234. package/src/cli-api.mjs +175 -0
  235. package/src/parser/include-parser.ts +506 -0
  236. package/src/system.mjs +155 -0
  237. package/src/testing/compile-cache.ts +31 -0
  238. package/src/testing/compile.ts +222 -0
  239. package/src/testing/coroutines.ts +191 -0
  240. package/src/testing/index.ts +39 -0
  241. package/src/testing/kits.ts +55 -0
  242. package/src/testing/memory.ts +125 -0
  243. package/src/testing/natives.ts +925 -0
  244. package/src/testing/server.ts +1874 -0
  245. package/src/testing/setup.ts +63 -0
  246. package/src/testing/tables.ts +139 -0
  247. package/src/types.ts +51 -0
@@ -0,0 +1,666 @@
1
+ // vim: set ts=4 sw=4 tw=99 noet:
2
+ //
3
+ // AMX Mod X, based on AMX Mod by Aleksander Naszko ("OLO").
4
+ // Copyright (C) The AMX Mod X Development Team.
5
+ //
6
+ // This software is licensed under the GNU General Public License, version 3 or higher.
7
+ // Additional exceptions apply. For full license details, see LICENSE.txt or visit:
8
+ // https://alliedmods.net/amxmodx-license
9
+
10
+ //
11
+ // File Functions
12
+ //
13
+
14
+ #if defined _file_included
15
+ #endinput
16
+ #endif
17
+ #define _file_included
18
+
19
+ /**
20
+ * @note All paths in AMX Mod X natives are relative to the mod folder
21
+ * unless otherwise noted.
22
+ *
23
+ * Most functions in AMX Mod X (at least, ones that deal with direct
24
+ * file manipulation) will support an alternate path specification.
25
+ */
26
+
27
+ /**
28
+ * Maximum path length.
29
+ */
30
+ #define PLATFORM_MAX_PATH 256
31
+
32
+ /**
33
+ * File inode types for use with open_dir() and next_file().
34
+ */
35
+ enum FileType
36
+ {
37
+ FileType_Unknown, /* Unknown file type (device/socket) */
38
+ FileType_Directory, /* File is a directory */
39
+ FileType_File, /* File is a file */
40
+ };
41
+
42
+ /**
43
+ * File time modes for use with GetFileTime().
44
+ */
45
+ enum FileTimeType
46
+ {
47
+ FileTime_LastAccess, /* Last access (not available on FAT) */
48
+ FileTime_Created, /* Creation (not available on FAT) */
49
+ FileTime_LastChange, /* Last modification */
50
+ };
51
+
52
+ /**
53
+ * File position modes for use with fseek().
54
+ */
55
+ #define SEEK_SET 0 /* Seek from start */
56
+ #define SEEK_CUR 1 /* Seek from current position */
57
+ #define SEEK_END 2 /* Seek from end position */
58
+
59
+ /**
60
+ * Options for use with file_size() flag parameter.
61
+ */
62
+ #define FSOPT_BYTES_COUNT 0 /* Returns the file size in number of bytes */
63
+ #define FSOPT_LINES_COUNT 1 /* Returns how many lines there are in this file */
64
+ #define FSOPT_END_WITH_LF 2 /* Returns whether the last line is '\n' */
65
+
66
+ /**
67
+ * Data block modes for use with fread*() and fwrite*().
68
+ */
69
+ #define BLOCK_INT 4
70
+ #define BLOCK_SHORT 2
71
+ #define BLOCK_CHAR 1
72
+ #define BLOCK_BYTE 1
73
+
74
+ /**
75
+ * File permissions flags for use with mkdir() and SetFilePermissions().
76
+ */
77
+ #define FPERM_U_READ 0x0100 /* User can read. */
78
+ #define FPERM_U_WRITE 0x0080 /* User can write. */
79
+ #define FPERM_U_EXEC 0x0040 /* User can exec. */
80
+ #define FPERM_U_RWX FPERM_U_READ | FPERM_U_WRITE | FPERM_U_EXEC
81
+
82
+ #define FPERM_G_READ 0x0020 /* Group can read. */
83
+ #define FPERM_G_WRITE 0x0010 /* Group can write. */
84
+ #define FPERM_G_EXEC 0x0008 /* Group can exec. */
85
+ #define FPERM_G_RWX FPERM_G_READ | FPERM_G_WRITE | FPERM_G_EXEC
86
+
87
+ #define FPERM_O_READ 0x0004 /* Anyone can read. */
88
+ #define FPERM_O_WRITE 0x0002 /* Anyone can write. */
89
+ #define FPERM_O_EXEC 0x0001 /* Anyone can exec. */
90
+ #define FPERM_O_RWX FPERM_O_READ | FPERM_O_WRITE | FPERM_O_EXEC
91
+
92
+ #define FPERM_DIR_DEFAULT FPERM_U_RWX | FPERM_G_RWX | FPERM_O_RWX /* rwx r-x r-x (0755) */
93
+
94
+
95
+ /**
96
+ * Reads content from directory
97
+ *
98
+ * @note This native is expensive. Consider the use of open_dir(), next_file() and close_dir() instead.
99
+ * @note Both the '.' and '..' automatic directory entries will be retrieved for Windows and Linux.
100
+ *
101
+ * @param dirname Path to open
102
+ * @param pos Index the element
103
+ * @param output String buffer to hold content
104
+ * @param len Maximum size of string buffer
105
+ * @param outlen Number of characters written to the buffer
106
+ *
107
+ * @return Returns index of next element, otherwiwe 0 when end of dir is reached
108
+ */
109
+ native read_dir(const dirname[], pos, output[], len, &outlen = 0);
110
+
111
+ /**
112
+ * Reads line from file.
113
+ *
114
+ * @note This native is expensive. Consider the use of new file natives (fopen(), fgets(), etc.)
115
+ * if purpose is to read several lines of a file.
116
+ *
117
+ * @param file Path to open
118
+ * @param line Index of the line, starting to 0
119
+ * @param text String buffer to hold line read
120
+ * @param len Maximum size of string buffer
121
+ * @param txtlen Number of characters written to the buffer
122
+ *
123
+ * @return Returns index of next line, otherwise 0 when end of file is reached
124
+ * @error Unable to read the file
125
+ */
126
+ native read_file(const file[], line, text[], len, &txtlen = 0);
127
+
128
+ /**
129
+ * Writes text to file.
130
+ *
131
+ * @note This native is expensive. Consider the use of new file natives (fopen(), fputs(), etc.)
132
+ * if purpose is to write several lines of a file.
133
+ *
134
+ * @param file Path to open
135
+ * @param text String to write to
136
+ * @param line Index of the line, starting to 0
137
+ * If < 0, content will be appended
138
+ *
139
+ * @noreturn
140
+ * @error Unable to write [temporary] file
141
+ */
142
+ native write_file(const file[], const text[], line = -1);
143
+
144
+ /**
145
+ * Deletes a file.
146
+ *
147
+ * @param file Path of the file to delete
148
+ * @param use_valve_fs If true, the Valve file system will be used instead.
149
+ * This can be used to delete files existing in the Valve
150
+ * search path, rather than solely files existing directly
151
+ * in the gamedir.
152
+ * @param valve_path_id If use_valve_fs, a search path from gameinfo or NULL_STRING for all search paths.
153
+ *
154
+ * @return 1 on success, 0 on failure or if file not immediately removed.
155
+ */
156
+ native delete_file(const file[], bool:use_valve_fs = false, const valve_path_id[] = "GAMECONFIG");
157
+
158
+ /**
159
+ * Checks if a file exists.
160
+ *
161
+ * @param file Path to the file
162
+ * @param use_valve_fs If true, the Valve file system will be used instead.
163
+ * This can be used to find files existing in any of
164
+ * the Valve search paths, rather than solely files
165
+ * existing directly in the gamedir.
166
+ *
167
+ * @return 1 if the file exists, 0 otherwise
168
+ */
169
+ native file_exists(const file[], bool:use_valve_fs = false);
170
+
171
+ /**
172
+ * Renames a file.
173
+ *
174
+ * @param oldname New path to the file
175
+ * @param newname Path to the existing file
176
+ * @param relative If true, native will act like other natives which
177
+ * use the moddir as a base directory. Otherwise, the
178
+ * current directory is undefined (but assumed to be hlds).
179
+ *
180
+ * @return 1 on success, 0 otherwise
181
+ */
182
+ native rename_file(const oldname[], const newname[], relative = 0);
183
+
184
+ /**
185
+ * Checks if a directory exists.
186
+ *
187
+ * @param dir Path to the directory
188
+ * @param use_valve_fs If true, the Valve file system will be used instead.
189
+ * This can be used to find files existing in any of
190
+ * the Valve search paths, rather than solely files
191
+ * existing directly in the gamedir.
192
+ *
193
+ * @return 1 if the directory exists, 0 otherwise
194
+ */
195
+ native dir_exists(const dir[], bool:use_valve_fs = false);
196
+
197
+ /**
198
+ * Get the file size in bytes.
199
+ *
200
+ * @param file Path to the file
201
+ * @param flag Flag options, see FSOPT_* constants
202
+ * @param use_valve_fs If true, the Valve file system will be used instead.
203
+ * This can be used to find files existing in any of
204
+ * the Valve search paths, rather than solely files
205
+ * existing directly in the gamedir.
206
+ * If used, flag option is ignored.
207
+ * @param valve_path_id If use_valve_fs, a search path from gameinfo or NULL_STRING for all search paths
208
+ *
209
+ * @return If flag is FSOPT_BYTES_COUNT or use_valve_fs to true, the file size in bytes
210
+ * If flag is FSOPT_LINES_COUNT, the number of lines in the file
211
+ * If flag is FSOPT_END_WITH_LF, 1 is returned if file ends with line feed
212
+ * If file doesn't exist, -1
213
+ */
214
+ native file_size(const file[], flag = FSOPT_BYTES_COUNT, bool:use_valve_fs = false, const valve_path_id[] = "GAME");
215
+
216
+ /**
217
+ * Opens or creates a file, returning a file handle on success. File handles
218
+ * should be closed with fclose().
219
+ *
220
+ * @note The open mode may be one of the following strings:
221
+ * "r": Open an existing file for reading.
222
+ * "w": Create a file for writing, or truncate (delete the contents of) an
223
+ * existing file and then open it for writing.
224
+ * "a": Create a file for writing, or open an existing file such that writes
225
+ * will be appended to the end.
226
+ * "r+": Open an existing file for both reading and writing.
227
+ * "w+": Create a file for reading and writing, or truncate an existing file
228
+ * and then open it for reading and writing.
229
+ * "a+": Create a file for both reading and writing, or open an existing file
230
+ * such that writes will be appended to the end.
231
+ *
232
+ * @note The open mode may also contain an additional character after "r", "w", or "a",
233
+ * but before any "+" sign. This character may be "b" (indicating binary mode) or
234
+ * "t" (indicating text mode). By default, "text" mode is implied. On Linux and
235
+ * Mac, this has no distinction from binary mode. On Windows, it causes the '\n'
236
+ * character (0xA) to be written as "\r\n" (0xD, 0xA).
237
+ *
238
+ * Example: "rb" opens a binary file for writing; "at" opens a text file for
239
+ * appending.
240
+ *
241
+ * @note Registered paths ID are (in priority order) :
242
+ * GAME All paths related to current mod, including fallback
243
+ * Depending settings, it includes: <gamedir>_lv/_addon/_<language>/_hd
244
+ * and <gamedir> itself
245
+ * GAMECONFIG The default writable directory (<gamedir>)
246
+ * GAMEDOWNLOAD The download directory (<gamedir>_download)
247
+ * GAME_FALLBACK All paths related to fallback game, same as GAME
248
+ * DEFAULTGAME All paths related to the default game which is "valve", same as GAME
249
+ * BASE The base path where server is installed
250
+ *
251
+ * Note that some paths are non-writable. It includes all <gamedir>_* (expect _download)
252
+ * and DEFAULTGAME. Any file inside a non-writable path will be ignored if you try to open
253
+ * it in writing mode.
254
+ *
255
+ * @param filename File to open
256
+ * @param mode Open mode
257
+ * @param use_valve_fs If true, the Valve file system will be used instead
258
+ * This can be used to finred files existing in valve
259
+ * search paths, rather than solely files existing directly
260
+ * in the gamedir.
261
+ * @param valve_path_id If use_valve_fs, a search path from gameinfo or NULL_STRING for all search paths
262
+ *
263
+ * @return A file handle, or null if the file could not be opened.
264
+ */
265
+ native fopen(const filename[], const mode[], bool:use_valve_fs = false, const valve_path_id[] = "GAME");
266
+
267
+ /**
268
+ * Closes a file handle.
269
+ *
270
+ * @param file File handle
271
+ */
272
+ native fclose(file);
273
+
274
+ /**
275
+ * Reads a single binary data from a file.
276
+ *
277
+ * @param file Handle to the file
278
+ * @param data Variable to store item read
279
+ * @param mode Size of each element, in bytes, to be read
280
+ * See BLOCK_* constants
281
+ *
282
+ * @return Number of elements read
283
+ */
284
+ native fread(file, &any:data, mode);
285
+
286
+ /**
287
+ * Reads binary data from a file.
288
+ *
289
+ * @param file Handle to the file
290
+ * @param data Array to store each item read
291
+ * @param blocks Number of items to read into the array
292
+ * @param mode Size of each element, in bytes, to be read
293
+ * Valid sizes are 1, 2, or 4. See BLOCK_* constants.
294
+ *
295
+ * @return Number of elements read
296
+ */
297
+ native fread_blocks(file, any:data[], blocks, mode);
298
+
299
+ /**
300
+ * Reads raw binary data from a file.
301
+ *
302
+ * @param file Handle to the file
303
+ * @param stream Array to store each item read
304
+ * @param blocksize Number of items to read into the array
305
+ * @param blocks Size of each element, in bytes. The data is read directly.
306
+ * That is, in 1 or 2-byte mode, the lower byte(s) in
307
+ * each cell are used directly, rather than performing
308
+ * any casts from a 4-byte number to a smaller number.
309
+ *
310
+ * @return Number of elements read
311
+ */
312
+ native fread_raw(file, any:stream[], blocksize, blocks);
313
+
314
+ /**
315
+ * Writes a single binary data to a file.
316
+ *
317
+ * @param file Handle to the file
318
+ * @param data Item to write
319
+ * @param mode Size of each item in the array in bytes
320
+ * Valid sizes are 1, 2, or 4. See BLOCK_* constants
321
+ *
322
+ * @return Number of elements written
323
+ */
324
+ native fwrite(file, any:data, mode);
325
+
326
+ /**
327
+ * Writes binary data to a file.
328
+ *
329
+ * @param file Handle to the file
330
+ * @param data Array of items to write
331
+ * @param blocks Number of items in the array
332
+ * @param mode Size of each item in the array in bytes
333
+ * Valid sizes are 1, 2, or 4. See BLOCK_* constants
334
+ *
335
+ * @return Number of elements written
336
+ */
337
+ native fwrite_blocks(file, const any:data[], blocks, mode);
338
+
339
+ /**
340
+ * Writes raw binary data to a file.
341
+ *
342
+ * @param file Handle to the file.
343
+ * @param stream Array of items to write. The data is written directly.
344
+ * That is, in 1 or 2-byte mode, the lower byte(s) in
345
+ * each cell are used directly, rather than performing
346
+ * any casts from a 4-byte number to a smaller number.
347
+ * @param blocks Size of each item in the array in bytes.
348
+ * @param mode Number of items in the array.
349
+ *
350
+ * @return Number of elements written
351
+ */
352
+ native fwrite_raw(file, const any:stream[], blocks, mode);
353
+
354
+ /**
355
+ * Tests if the end of file has been reached.
356
+ *
357
+ * @param file Handle to the file
358
+ *
359
+ * @return 1 if end of file has been reached, 0 otherwise.
360
+ */
361
+ native feof(file);
362
+
363
+ /**
364
+ * Reads a line from a text file.
365
+ *
366
+ * @param file Handle to the file.
367
+ * @param buffer String buffer to hold the line
368
+ * @param maxlength Maximum size of string buffer
369
+ *
370
+ * @return Total number of characters written on success, 0 otherwise
371
+ */
372
+ native fgets(file, buffer[], maxlength);
373
+
374
+ /**
375
+ * Writes a line of text to a text file.
376
+ *
377
+ * @param file Handle to the file
378
+ * @param text String to write
379
+ * @param null_term True to append NULL terminator, false otherwise
380
+ *
381
+ * @return 0 on success, -1 otherwise
382
+ */
383
+ native fputs(file, const text[], bool:null_term = false);
384
+
385
+ /**
386
+ * Writes a line of formatted text to a text file.
387
+ *
388
+ * @param file Handle to the file
389
+ * @param format Formatting rules
390
+ * @param ... Variable number of format parameters
391
+ *
392
+ * @return Total number of characters written on success, 0 otherwise
393
+ */
394
+ native fprintf(file, const fmt[], any:...);
395
+
396
+ /**
397
+ * Sets the file position indicator.
398
+ *
399
+ * @param file Handle to the file
400
+ * @param position Position relative to what is specified in whence
401
+ * @param start SEEK_ constant value of where to see from
402
+ *
403
+ * @return 0 on success, a non-zero value otherwise
404
+ */
405
+ native fseek(file, position, start);
406
+
407
+ /**
408
+ * Gets current position in the file.
409
+ *
410
+ * @param file Handle to the file
411
+ *
412
+ * @return Value for the file position indicator
413
+ */
414
+ native ftell(file);
415
+
416
+ /**
417
+ * Gets character from file.
418
+ *
419
+ * @param file Handle to the file
420
+ *
421
+ * @return Character read on success, -1 otherwise
422
+ */
423
+ native fgetc(file);
424
+
425
+ /**
426
+ * Writes character to file
427
+ *
428
+ * @param file Handle to the file
429
+ * @param data Character to put
430
+ *
431
+ * @return Character written on success, -1 otherwise
432
+ */
433
+ native fputc(file, data);
434
+
435
+ /**
436
+ * Ungets character from file.
437
+ *
438
+ * @param file Handle to the file
439
+ * @param data Character to unget
440
+ *
441
+ * @return On success, the character put back is returned, -1 otherwise
442
+ */
443
+ native fungetc(file, data);
444
+
445
+ /**
446
+ * Flushes a buffered output stream.
447
+ *
448
+ * @param file File handle, or 0 for all open streams
449
+ *
450
+ * @return 0 on success, -1 on failure
451
+ */
452
+ native fflush(file);
453
+
454
+ /**
455
+ * Gets the formatted file size in bytes.
456
+ *
457
+ * @param filename Path to the file
458
+ * @param ... Variable number of format parameters
459
+ *
460
+ * @return File size in bytes, otherwise -1 if file not found
461
+ */
462
+ native filesize(const filename[], any:...);
463
+
464
+ /**
465
+ * Removes a directory.
466
+ *
467
+ * @note On most Operating Systems you cannot remove a directory which has files inside it.
468
+ *
469
+ * @param path Path to the directory
470
+ *
471
+ * @return 1 on success, 0 otherwise
472
+ */
473
+ native rmdir(const path[]);
474
+
475
+ /**
476
+ * Creates a directory.
477
+ *
478
+ * @param path Path to create
479
+ * @param mode Permissions (default is o=rx,g=rx,u=rwx). Note that folders must have
480
+ * the execute bit set on Linux. On Windows, the mode is ignored.
481
+ * @param use_valve_fs If true, the Valve file system will be used instead
482
+ * This can be used to create folders in the game's
483
+ * Valve search paths, rather than directly in the gamedir.
484
+ * @param valve_path_id If use_valve_fs, a search path from gameinfo or NULL_STRING for default
485
+ * In this case, mode is ignored
486
+ *
487
+ * @return 0 on success, -1 otherwise
488
+ */
489
+ native mkdir(const dirname[], mode = FPERM_DIR_DEFAULT, bool:use_valve_fs = false, const valve_path_id[] = "GAMECONFIG");
490
+
491
+ /**
492
+ * Deletes a file (delete_file macro)
493
+ *
494
+ * @param filename Path of the file to delete
495
+ * @param use_valve_fs If true, the Valve file system will be used instead.
496
+ * This can be used to delete files existing in the Valve
497
+ * search path, rather than solely files existing directly
498
+ * in the gamedir.
499
+ * @param valve_path_id If use_valve_fs, a search path from gameinfo or NULL_STRING for all search paths
500
+ *
501
+ * @return 1 on success, 0 on failure or if file not immediately removed
502
+ */
503
+ native unlink(const filename[], bool:use_valve_fs = false, const valve_path_id[] = "GAMECONFIG");
504
+
505
+ /**
506
+ * Opens a directory/folder for contents enumeration.
507
+ *
508
+ * @note Directories are closed with close_dir().
509
+ *
510
+ * @param dir Path to open.
511
+ * @param firstfile String buffer to hold first file name
512
+ * @param length Maximum size of the string buffer
513
+ * @param type Optional variable to store the file type
514
+ * @param use_valve_fs If true, the Valve file system will be used instead.
515
+ * This can be used to find files existing in any of
516
+ * the Valve search paths, rather than solely files
517
+ * existing directly in the gamedir.
518
+ * @param valve_path_id If use_valve_fs, a search path from gameinfo or NULL_STRING for all search paths.
519
+ *
520
+ * @return Handle to the directory, 0 otherwise
521
+ */
522
+ native open_dir(const dir[], firstfile[], length, &FileType:type = FileType_Unknown, bool:use_valve_fs = false, const valve_path_id[] = "GAME");
523
+
524
+ /**
525
+ * Reads the next directory entry as a local filename.
526
+ *
527
+ * @note Contents of buffers are undefined when returning false.
528
+ * @note Both the '.' and '..' automatic directory entries will be retrieved for Windows and Linux.
529
+ *
530
+ * @param dirh Handle to a directory
531
+ * @param buffer String buffer to hold directory name
532
+ * @param length Maximum size of string buffer
533
+ * @param type Optional variable to store the file type. FileType_* constants
534
+ *
535
+ * @return 1 on success, 0 if there are no more files to read.
536
+ */
537
+ native next_file(dirh, buffer[], length, &FileType:type = FileType_Unknown);
538
+
539
+ /**
540
+ * Closes the directory.
541
+ *
542
+ * @param dirh Handle to a directory
543
+ */
544
+ native close_dir(dirh);
545
+
546
+ /**
547
+ * Loads a file using the LoadFileForMe engine function.
548
+ *
549
+ * The data is truncated if there is not enough space. No null-terminator
550
+ * is applied; the data is the raw contents of the file.
551
+ *
552
+ * @param file File to load (may be a file from the GCF)
553
+ * @param buffer Buffer to store file contents
554
+ * @param maxlength Maximum size of the file buffer
555
+ * @param length Variable to store the file length. This may return
556
+ * a number larger than the buffer size
557
+ * @return -1 if the file could not be loaded. Otherwise,
558
+ * the number of cells actually written to the buffer
559
+ * are returned.
560
+ */
561
+ native LoadFileForMe(const file[], buffer[], maxlength, &length = 0);
562
+
563
+ /**
564
+ * Returns a file timestamp as a unix timestamp.
565
+ *
566
+ * @param file File name
567
+ * @param tmode Time mode, see FileTime_* constants
568
+ *
569
+ * @return Returns a file timestamp as a unix timestamp
570
+ */
571
+ native GetFileTime(const file[], FileTimeType:tmode);
572
+
573
+ /**
574
+ * Changes a file or directories permissions.
575
+ *
576
+ * @param path Path to the file
577
+ * @param mode Permissions to set, see FPERM_* constants
578
+ *
579
+ * @return True on success, false otherwise
580
+ */
581
+ native bool:SetFilePermissions(const path[], mode);
582
+
583
+ /**
584
+ * Reads a single int8 (byte) from a file. The returned value is sign-
585
+ * extended to an int32.
586
+ *
587
+ * @param file Handle to the file
588
+ * @param data Variable to store the data read
589
+ *
590
+ * @return True on success, false on failure
591
+ */
592
+ native bool:FileReadInt8(file, &any:data);
593
+
594
+ /**
595
+ * Reads a single uint8 (unsigned byte) from a file. The returned value is
596
+ * zero-extended to an int32.
597
+ *
598
+ * @param file Handle to the file
599
+ * @param data Variable to store the data read
600
+ *
601
+ * @return True on success, false on failure
602
+ */
603
+ native bool:FileReadUint8(file, &any:data);
604
+
605
+ /**
606
+ * Reads a single int16 (short) from a file. The value is sign-extended to
607
+ * an int32.
608
+ *
609
+ * @param file Handle to the file
610
+ * @param data Variable to store the data read
611
+ *
612
+ * @return True on success, false on failure
613
+ */
614
+ native bool:FileReadInt16(file, &any:data);
615
+
616
+ /**
617
+ * Reads a single unt16 (unsigned short) from a file. The value is zero-
618
+ * extended to an int32.
619
+ *
620
+ * @param file Handle to the file
621
+ * @param data Variable to store the data read
622
+ *
623
+ * @return True on success, false on failure
624
+ */
625
+ native bool:FileReadUint16(file, &any:data);
626
+
627
+ /**
628
+ * Reads a single int32 (int/cell) from a file.
629
+ *
630
+ * @param file Handle to the file
631
+ * @param data Variable to store the data read
632
+ *
633
+ * @return True on success, false on failure
634
+ */
635
+ native bool:FileReadInt32(file, &any:data);
636
+
637
+ /**
638
+ * Writes a single int8 (byte) to a file.
639
+ *
640
+ * @param file Handle to the file
641
+ * @param data Data to write (truncated to an int8)
642
+ *
643
+ * @return True on success, false on failure
644
+ */
645
+ native bool:FileWriteInt8(file, any:data);
646
+
647
+ /**
648
+ * Writes a single int16 (short) to a file.
649
+ *
650
+ * @param file Handle to the file
651
+ * @param data Data to write (truncated to an int16)
652
+ *
653
+ * @return True on success, false on failure
654
+ */
655
+ native bool:FileWriteInt16(file, any:data);
656
+
657
+ /**
658
+ * Writes a single int32 (int/cell) to a file.
659
+ *
660
+ * @param file Handle to the file
661
+ * @param data Data to write
662
+ *
663
+ * @return True on success, false on failure
664
+ */
665
+ native bool:FileWriteInt32(file, any:data);
666
+