1
0
Fork 0

Support for INT 21 function 0x57 - DOS_GetFileDate

Imported-from: https://svn.code.sf.net/p/dosbox/code-0/dosbox/trunk@412
This commit is contained in:
Ulf Wohlers 2002-10-25 15:17:19 +00:00
parent ac29b40919
commit 9f1a42a3b9
3 changed files with 38 additions and 3 deletions

View file

@ -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);

View file

@ -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,&reg_cx,&reg_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) {

View file

@ -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 */