Skip to content

Commit

Permalink
fix #6408
Browse files Browse the repository at this point in the history
  • Loading branch information
rtri committed Jul 19, 2020
1 parent 005147b commit fdd9ca6
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 12 deletions.
5 changes: 4 additions & 1 deletion rts/Lua/LuaParser.cpp
Expand Up @@ -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;
}

Expand Down
15 changes: 4 additions & 11 deletions rts/Lua/LuaVFS.cpp
Expand Up @@ -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); }


/******************************************************************************/
Expand Down

0 comments on commit fdd9ca6

Please sign in to comment.