diff --git a/lib/irrlicht/include/IFileSystem.h b/lib/irrlicht/include/IFileSystem.h index 497b6b71d..82b595f2a 100644 --- a/lib/irrlicht/include/IFileSystem.h +++ b/lib/irrlicht/include/IFileSystem.h @@ -324,6 +324,11 @@ public: \return True if file exists, and false if it does not exist or an error occured. */ virtual bool existFile(const path& filename) const =0; + //! Determines if a file exists and could be opened (thread-safe, ignore file archives). + /** \param filename is the string identifying the file which should be tested for existence. + \return True if file exists, and false if it does not exist or an error occured. */ + virtual bool existFileThreadSafe(const path& filename) const =0; + //! Creates a XML Reader from a file which returns all parsed strings as wide characters (wchar_t*). /** Use createXMLReaderUTF8() if you prefer char* instead of wchar_t*. See IIrrXMLReader for more information on how to use the parser. diff --git a/lib/irrlicht/source/Irrlicht/CFileSystem.cpp b/lib/irrlicht/source/Irrlicht/CFileSystem.cpp index fa5fcc5d0..c30b25e93 100644 --- a/lib/irrlicht/source/Irrlicht/CFileSystem.cpp +++ b/lib/irrlicht/source/Irrlicht/CFileSystem.cpp @@ -943,13 +943,9 @@ IFileList* CFileSystem::createEmptyFileList(const io::path& path, bool ignoreCas } -//! determines if a file exists and would be able to be opened. -bool CFileSystem::existFile(const io::path& filename) const +//! Determines if a file exists and could be opened (thread-safe, ignore file archives). +bool CFileSystem::existFileThreadSafe(const path& filename) const { - for (u32 i=0; i < FileArchives.size(); ++i) - if (FileArchives[i]->getFileList()->findFile(filename)!=-1) - return true; - #if defined(_IRR_WINDOWS_CE_PLATFORM_) #if defined(_IRR_WCHAR_FILESYSTEM) HANDLE hFile = CreateFileW(filename.c_str(), GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, 0, NULL); @@ -986,6 +982,16 @@ bool CFileSystem::existFile(const io::path& filename) const } +//! determines if a file exists and would be able to be opened. +bool CFileSystem::existFile(const io::path& filename) const +{ + for (u32 i=0; i < FileArchives.size(); ++i) + if (FileArchives[i]->getFileList()->findFile(filename)!=-1) + return true; + return existFileThreadSafe(filename); +} + + //! Creates a XML Reader from a file. IXMLReader* CFileSystem::createXMLReader(const io::path& filename) { diff --git a/lib/irrlicht/source/Irrlicht/CFileSystem.h b/lib/irrlicht/source/Irrlicht/CFileSystem.h index 787864c64..a935bc7ab 100644 --- a/lib/irrlicht/source/Irrlicht/CFileSystem.h +++ b/lib/irrlicht/source/Irrlicht/CFileSystem.h @@ -133,6 +133,9 @@ public: //! determines if a file exists and would be able to be opened. virtual bool existFile(const io::path& filename) const; + //! Determines if a file exists and could be opened (thread-safe, ignore file archives). + virtual bool existFileThreadSafe(const path& filename) const; + //! Creates a XML Reader from a file. virtual IXMLReader* createXMLReader(const io::path& filename);