Skip to content

Commit 73a9dcf

Browse files
committed
Fix file existence cache when creating new file
1 parent 321e662 commit 73a9dcf

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

Core/GameEngine/Source/Common/System/FileSystem.cpp

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -192,9 +192,17 @@ 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-
FileExistMap::mapped_type& value = m_fileExist[filename];
196-
value.instanceExists = max(value.instanceExists, instance);
197-
value.instanceDoesNotExist = max(value.instanceDoesNotExist, instance + 1);
195+
FileExistMap::iterator it = m_fileExist.find(FileExistMap::key_type::temporary(filename));
196+
if (it != m_fileExist.end())
197+
{
198+
++it->second.instanceExists;
199+
if (it->second.instanceDoesNotExist != ~0u)
200+
++it->second.instanceDoesNotExist;
201+
}
202+
else
203+
{
204+
m_fileExist.insert(it, std::make_pair(rts::string_key<AsciiString>(filename), FileExistData()));
205+
}
198206
}
199207
#endif
200208
}

0 commit comments

Comments
 (0)