From f50509abf0ce94155e99634ca318d0f12ca43f92 Mon Sep 17 00:00:00 2001 From: David Anderson Date: Tue, 22 Jan 2008 17:04:59 +0000 Subject: [PATCH] added amb1378 - FileExists() for valve fs --HG-- extra : convert_revision : svn%3A39bc706e-5318-0410-9160-8a85361fbb7c/trunk%401860 --- core/smn_filesystem.cpp | 5 +++++ plugins/include/files.inc | 6 +++++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/core/smn_filesystem.cpp b/core/smn_filesystem.cpp index eeec4886..124371a4 100644 --- a/core/smn_filesystem.cpp +++ b/core/smn_filesystem.cpp @@ -288,6 +288,11 @@ static cell_t sm_FileExists(IPluginContext *pContext, const cell_t *params) return 0; } + if (params[0] >= 2 && params[2] == 1) + { + return basefilesystem->FileExists(name) ? 1 : 0; + } + char realpath[PLATFORM_MAX_PATH]; g_SourceMod.BuildPath(Path_Game, realpath, sizeof(realpath), "%s", name); #ifdef PLATFORM_WINDOWS diff --git a/plugins/include/files.inc b/plugins/include/files.inc index e8767e66..20f3424c 100644 --- a/plugins/include/files.inc +++ b/plugins/include/files.inc @@ -302,9 +302,13 @@ native 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 check for the existance of files + * inside GCFs or the game cache, rather than solely files + * that are on disk. * @return True if the file exists, false otherwise. */ -native bool:FileExists(const String:path[]); +native bool:FileExists(const String:path[], bool:use_valve_fs=false); /** * Renames a file.