diff --git a/source/graphics/ColladaManager.cpp b/source/graphics/ColladaManager.cpp index 8ae823757e..9bb8dae918 100644 --- a/source/graphics/ColladaManager.cpp +++ b/source/graphics/ColladaManager.cpp @@ -204,7 +204,7 @@ VfsPath CColladaManager::GetLoadableFilename(const VfsPath& pathnameNoExtension, // be "psa" too.) VfsPath dae(fs::change_extension(pathnameNoExtension, L".dae")); - if (! FileExists(dae)) + if (! VfsFileExists(dae)) { // No .dae - got to use the .pmd, assuming there is one return fs::change_extension(pathnameNoExtension, extn); @@ -252,7 +252,7 @@ VfsPath CColladaManager::GetLoadableFilename(const VfsPath& pathnameNoExtension, cachedPmdVfsPath = fs::change_extension(cachedPmdVfsPath, extension); // If it's not in the cache, we'll have to create it first - if (! FileExists(cachedPmdVfsPath)) + if (! VfsFileExists(cachedPmdVfsPath)) { if (! m->Convert(dae, cachedPmdVfsPath, type)) return L""; // failed to convert diff --git a/source/graphics/MapReader.cpp b/source/graphics/MapReader.cpp index d8c8c24543..f90ec00313 100644 --- a/source/graphics/MapReader.cpp +++ b/source/graphics/MapReader.cpp @@ -77,7 +77,7 @@ void CMapReader::LoadMap(const VfsPath& pathname, CTerrain *pTerrain_, // mostly-empty .pmp file, so we let the XML file specify basic terrain instead. // If there's an .xml file and no .pmp, then we're probably in this XML-only mode only_xml = false; - if (!FileExists(pathname) && FileExists(filename_xml)) + if (!VfsFileExists(pathname) && VfsFileExists(filename_xml)) { only_xml = true; } diff --git a/source/graphics/TerrainTextureManager.cpp b/source/graphics/TerrainTextureManager.cpp index 31ada4872e..db04762095 100644 --- a/source/graphics/TerrainTextureManager.cpp +++ b/source/graphics/TerrainTextureManager.cpp @@ -146,7 +146,7 @@ void CTerrainTextureManager::LoadTextures(const CTerrainPropertiesPtr& props, co VfsPath pathnameXML = fs::change_extension(pathnames[i], L".xml"); CTerrainPropertiesPtr myprops; // Has XML file -> attempt to load properties - if (FileExists(pathnameXML)) + if (VfsFileExists(pathnameXML)) { myprops = GetPropertiesFromFile(props, pathnameXML); if (myprops) @@ -169,7 +169,7 @@ void CTerrainTextureManager::RecurseDirectory(const CTerrainPropertiesPtr& paren // Load terrains.xml first, if it exists VfsPath pathname = path/L"terrains.xml"; - if (FileExists(pathname)) + if (VfsFileExists(pathname)) props = GetPropertiesFromFile(parentProps, pathname); // No terrains.xml, or read failures -> use parent props (i.e. diff --git a/source/ps/CConsole.cpp b/source/ps/CConsole.cpp index e05acc961f..b7c30886dc 100644 --- a/source/ps/CConsole.cpp +++ b/source/ps/CConsole.cpp @@ -615,7 +615,7 @@ void CConsole::LoadHistory() // just don't load anything in that case. // do this before LoadFile to avoid an error message if file not found. - if (!FileExists(m_sHistoryFile)) + if (!VfsFileExists(m_sHistoryFile)) return; shared_ptr buf; size_t buflen; diff --git a/source/ps/FileIo.cpp b/source/ps/FileIo.cpp index 7b246300fb..8eb8d1dab7 100644 --- a/source/ps/FileIo.cpp +++ b/source/ps/FileIo.cpp @@ -109,7 +109,7 @@ void CFileUnpacker::Read(const VfsPath& filename, const char magic[4]) // since this (unfortunately) happens so often, we perform a separate // check and "just" raise an exception for the caller to handle. // (this is nicer than somehow squelching internal VFS error reporting) - if(!FileExists(filename)) + if(!VfsFileExists(filename)) throw PSERROR_File_OpenFailed(); // load the whole thing into memory diff --git a/source/ps/Filesystem.cpp b/source/ps/Filesystem.cpp index 716687f986..062e5ca7c5 100644 --- a/source/ps/Filesystem.cpp +++ b/source/ps/Filesystem.cpp @@ -29,14 +29,14 @@ PIVFS g_VFS; static std::vector > g_ReloadFuncs; -bool FileExists(const PIVFS& vfs, const VfsPath& pathname) +bool VfsFileExists(const PIVFS& vfs, const VfsPath& pathname) { return vfs->GetFileInfo(pathname, 0) == INFO::OK; } -bool FileExists(const VfsPath& pathname) +bool VfsFileExists(const VfsPath& pathname) { - return FileExists(g_VFS, pathname); + return VfsFileExists(g_VFS, pathname); } void RegisterFileReloadFunc(FileReloadFunc func, void* obj) diff --git a/source/ps/Filesystem.h b/source/ps/Filesystem.h index 29a9f9b343..374b1a1995 100644 --- a/source/ps/Filesystem.h +++ b/source/ps/Filesystem.h @@ -30,9 +30,9 @@ extern PIVFS g_VFS; -extern bool FileExists(const PIVFS& vfs, const VfsPath& pathname); +extern bool VfsFileExists(const PIVFS& vfs, const VfsPath& pathname); -extern bool FileExists(const VfsPath& pathname); +extern bool VfsFileExists(const VfsPath& pathname); /** * callback function type for file change notifications diff --git a/source/scriptinterface/ScriptInterface.cpp b/source/scriptinterface/ScriptInterface.cpp index fb3239541c..b290aa1aa0 100644 --- a/source/scriptinterface/ScriptInterface.cpp +++ b/source/scriptinterface/ScriptInterface.cpp @@ -741,7 +741,7 @@ bool ScriptInterface::LoadScript(const std::wstring& filename, const std::wstrin bool ScriptInterface::LoadGlobalScriptFile(const VfsPath& path) { - if (!FileExists(g_VFS, path)) + if (!VfsFileExists(g_VFS, path)) { LOGERROR(L"File '%ls' does not exist", path.string().c_str()); return false; @@ -826,7 +826,7 @@ CScriptValRooted ScriptInterface::ParseJSON(const std::string& string_utf8) CScriptValRooted ScriptInterface::ReadJSONFile(const VfsPath& path) { - if (!FileExists(g_VFS, path)) + if (!VfsFileExists(g_VFS, path)) { LOGERROR(L"File '%ls' does not exist", path.string().c_str()); return CScriptValRooted(); @@ -900,7 +900,7 @@ std::wstring ScriptInterface::ToString(jsval obj, bool pretty) // Temporary disable the error reporter, so we don't print complaints about cyclic values JSErrorReporter er = JS_SetErrorReporter(m->m_cx, NULL); - bool ok = JS_Stringify(m->m_cx, &obj, NULL, INT_TO_JSVAL(2), &StringifierW::callback, &str); + bool ok = JS_Stringify(m->m_cx, &obj, NULL, INT_TO_JSVAL(2), &StringifierW::callback, &str) == JS_TRUE; // Restore error reporter JS_SetErrorReporter(m->m_cx, er); diff --git a/source/simulation2/Simulation2.cpp b/source/simulation2/Simulation2.cpp index 4b764183c0..0775ec1913 100644 --- a/source/simulation2/Simulation2.cpp +++ b/source/simulation2/Simulation2.cpp @@ -167,7 +167,7 @@ LibError CSimulation2Impl::ReloadChangedFile(const VfsPath& path) // If the file doesn't exist (e.g. it was deleted), don't bother loading it since that'll give an error message. // (Also don't bother trying to 'unload' it from the component manager, because that's not possible) - if (!FileExists(path)) + if (!VfsFileExists(path)) return INFO::OK; LOGMESSAGE(L"Reloading simulation script '%ls'", filename.c_str()); diff --git a/source/simulation2/components/tests/test_scripts.h b/source/simulation2/components/tests/test_scripts.h index 406e0697c9..5bbe2b4256 100644 --- a/source/simulation2/components/tests/test_scripts.h +++ b/source/simulation2/components/tests/test_scripts.h @@ -59,7 +59,7 @@ public: void test_scripts() { - if (!FileExists(L"simulation/components/tests/setup.js")) + if (!VfsFileExists(L"simulation/components/tests/setup.js")) { debug_printf(L"WARNING: Skipping component scripts tests (can't find binaries/data/mods/public/simulation/components/tests/setup.js)\n"); return;