1
0
Fork 0

Flush the buffer of handles for the same file. (Betrayal in Antara). Thanks ripsaw

Imported-from: https://svn.code.sf.net/p/dosbox/code-0/dosbox/trunk@3624
This commit is contained in:
Peter Veenstra 2010-07-24 21:18:11 +00:00
parent 72bf840408
commit 0af0da678c

View file

@ -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;i<DOS_DRIVES;i++) {
if (Drives[i]==this) {
drive=i;
break;
}
}
for (i=0;i<DOS_FILES;i++) {
if (Files[i] && Files[i]->IsOpen() && Files[i]->GetDrive()==drive && Files[i]->IsName(name)) {
lfp=dynamic_cast<localFile*>(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