diff --git a/src/dos/drive_local.cpp b/src/dos/drive_local.cpp index f92e666f..1af3ddc9 100644 --- a/src/dos/drive_local.cpp +++ b/src/dos/drive_local.cpp @@ -41,6 +41,7 @@ public: Bit16u GetInformation(void); bool UpdateDateTimeFromHost(void); void FlagReadOnlyMedium(void); + void Flush(void); private: FILE * fhandle; bool read_only_medium; @@ -95,6 +96,22 @@ bool localDrive::FileOpen(DOS_File * * file,char * name,Bit32u flags) { CROSS_FILENAME(newname); dirCache.ExpandName(newname); + //Flush the buffer of handles for the same file. (Betrayal in Antara) + Bit8u i,drive=DOS_DRIVES; + localFile *lfp; + for (i=0;iIsOpen() && Files[i]->GetDrive()==drive && Files[i]->IsName(name)) { + lfp=dynamic_cast(Files[i]); + if (lfp) lfp->Flush(); + } + } + FILE * hand=fopen(newname,type); // Bit32u err=errno; if (!hand) { @@ -541,6 +558,13 @@ bool localFile::UpdateDateTimeFromHost(void) { return true; } +void localFile::Flush(void) { + if (last_action==WRITE) { + fseek(fhandle,ftell(fhandle),SEEK_SET); + last_action=NONE; + } +} + // ******************************************** // CDROM DRIVE