1
0
Fork 0
mirror of https://github.com/AquariaOSE/Aquaria.git synced 2025-10-07 06:41:38 +00:00

Fix problems with loading saves after saving over them.

This was caused by the VFS caching file sizes,
and not noticing that the file size had changed,
which confused zlib because the data stream ended too early.
This commit is contained in:
fgenesis 2012-06-14 17:54:40 +02:00
commit 8f2279e28a
4 changed files with 27 additions and 29 deletions

View file

@ -76,7 +76,7 @@ void VFSFile::dropBuf(bool del)
}
VFSFileReal::VFSFileReal(const char *name /* = NULL */)
: VFSFile(name), _fh(NULL), _size(npos), _buf(NULL)
: VFSFile(name), _fh(NULL), _buf(NULL)
{
}
@ -94,14 +94,8 @@ bool VFSFileReal::open(const char *mode /* = NULL */)
dropBuf(true);
_fh = real_fopen(fullname(), mode ? mode : "rb");
if(!_fh)
return false;
real_fseek((FILE*)_fh, 0, SEEK_END);
_size = getpos();
real_fseek((FILE*)_fh, 0, SEEK_SET);
return true;
return !!_fh;
}
bool VFSFileReal::isopen(void) const
@ -177,13 +171,7 @@ unsigned int VFSFileReal::write(const void *src, unsigned int bytes)
vfspos VFSFileReal::size(void)
{
VFS_GUARD_OPT(this);
if(_size != npos)
return _size;
open();
close();
// now size is known.
return _size;
return GetFileSize(fullname());
}
// ------------- VFSFileMem -----------------------