/* * get and set file times, given a file descriptor (DOS) */ #include #include /* * find the access, last modified, and creation dates of a file */ USHORT APIENTRY DosQFileInfo(HFILE hf, USHORT usInfoLevel, PVOID pInfoBuf, USHORT cbInfoBuf) { FILESTATUS *mp = pInfoBuf; if (usInfoLevel != 1 || cbInfoBuf != sizeof *mp) return 1; if (_dos_getftime(hf, (unsigned*)&(mp->fdateLastWrite), (unsigned*)&(mp->ftimeLastWrite)) == 0) { mp->ftimeLastAccess = mp->ftimeLastWrite; memcpy(&mp->fdateLastAccess, &mp->fdateLastWrite, sizeof mp->fdateLastWrite); mp->ftimeCreation = mp->ftimeLastWrite; memcpy(&mp->fdateCreation, &mp->fdateLastWrite, sizeof mp->fdateLastWrite); return 0; } return 1; } /* fsQfiletime */ /* * set the access, last modified, and creation dates of a file */ USHORT APIENTRY DosSetFileInfo(HFILE hf, USHORT usInfoLevel, PBYTE pInfoBuf, USHORT cbInfoBuf) { FILESTATUS *mp = (FILESTATUS*)pInfoBuf; if (usInfoLevel != 1 || cbInfoBuf != sizeof *mp) return 1; return _dos_setftime(hf, ((unsigned*)(&mp->fdateLastWrite))[0], ((unsigned*)(&mp->ftimeLastWrite))[0]); } /* fsSetfiletime */