1
0
Fork 0

fixed Localfile::write to truncate the file when zero data is written

Imported-from: https://svn.code.sf.net/p/dosbox/code-0/dosbox/trunk@116
This commit is contained in:
Peter Veenstra 2002-08-07 10:23:35 +00:00
parent 5473800c32
commit 6931e8fa41

View file

@ -265,10 +265,15 @@ bool localFile::Read(Bit8u * data,Bit16u * size) {
};
bool localFile::Write(Bit8u * data,Bit16u * size) {
*size=fwrite(data,1,*size,fhandle);
if(*size==0){
return (!ftruncate(fileno(fhandle),ftell(fhandle)));
}
else
{
*size=fwrite(data,1,*size,fhandle);
return true;
}
}
bool localFile::Seek(Bit32u * pos,Bit32u type) {
int seektype;
switch (type) {