diff --git a/core/logic/intercom.h b/core/logic/intercom.h index bb8fb9d2..00d6ed3e 100644 --- a/core/logic/intercom.h +++ b/core/logic/intercom.h @@ -51,7 +51,7 @@ using namespace SourceHook; * Add 1 to the RHS of this expression to bump the intercom file * This is to prevent mismatching core/logic binaries */ -#define SM_LOGIC_MAGIC (0x0F47C0DE - 26) +#define SM_LOGIC_MAGIC (0x0F47C0DE - 27) #if defined SM_LOGIC class IVEngineServer @@ -82,6 +82,7 @@ public: virtual char *ReadLine(char *pOutput, int maxChars, FileHandle_t file) = 0; virtual bool EndOfFile(FileHandle_t file) = 0; virtual bool FileExists(const char *pFileName, const char *pPathID = 0) = 0; + virtual unsigned int Size(const char *pFileName, const char *pPathID = 0) = 0; }; namespace SourceMod diff --git a/core/logic/smn_filesystem.cpp b/core/logic/smn_filesystem.cpp index 11f52093..26575acf 100644 --- a/core/logic/smn_filesystem.cpp +++ b/core/logic/smn_filesystem.cpp @@ -426,6 +426,18 @@ static cell_t sm_FileSize(IPluginContext *pContext, const cell_t *params) return -1; } + if (params[0] >= 2 && params[2] == 1) + { + if (smcore.filesystem->FileExists(name)) + { + return smcore.filesystem->Size(name); + } + else + { + return -1; + } + } + char realpath[PLATFORM_MAX_PATH]; g_pSM->BuildPath(Path_Game, realpath, sizeof(realpath), "%s", name); #ifdef PLATFORM_WINDOWS diff --git a/core/logic_bridge.cpp b/core/logic_bridge.cpp index a047943b..e386d55c 100644 --- a/core/logic_bridge.cpp +++ b/core/logic_bridge.cpp @@ -138,6 +138,10 @@ public: { return filesystem->FileExists(pFileName, pPathID); } + unsigned int Size(const char *pFileName, const char *pPathID = 0) + { + return filesystem->Size(pFileName, pPathID); + } }; static VFileSystem_Logic logic_filesystem; diff --git a/plugins/include/files.inc b/plugins/include/files.inc index ab9eaf70..4da32671 100644 --- a/plugins/include/files.inc +++ b/plugins/include/files.inc @@ -303,9 +303,9 @@ native FilePosition(Handle:file); * * @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 check for the existance of files - * inside GCFs or the game cache, rather than solely files - * that are on disk. + * This can be used to find files existing in any of + * the GAME search paths, rather than solely files + * existing directly in the gamedir. * @return True if the file exists, false otherwise. */ native bool:FileExists(const String:path[], bool:use_valve_fs=false); @@ -331,9 +331,13 @@ native bool:DirExists(const String:path[]); * 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 GAME search paths, rather than solely files + * existing directly in the gamedir. * @return File size in bytes, -1 if file not found. */ -native FileSize(const String:path[]); +native FileSize(const String:path[], bool:use_valve_fs=false); /** * Flushes a file's buffered output; any buffered output