diff --git a/rts/Lua/LuaParser.cpp b/rts/Lua/LuaParser.cpp index b06d6a7f3cf..2e4b9d84dab 100644 --- a/rts/Lua/LuaParser.cpp +++ b/rts/Lua/LuaParser.cpp @@ -674,11 +674,14 @@ int LuaParser::FileExists(lua_State* L) const LuaParser* currentParser = GetLuaParser(L); const std::string& filename = luaL_checkstring(L, 1); + // filter any modes not within the parser's allowed set + const std::string& argModes = luaL_optstring(L, 2, currentParser->accessModes.c_str()); + const std::string& vfsModes = CFileHandler::AllowModes(argModes, currentParser->accessModes); if (!LuaIO::IsSimplePath(filename)) return 0; - lua_pushboolean(L, CFileHandler::FileExists(filename, currentParser->accessModes)); + lua_pushboolean(L, CFileHandler::FileExists(filename, vfsModes)); return 1; } diff --git a/rts/Lua/LuaVFS.cpp b/rts/Lua/LuaVFS.cpp index b2c5bd78495..bdd89c61e8d 100644 --- a/rts/Lua/LuaVFS.cpp +++ b/rts/Lua/LuaVFS.cpp @@ -239,26 +239,19 @@ int LuaVFS::UnsyncLoadFile(lua_State* L) int LuaVFS::FileExists(lua_State* L, bool synced) { const std::string& filename = luaL_checkstring(L, 1); + const std::string& vfsModes = GetModes(L, 2, synced); // FIXME: return 0, keep searches within the Spring directory // the path may point to a file or dir outside of any data-dir // if (!LuaIO::IsSimplePath(filename)) return 0; - lua_pushboolean(L, CFileHandler::FileExists(filename, GetModes(L, 2, synced))); + lua_pushboolean(L, CFileHandler::FileExists(filename, vfsModes)); return 1; } -int LuaVFS::SyncFileExists(lua_State* L) -{ - return FileExists(L, true); -} - - -int LuaVFS::UnsyncFileExists(lua_State* L) -{ - return FileExists(L, false); -} +int LuaVFS:: SyncFileExists(lua_State* L) { return FileExists(L, true); } +int LuaVFS::UnsyncFileExists(lua_State* L) { return FileExists(L, false); } /******************************************************************************/