@@ -192,6 +192,7 @@ File* FileSystem::openFile( const Char *filename, Int access, size_t bufferSize
192192#if ENABLE_FILESYSTEM_EXISTENCE_CACHE
193193 if (file != NULL && (file->getAccess () & File::CREATE))
194194 {
195+ FastCriticalSectionClass::LockClass lock (m_fileExistMutex);
195196 FileExistMap::iterator it = m_fileExist.find (FileExistMap::key_type::temporary (filename));
196197 if (it != m_fileExist.end ())
197198 {
@@ -227,6 +228,7 @@ Bool FileSystem::doesFileExist(const Char *filename, FileInstance instance) cons
227228
228229#if ENABLE_FILESYSTEM_EXISTENCE_CACHE
229230 {
231+ FastCriticalSectionClass::LockClass lock (m_fileExistMutex);
230232 FileExistMap::const_iterator it = m_fileExist.find (FileExistMap::key_type::temporary (filename));
231233 if (it != m_fileExist.end ())
232234 {
@@ -244,7 +246,10 @@ Bool FileSystem::doesFileExist(const Char *filename, FileInstance instance) cons
244246 if (instance == 0 )
245247 {
246248#if ENABLE_FILESYSTEM_EXISTENCE_CACHE
247- m_fileExist[filename];
249+ {
250+ FastCriticalSectionClass::LockClass lock (m_fileExistMutex);
251+ m_fileExist[filename];
252+ }
248253#endif
249254 return TRUE ;
250255 }
@@ -255,15 +260,21 @@ Bool FileSystem::doesFileExist(const Char *filename, FileInstance instance) cons
255260 if (TheArchiveFileSystem->doesFileExist (filename, instance))
256261 {
257262#if ENABLE_FILESYSTEM_EXISTENCE_CACHE
258- FileExistMap::mapped_type& value = m_fileExist[filename];
259- value.instanceExists = max (value.instanceExists , instance);
263+ {
264+ FastCriticalSectionClass::LockClass lock (m_fileExistMutex);
265+ FileExistMap::mapped_type& value = m_fileExist[filename];
266+ value.instanceExists = max (value.instanceExists , instance);
267+ }
260268#endif
261269 return TRUE ;
262270 }
263271
264272#if ENABLE_FILESYSTEM_EXISTENCE_CACHE
265- FileExistMap::mapped_type& value = m_fileExist[filename];
266- value.instanceDoesNotExist = min (value.instanceDoesNotExist , instance);
273+ {
274+ FastCriticalSectionClass::LockClass lock (m_fileExistMutex);
275+ FileExistMap::mapped_type& value = m_fileExist[filename];
276+ value.instanceDoesNotExist = min (value.instanceDoesNotExist , instance);
277+ }
267278#endif
268279 return FALSE ;
269280}
0 commit comments