--- xmil/win9x/dosio.cpp 2004/08/09 02:47:02 1.3 +++ xmil/win9x/dosio.cpp 2004/08/12 17:57:36 1.4 @@ -81,7 +81,7 @@ UINT __stdcall file_write(FILEH handle, return(0); } -short __stdcall file_close(FILEH handle) { +BRESULT __stdcall file_close(FILEH handle) { CloseHandle(handle); return(0); @@ -92,19 +92,52 @@ UINT __stdcall file_getsize(FILEH handle return(GetFileSize(handle, NULL)); } -short __stdcall file_delete(const OEMCHAR *path) { +static BRESULT cnvdatetime(FILETIME *file, DOSDATE *dosdate, DOSTIME *dostime) { - return(DeleteFile(path)?0:-1); + FILETIME localtime; + SYSTEMTIME systime; + + if ((FileTimeToLocalFileTime(file, &localtime) == 0) || + (FileTimeToSystemTime(&localtime, &systime) == 0)) { + return(FAILURE); + } + if (dosdate) { + dosdate->year = (UINT16)systime.wYear; + dosdate->month = (UINT8)systime.wMonth; + dosdate->day = (UINT8)systime.wDay; + } + if (dostime) { + dostime->hour = (UINT8)systime.wHour; + dostime->minute = (UINT8)systime.wMinute; + dostime->second = (UINT8)systime.wSecond; + } + return(SUCCESS); +} + +BRESULT __stdcall file_getdatetime(FILEH handle, DOSDATE *dosdate, DOSTIME *dostime) { + + FILETIME lastwrite; + + if ((GetFileTime(handle, NULL, NULL, &lastwrite) == 0) || + (cnvdatetime(&lastwrite, dosdate, dostime) != SUCCESS)) { + return(FAILURE); + } + return(SUCCESS); +} + +BRESULT __stdcall file_delete(const OEMCHAR *path) { + + return(DeleteFile(path)?SUCCESS:FAILURE); } -short __stdcall file_attr(const OEMCHAR *path) { +SINT16 __stdcall file_attr(const OEMCHAR *path) { - return((short)GetFileAttributes(path)); + return((SINT16)GetFileAttributes(path)); } -short __stdcall file_dircreate(const OEMCHAR *path) { +BRESULT __stdcall file_dircreate(const OEMCHAR *path) { - return(CreateDirectory(path, NULL)?0:-1); + return(CreateDirectory(path, NULL)?SUCCESS:FAILURE); } @@ -144,14 +177,14 @@ FILEH __stdcall file_create_c(const OEMC return(file_create(curpath)); } -short __stdcall file_delete_c(const OEMCHAR *path) { +BRESULT __stdcall file_delete_c(const OEMCHAR *path) { *curfilep = '\0'; file_catname(curpath, path, NELEMENTS(curpath)); return(file_delete(curpath)); } -short __stdcall file_attr_c(const OEMCHAR *path) { +SINT16 __stdcall file_attr_c(const OEMCHAR *path) { *curfilep = '\0'; file_catname(curpath, path, NELEMENTS(curpath));