Add thread-safe existFile in IFileSystem
This commit is contained in:
parent
878f064ecf
commit
d6db020bfe
@ -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.
|
||||
|
@ -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)
|
||||
{
|
||||
|
@ -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);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user