Changeset 9530 for trunk/src/kernel32


Ignore:
Timestamp:
Dec 19, 2002, 1:55:27 PM (23 years ago)
Author:
sandervl
Message:

DT: GetFileTime & SetFileTime fixes; need to convert between UTC and local file time

Location:
trunk/src/kernel32
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/kernel32/hmfile.cpp

    r9453 r9530  
    1 /* $Id: hmfile.cpp,v 1.36 2002-12-03 11:29:27 sandervl Exp $ */
     1/* $Id: hmfile.cpp,v 1.37 2002-12-19 12:55:27 sandervl Exp $ */
    22
    33/*
     
    141141 * Result    :
    142142 * Remark    : TODO: Check if this implementation is complete and 100% correct
     143 *                           UTC Time or Localtime ?
     144 *                   GetFileTime is changed, Returns UTC-time yet !!!!!
    143145 * Status    : NO_ERROR - API succeeded
    144146 *             other    - what is to be set in SetLastError
     
    220222                    &filetime );
    221223
     224                /* UTC Time or Localtime ? GetFileTime Returns UTC-time yet ? !!!!! */
    222225        FileTimeToDosDateTime(&filetime,
    223226                              &filedatetime[0],
     
    674677}
    675678
    676 
     679//******************************************************************************
    677680/*****************************************************************************
    678681 * Name      : BOOL HMDeviceFileClass::SetFileTime
     
    687690 * Status    :
    688691 *
    689  * Author    : Patrick Haller [Wed, 1999/06/17 20:44]
     692 * Author    : Patrick Haller [Wed, 1999/06/17 20:44] mod. DT
    690693 *****************************************************************************/
    691694
     
    695698                                    LPFILETIME pFT3)
    696699{
    697  WORD creationdate = 0, creationtime = 0;
    698  WORD lastaccessdate = 0, lastaccesstime = 0;
    699  WORD lastwritedate = 0, lastwritetime = 0;
    700 
    701700    dprintfl(("KERNEL32: HMDeviceFileClass::SetFileTime %s(%08xh,%08xh,%08xh,%08xh)\n",
    702701              lpHMDeviceName, pHMHandleData, pFT1, pFT2, pFT3));
    703702
    704     if(pFT1 && pFT1->dwLowDateTime && pFT1->dwHighDateTime) {
    705         FileTimeToDosDateTime(pFT1, &creationdate, &creationtime);
    706     }
    707 
    708     if(pFT2 && pFT2->dwLowDateTime && pFT2->dwHighDateTime) {
    709         FileTimeToDosDateTime(pFT2, &lastaccessdate, &lastaccesstime);
    710     }
    711 
    712     if(pFT3 && pFT3->dwLowDateTime && pFT3->dwHighDateTime) {
    713         FileTimeToDosDateTime(pFT3, &lastwritedate, &lastwritetime);
    714     }
    715 
    716     if(OSLibDosSetFileTime(pHMHandleData->hHMHandle,
    717                            creationdate, creationtime,
    718                            lastaccessdate, lastaccesstime,
    719                            lastwritedate, lastwritetime))
    720     {
    721         return TRUE;
    722     }
     703    if(OSLibDosSetFileTime(pHMHandleData->hHMHandle, pFT1, pFT2, pFT3)) return TRUE;
     704
    723705    dprintf(("SetFileTime failed with error %d", GetLastError()));
    724706    return FALSE;
     
    737719 * Status    :
    738720 *
    739  * Author    : SvL
     721 * Author    : SvL mod. DT
    740722 *****************************************************************************/
    741723
     
    745727                                    LPFILETIME pFT3)
    746728{
    747  WORD creationdate, creationtime;
    748  WORD lastaccessdate, lastaccesstime;
    749  WORD lastwritedate, lastwritetime;
    750  BOOL rc;
    751 
    752729  if(!pFT1 && !pFT2 && !pFT3) {//TODO: does NT do this?
    753730    dprintf(("ERROR: GetFileTime: invalid parameter!"));
     
    756733  }
    757734
    758   if(OSLibDosGetFileTime(pHMHandleData->hHMHandle,
    759                          &creationdate, &creationtime,
    760                          &lastaccessdate, &lastaccesstime,
    761                          &lastwritedate, &lastwritetime))
    762   {
    763     if(pFT1) {
    764         DosDateTimeToFileTime(creationdate, creationtime, pFT1);
    765     }
    766     if(pFT2) {
    767         DosDateTimeToFileTime(lastaccessdate, lastaccesstime, pFT2);
    768     }
    769     if(pFT3) {
    770         DosDateTimeToFileTime(lastwritedate, lastwritetime, pFT3);
    771     }
    772     return TRUE;
    773   }
     735  if(OSLibDosGetFileTime(pHMHandleData->hHMHandle, pFT1, pFT2, pFT3)) return TRUE;
    774736  dprintf(("GetFileTime failed with error %d", GetLastError()));
    775737  return FALSE;
  • trunk/src/kernel32/oslibdos.cpp

    r9298 r9530  
    1 /* $Id: oslibdos.cpp,v 1.109 2002-09-26 16:06:07 sandervl Exp $ */
     1/* $Id: oslibdos.cpp,v 1.110 2002-12-19 12:55:27 sandervl Exp $ */
    22/*
    33 * Wrappers for OS/2 Dos* API
     
    673673    dosDate = *(USHORT*)pDate;
    674674
     675    //time we get from OS2 is local time; win32 expects file time (UTC)
    675676    ret = DosDateTimeToFileTime(dosDate, dosTime, &dummy);
    676     if(ret == FALSE) {
    677         return FALSE;
    678     }
    679     //time we get from OS2 is local time; win32 expects file time (UTC)
    680     ret = LocalFileTimeToFileTime(&dummy, pFT);
     677    if(ret) ret = LocalFileTimeToFileTime(&dummy, pFT);
     678    return ret;
     679}
     680//******************************************************************************
     681//******************************************************************************
     682BOOL pmFileTimeToDateTime(FILETIME *pFT, FDATE *pDate, FTIME *pTime)
     683{
     684    BOOL        ret;
     685    FILETIME dummy;
     686    //time we get from win32 is file time (UTC); OS2 expects local time
     687    ret = FileTimeToLocalFileTime(pFT, &dummy);
     688    if (ret) ret = FileTimeToDosDateTime(&dummy, (WORD*)pDate, (WORD*)pTime);
    681689    return ret;
    682690}
     
    13911399//******************************************************************************
    13921400//******************************************************************************
    1393 BOOL OSLibDosSetFileTime(DWORD hFile, WORD creationdate, WORD creationtime,
    1394                          WORD lastaccessdate, WORD lastaccesstime,
    1395                          WORD lastwritedate, WORD lastwritetime)
     1401BOOL OSLibDosSetFileTime(DWORD hFile,  LPFILETIME pFT1,
     1402                         LPFILETIME pFT2, LPFILETIME pFT3)
    13961403{
    13971404  FILESTATUS3 fileInfo;
     
    14001407  rc = DosQueryFileInfo(hFile, FIL_STANDARD, &fileInfo, sizeof(fileInfo));
    14011408
    1402   if(rc == NO_ERROR)
    1403   {
    1404     if(creationdate && creationtime) {
    1405         fileInfo.fdateCreation   = *(FDATE *)&creationdate;
    1406         fileInfo.ftimeCreation   = *(FTIME *)&creationtime;
    1407     }
    1408     if(lastaccessdate && lastaccesstime) {
    1409         fileInfo.fdateLastAccess = *(FDATE *)&lastaccessdate;
    1410         fileInfo.ftimeLastAccess = *(FTIME *)&lastaccesstime;
    1411     }
    1412     if(lastwritedate && lastwritetime) {
    1413         fileInfo.fdateLastWrite  = *(FDATE *)&lastwritedate;
    1414         fileInfo.ftimeLastWrite  = *(FTIME *)&lastwritetime;
    1415     }
     1409  if (rc == NO_ERROR)
     1410  {
     1411        if (pFT1) pmFileTimeToDateTime(pFT1, &fileInfo.fdateCreation,  &fileInfo.ftimeCreation);
     1412        if (pFT2) pmFileTimeToDateTime(pFT2, &fileInfo.fdateLastAccess,&fileInfo.ftimeLastAccess);
     1413        if (pFT3) pmFileTimeToDateTime(pFT3, &fileInfo.fdateLastWrite, &fileInfo.ftimeLastWrite);
    14161414
    14171415    rc = DosSetFileInfo(hFile, FIL_STANDARD, &fileInfo, sizeof(fileInfo));
     
    14281426//******************************************************************************
    14291427//******************************************************************************
    1430 BOOL OSLibDosGetFileTime(DWORD hFile, WORD *creationdate, WORD *creationtime,
    1431                          WORD *lastaccessdate, WORD *lastaccesstime,
    1432                          WORD *lastwritedate, WORD *lastwritetime)
     1428BOOL OSLibDosGetFileTime(DWORD hFile, LPFILETIME pFT1,
     1429                         LPFILETIME pFT2, LPFILETIME pFT3)
    14331430{
    14341431  FILESTATUS3 fileInfo;
     
    14391436  if(rc == NO_ERROR)
    14401437  {
    1441     *creationdate   = *(WORD *)&fileInfo.fdateCreation;
    1442     *creationtime   = *(WORD *)&fileInfo.ftimeCreation;
    1443     *lastaccessdate = *(WORD *)&fileInfo.fdateLastAccess;
    1444     *lastaccesstime = *(WORD *)&fileInfo.ftimeLastAccess;
    1445     *lastwritedate  = *(WORD *)&fileInfo.fdateLastWrite;
    1446     *lastwritetime  = *(WORD *)&fileInfo.ftimeLastWrite;
    1447   }
    1448 
     1438        if (pFT1) pmDateTimeToFileTime(&fileInfo.fdateCreation,  &fileInfo.ftimeCreation,  pFT1);
     1439        if (pFT2) pmDateTimeToFileTime(&fileInfo.fdateLastAccess,&fileInfo.ftimeLastAccess,pFT2);
     1440        if (pFT3) pmDateTimeToFileTime(&fileInfo.fdateLastWrite, &fileInfo.ftimeLastWrite, pFT3);
     1441  }
    14491442  if(rc)
    14501443  {
  • trunk/src/kernel32/oslibdos.h

    r9095 r9530  
    1 /* $Id: oslibdos.h,v 1.48 2002-08-22 14:21:27 sandervl Exp $ */
     1/* $Id: oslibdos.h,v 1.49 2002-12-19 12:55:27 sandervl Exp $ */
    22
    33/*
     
    9999BOOL  OSLibDosGetFileInformationByHandle(DWORD hFile, BY_HANDLE_FILE_INFORMATION* pHFI);
    100100
    101 BOOL  OSLibDosSetFileTime(DWORD hFile, WORD creationdate, WORD creationtime,
    102                           WORD lastaccessdate, WORD lastaccesstime,
    103                           WORD lastwritedate, WORD lastwritetime);
    104 
    105 BOOL  OSLibDosGetFileTime(DWORD hFile, WORD *creationdate, WORD *creationtime,
    106                           WORD *lastaccessdate, WORD *lastaccesstime,
    107                           WORD *lastwritedate, WORD *lastwritetime);
     101BOOL  OSLibDosSetFileTime(DWORD hFile, LPFILETIME pFT1,
     102                                    LPFILETIME pFT2,
     103                                    LPFILETIME pFT3);
     104
     105BOOL  OSLibDosGetFileTime(DWORD hFile, LPFILETIME pFT1,
     106                                    LPFILETIME pFT2,
     107                                    LPFILETIME pFT3);
    108108
    109109DWORD OSLibDosSetFilePointer(DWORD hFile, DWORD OffsetLow, DWORD *OffsetHigh, DWORD method);
Note: See TracChangeset for help on using the changeset viewer.