Additional size check to avoid stuck empty string cache files, caused by exception handling

develop
kaetemi 4 years ago
parent bb564a6302
commit e20af7828a

@ -127,13 +127,16 @@ namespace STRING_MANAGER
nlinfo("SM : Try to open the string cache : %s", _CacheFilename.c_str());
if (CFile::fileExists(_CacheFilename))
if (CFile::fileExists(_CacheFilename) && CFile::getFileSize(_CacheFilename))
{
// there is a cache file, check date reset it if needed
{
NLMISC::CIFile file(_CacheFilename);
file.setVersionException(false, false);
file.serialVersion(currentVersion);
if (file.getPos() + sizeof(_Timestamp) > file.getFileSize())
_Timestamp = ~timestamp;
else
file.serial(_Timestamp);
}

Loading…
Cancel
Save