From 6931e8fa410da4cfeb7a5e4fbcb95b8ad9541853 Mon Sep 17 00:00:00 2001 From: Peter Veenstra Date: Wed, 7 Aug 2002 10:23:35 +0000 Subject: [PATCH] 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 --- src/dos/drive_local.cpp | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/dos/drive_local.cpp b/src/dos/drive_local.cpp index 5b8882f0..a24ad9cc 100644 --- a/src/dos/drive_local.cpp +++ b/src/dos/drive_local.cpp @@ -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) {