SVN r4369

Compatible side-effect behavior of DOS in the file close function.
This commit is contained in:
Allofich
2020-10-03 18:40:49 +09:00
parent 254c8dde3f
commit 8e502d57ad
3 changed files with 7 additions and 5 deletions

View File

@@ -168,7 +168,7 @@ bool DOS_WriteFile(uint16_t entry,uint8_t * data,uint16_t * amount,bool fcb = fa
bool DOS_SeekFile(uint16_t entry,uint32_t * pos,uint32_t type,bool fcb = false);
/* ert, 20100711: Locking extensions */
bool DOS_LockFile(uint16_t entry,uint8_t mode,uint32_t pos,uint32_t size);
bool DOS_CloseFile(uint16_t entry,bool fcb = false);
bool DOS_CloseFile(uint16_t entry,bool fcb = false,uint8_t * refcnt = NULL);
bool DOS_FlushFile(uint16_t entry);
bool DOS_DuplicateEntry(uint16_t entry,uint16_t * newentry);
bool DOS_ForceDuplicateEntry(uint16_t entry,uint16_t newentry);

View File

@@ -1371,8 +1371,8 @@ static Bitu DOS_21Handler(void) {
}
case 0x3e: /* CLOSE Close file */
unmask_irq0 |= disk_io_unmask_irq0;
if (DOS_CloseFile(reg_bx)) {
// reg_al=0x01; /* al destroyed. Refcount */
if (DOS_CloseFile(reg_bx, false, &reg_al)) {
/* al destroyed with pre-close refcount from sft */
CALLBACK_SCF(false);
} else {
reg_ax=dos.errorcode;

View File

@@ -624,7 +624,7 @@ bool DOS_LockFile(uint16_t entry,uint8_t mode,uint32_t pos,uint32_t size) {
#endif
}
bool DOS_CloseFile(uint16_t entry, bool fcb) {
bool DOS_CloseFile(uint16_t entry, bool fcb, uint8_t * refcnt) {
#if defined(WIN32) && !defined(__MINGW32__)
if(Network_IsActiveResource(entry))
return Network_CloseFile(entry);
@@ -648,10 +648,12 @@ bool DOS_CloseFile(uint16_t entry, bool fcb) {
DOS_PSP psp(dos.psp());
if (!fcb) psp.SetFileHandle(entry,0xff);
if (Files[handle]->RemoveRef()<=0) {
Bits refs=Files[handle]->RemoveRef();
if (refs<=0) {
delete Files[handle];
Files[handle]=0;
}
if (refcnt!=NULL) *refcnt=static_cast<uint8_t>(refs+1);
return true;
}