diff --git a/include/dos_inc.h b/include/dos_inc.h index 1fb88330..be86aea8 100644 --- a/include/dos_inc.h +++ b/include/dos_inc.h @@ -98,6 +98,7 @@ bool DOS_SeekFile(Bit16u handle,Bit32u * pos,Bit32u type); bool DOS_CloseFile(Bit16u handle); bool DOS_DuplicateEntry(Bit16u entry,Bit16u * newentry); bool DOS_ForceDuplicateEntry(Bit16u entry,Bit16u newentry); +bool DOS_GetFileDate(Bit16u entry, Bit16u* otime, Bit16u* odate); /* Routines for Drive Class */ bool DOS_OpenFile(char * name,Bit8u flags,Bit16u * entry); diff --git a/src/dos/dos.cpp b/src/dos/dos.cpp index 13c66fd7..a1895934 100644 --- a/src/dos/dos.cpp +++ b/src/dos/dos.cpp @@ -670,9 +670,17 @@ static Bitu DOS_21Handler(void) { } break; case 0x57: /* Get/Set File's Date and Time */ - reg_cx=0; - reg_dx=0; - LOG_DEBUG("DOS:57:Getting/Setting File Date is faked",reg_ah); + if (reg_al==0x00) { + if (DOS_GetFileDate(reg_bx,®_cx,®_dx)) { + CALLBACK_SCF(false); + } else { + CALLBACK_SCF(true); + }; + } else { + reg_cx=0; + reg_dx=0; + LOG_DEBUG("DOS:57:Setting File Date is faked",reg_ah); + } break; case 0x58: /* Get/Set Memory allocation strategy */ switch (reg_al) { diff --git a/src/dos/dos_files.cpp b/src/dos/dos_files.cpp index 3b9a93cf..4949fa45 100644 --- a/src/dos/dos_files.cpp +++ b/src/dos/dos_files.cpp @@ -816,6 +816,32 @@ bool DOS_SetDrive(Bit8u drive) { } }; +bool DOS_GetFileDate(Bit16u entry, Bit16u* otime, Bit16u* odate) +{ + Bit32u handle=RealHandle(entry); + if (handle>=DOS_FILES) { + DOS_SetError(DOSERR_INVALID_HANDLE); + return false; + }; + if (!Files[handle]) { + DOS_SetError(DOSERR_INVALID_HANDLE); + return false; + }; + struct stat stat_block; + if (fstat(handle, &stat_block)!=0) { + DOS_SetError(DOSERR_INVALID_HANDLE); + return false; + } + struct tm *time; + if ((time=localtime(&stat_block.st_mtime))!=0) { + *otime = (time->tm_hour<<11)+(time->tm_min<<5)+(time->tm_sec/2); /* standard way. */ + *odate = ((time->tm_year-80)<<9)+((time->tm_mon+1)<<5)+(time->tm_mday); + } else { + *otime = 6; + *odate = 4; + } + return true; +}; void DOS_SetupFiles (void) { /* Setup the File Handles */