Ignore:
Timestamp:
Nov 23, 2000, 8:23:51 PM (25 years ago)
Author:
sandervl
Message:

CreateProcessA (path with spaces) + OpenFile (multiple backslash) fixes

File:
1 edited

Legend:

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

    r4496 r4682  
    1 /* $Id: hmfile.cpp,v 1.23 2000-10-18 17:09:32 sandervl Exp $ */
     1/* $Id: hmfile.cpp,v 1.24 2000-11-23 19:23:50 sandervl Exp $ */
    22
    33/*
     
    3636#include "oslibdos.h"
    3737
    38 #define DBG_LOCALLOG    DBG_hmfile
     38#define DBG_LOCALLOG    DBG_hmfile
    3939#include "dbglocal.h"
    4040
     
    7777        // check the named pipes
    7878        if (strnicmp("\\\\.\\PIPE",lpFileName,8)==0)
    79                 lpFileName+=3;
     79            lpFileName+=3;
    8080        else
    81                 lpFileName+=4;
     81            lpFileName+=4;
    8282  }
    8383
     
    100100  if (hFile != INVALID_HANDLE_ERROR)
    101101  {
    102         pHMHandleData->dwUserData = (DWORD) new HMFileInfo((LPSTR)lpFileName, lpSecurityAttributes);
    103         pHMHandleData->hHMHandle  = hFile;
    104         return (NO_ERROR);
     102        pHMHandleData->dwUserData = (DWORD) new HMFileInfo((LPSTR)lpFileName, lpSecurityAttributes);
     103        pHMHandleData->hHMHandle  = hFile;
     104        return (NO_ERROR);
    105105  }
    106106  else {
    107         dprintf(("CreateFile failed; error %d", GetLastError()));
    108         return(GetLastError());
    109   }
     107        dprintf(("CreateFile failed; error %d", GetLastError()));
     108        return(GetLastError());
     109  }
     110}
     111
     112//*****************************************************************************
     113//Parses and copies path
     114//OpenFile in NT4, SP6 accepts double (or more) backslashes as separators for directories!
     115//(OS/2 doesn't)
     116//Girotel 2.0 (Dutch banking app) seems to depend on this behaviour
     117//*****************************************************************************
     118void HMDeviceFileClass::ParsePath(LPCSTR lpszFileName, LPSTR lpszParsedFileName, DWORD length)
     119{
     120
     121    while(*lpszFileName != 0) {
     122        *lpszParsedFileName++ = *lpszFileName;
     123        if(*lpszFileName == '\\') {
     124            while(*lpszFileName == '\\') {
     125                 lpszFileName++;
     126            }
     127        }
     128        else {
     129            lpszFileName++;
     130        }
     131    }
     132    *lpszParsedFileName = 0;
    110133}
    111134
     
    148171
    149172  //Re-open using name in OFSTRUCT
    150   if(fuMode & OF_REOPEN) 
    151         lpFileName = (LPSTR)pOFStruct->szPathName;
     173  if(fuMode & OF_REOPEN)
     174        lpFileName = (LPSTR)pOFStruct->szPathName;
    152175  else  memset(pOFStruct, 0, sizeof(OFSTRUCT));
    153176
     
    155178             "\\\\.\\") == 0)
    156179  {
    157         lpFileName+=4;
    158   }
    159   else 
    160   if(!strchr(lpFileName, ':') && !strchr(lpFileName, '\\')) 
     180        lpFileName+=4;
     181  }
     182  else
     183  if(!strchr(lpFileName, ':') && !strchr(lpFileName, '\\'))
    161184  {
    162         //filename only; search for file in following order
    163         //1: dir from which the app loaded
    164         //2: current dir
    165         //3: windows system dir
    166         //4: windows dir
    167         //5: dirs in path path environment variable
    168         //SearchPath does exactly that
    169         LPSTR filenameinpath;
    170 
    171         if(SearchPathA(NULL, lpFileName, NULL, sizeof(filepath), filepath, &filenameinpath) == 0
    172            && !(fuMode & OF_CREATE) ) 
     185    //filename only; search for file in following order
     186    //1: dir from which the app loaded
     187    //2: current dir
     188    //3: windows system dir
     189    //4: windows dir
     190    //5: dirs in path path environment variable
     191    //SearchPath does exactly that
     192    LPSTR filenameinpath;
     193
     194    if(SearchPathA(NULL, lpFileName, NULL, sizeof(filepath), filepath, &filenameinpath) == 0
     195           && !(fuMode & OF_CREATE) )
    173196        {
    174                 pOFStruct->nErrCode = ERROR_FILE_NOT_FOUND;
    175                 SetLastError(ERROR_FILE_NOT_FOUND);
    176                 return HFILE_ERROR;
    177         }
    178         lpFileName = filepath;
    179   }
     197        pOFStruct->nErrCode = ERROR_FILE_NOT_FOUND;
     198        SetLastError(ERROR_FILE_NOT_FOUND);
     199        return HFILE_ERROR;
     200    }
     201    lpFileName = filepath;
     202  }
     203  else {
     204    ParsePath(lpFileName, filepath, sizeof(filepath));
     205    lpFileName = filepath;
     206  }
     207
    180208  // filling OFSTRUCT
    181209  pOFStruct->cBytes = sizeof(OFSTRUCT);
     
    188216  if(hFile != INVALID_HANDLE_ERROR)
    189217  {
    190         //Needed for GetFileTime
    191         pHMHandleData->hHMHandle = hFile;
    192         GetFileTime(pHMHandleData,
     218        //Needed for GetFileTime
     219        pHMHandleData->hHMHandle = hFile;
     220        GetFileTime(pHMHandleData,
    193221                    NULL,
    194222                    NULL,
    195223                    &filetime );
    196224
    197         FileTimeToDosDateTime(&filetime,
     225        FileTimeToDosDateTime(&filetime,
    198226                              &filedatetime[0],
    199227                              &filedatetime[1] );
    200         memcpy(pOFStruct->reserved, filedatetime, sizeof(pOFStruct->reserved));
    201 
    202         if(fuMode & OF_DELETE)
    203         {
    204                 OSLibDosClose(hFile);
    205                 OSLibDosDelete((LPSTR)lpFileName);
    206         }
    207         else
    208         if(fuMode & OF_EXIST)
    209         {
    210                 OSLibDosClose(hFile);
    211                 hFile = HFILE_ERROR;
    212         }
    213         if(fuMode & OF_PARSE)
    214         {
    215           CHAR drive[4];
    216 
    217                 drive[0] = pOFStruct->szPathName[0];
    218                 drive[1] = pOFStruct->szPathName[1];
    219                 drive[2] = pOFStruct->szPathName[2];
    220                 drive[3] = 0;
    221 
    222                 pOFStruct->fFixedDisk = (GetDriveTypeA(drive) != DRIVE_REMOVABLE);
    223                
    224                 OSLibDosClose(hFile);
    225                 hFile = HFILE_ERROR;
    226         }
    227 
    228         if((fuMode & OF_VERIFY))
    229         {
    230                 if(memcmp(pOFStruct->reserved, filedatetime, sizeof(pOFStruct->reserved)))
    231                 {
    232                         OSLibDosClose(hFile);
    233                         SetLastError(ERROR_FILE_NOT_FOUND);
    234                 }
    235                 hFile = HFILE_ERROR;
    236         }
    237 
    238         pOFStruct->nErrCode = GetLastError();
    239         pHMHandleData->hHMHandle = hFile;
     228        memcpy(pOFStruct->reserved, filedatetime, sizeof(pOFStruct->reserved));
     229
     230    if(fuMode & OF_DELETE)
     231    {
     232            OSLibDosClose(hFile);
     233            OSLibDosDelete((LPSTR)lpFileName);
     234    }
     235    else
     236    if(fuMode & OF_EXIST)
     237    {
     238        OSLibDosClose(hFile);
     239        hFile = HFILE_ERROR;
     240    }
     241    if(fuMode & OF_PARSE)
     242    {
     243      CHAR drive[4];
     244
     245        drive[0] = pOFStruct->szPathName[0];
     246        drive[1] = pOFStruct->szPathName[1];
     247        drive[2] = pOFStruct->szPathName[2];
     248        drive[3] = 0;
     249
     250        pOFStruct->fFixedDisk = (GetDriveTypeA(drive) != DRIVE_REMOVABLE);
     251
     252        OSLibDosClose(hFile);
     253        hFile = HFILE_ERROR;
     254    }
     255
     256        if((fuMode & OF_VERIFY))
     257        {
     258            if(memcmp(pOFStruct->reserved, filedatetime, sizeof(pOFStruct->reserved)))
     259            {
     260                    OSLibDosClose(hFile);
     261                    SetLastError(ERROR_FILE_NOT_FOUND);
     262            }
     263        hFile = HFILE_ERROR;
     264        }
     265
     266        pOFStruct->nErrCode = GetLastError();
     267        pHMHandleData->hHMHandle = hFile;
    240268
    241269        if(hFile != HFILE_ERROR) {
    242                 pHMHandleData->dwUserData = (DWORD) new HMFileInfo((LPSTR)lpFileName, NULL);
    243         }
    244         return (NO_ERROR);
     270        pHMHandleData->dwUserData = (DWORD) new HMFileInfo((LPSTR)lpFileName, NULL);
     271    }
     272        return (NO_ERROR);
    245273  }
    246274  else {
    247         DWORD rc = GetLastError();
    248 
    249         if(fuMode & OF_EXIST)
    250         {
    251                 if(rc == ERROR_OPEN_FAILED) {
    252                         SetLastError(ERROR_FILE_NOT_FOUND);
    253                 }
    254         }
    255         //todo: OF_PROMPT handling (pop up message box)
     275        DWORD rc = GetLastError();
     276
     277        if(fuMode & OF_EXIST)
     278        {
     279            if(rc == ERROR_OPEN_FAILED) {
     280            SetLastError(ERROR_FILE_NOT_FOUND);
     281        }
     282    }
     283    //todo: OF_PROMPT handling (pop up message box)
    256284  }
    257285  // error branch
     
    266294/*****************************************************************************
    267295 * Name      : HMDeviceFileClass::DuplicateHandle
    268  * Purpose   : 
    269  * Parameters: 
     296 * Purpose   :
     297 * Parameters:
    270298 *             various parameters as required
    271299 * Variables :
    272300 * Result    :
    273301 * Remark    : DUPLICATE_CLOSE_SOURCE flag handled in HMDuplicateHandle
    274  *             
     302 *
    275303 * Status    : partially implemented
    276304 *
    277305 * Author    : SvL
    278306 *****************************************************************************/
    279 BOOL HMDeviceFileClass::DuplicateHandle(PHMHANDLEDATA pHMHandleData, 
     307BOOL HMDeviceFileClass::DuplicateHandle(PHMHANDLEDATA pHMHandleData,
    280308                                        HANDLE  srcprocess,
    281309                                        PHMHANDLEDATA pHMSrcHandle,
     
    292320  dprintf(("KERNEL32:HMDeviceFileClass::DuplicateHandle (%08x,%08x,%08x,%08x,%08x)",
    293321           pHMHandleData,
    294            srcprocess, 
    295            pHMSrcHandle->hHMHandle, 
    296            destprocess, 
     322           srcprocess,
     323           pHMSrcHandle->hHMHandle,
     324           destprocess,
    297325           desthandle));
    298326
    299327  //TODO: Inheritance of file handles won't work!
    300328
    301   if(destprocess != srcprocess) 
     329  if(destprocess != srcprocess)
    302330  {
    303331    //TODO:!!!!
     
    312340    //     Can't use DosDupHandle or else there can be a sharing violation
    313341    //     when an app tries to access the same file again
    314     if(fdwOdinOptions) 
     342    if(fdwOdinOptions)
    315343    {
    316344        HMHANDLEDATA duphdata;
    317345
    318         memcpy(&duphdata, pHMHandleData, sizeof(duphdata));
    319         duphdata.dwCreation = OPEN_EXISTING;
    320 
    321         if(CreateFile(srcfileinfo->lpszFileName, &duphdata,
    322                       srcfileinfo->lpSecurityAttributes, NULL) == NO_ERROR) 
     346        memcpy(&duphdata, pHMHandleData, sizeof(duphdata));
     347        duphdata.dwCreation = OPEN_EXISTING;
     348
     349        if(CreateFile(srcfileinfo->lpszFileName, &duphdata,
     350                      srcfileinfo->lpSecurityAttributes, NULL) == NO_ERROR)
    323351        {
    324                 memcpy(pHMHandleData, &duphdata, sizeof(duphdata));
    325                 SetLastError(ERROR_SUCCESS);
    326                 return TRUE;
     352            memcpy(pHMHandleData, &duphdata, sizeof(duphdata));
     353            SetLastError(ERROR_SUCCESS);
     354            return TRUE;
    327355        }
    328         dprintf(("ERROR: DuplicateHandle; CreateFile %s failed -> trying DosDupHandle instead!",
     356        dprintf(("ERROR: DuplicateHandle; CreateFile %s failed -> trying DosDupHandle instead!",
    329357                  srcfileinfo->lpszFileName));
    330         //SvL: IE5 setup opens file with DENYREADWRITE, so CreateFile can't
     358        //SvL: IE5 setup opens file with DENYREADWRITE, so CreateFile can't
    331359        //     be used for duplicating the handle; try DosDupHandle instead
    332360    }
    333    
     361
    334362    if(!(fdwOptions & DUPLICATE_SAME_ACCESS) && fdwAccess != pHMSrcHandle->dwAccess) {
    335         dprintf(("WARNING: DuplicateHandle; app wants different access permission; Not supported!! (%x, %x)", fdwAccess, pHMSrcHandle->dwAccess));
     363        dprintf(("WARNING: DuplicateHandle; app wants different access permission; Not supported!! (%x, %x)", fdwAccess, pHMSrcHandle->dwAccess));
    336364    }
    337365
     
    383411
    384412  if(pHMHandleData->dwFlags & FILE_FLAG_DELETE_ON_CLOSE) {
    385         //TODO: should only do this after all handles have been closed
    386         if(fileInfo) {
    387                 DeleteFileA(fileInfo->lpszFileName);
    388         }       
     413    //TODO: should only do this after all handles have been closed
     414    if(fileInfo) {
     415        DeleteFileA(fileInfo->lpszFileName);
     416    }
    389417  }
    390418  if(fileInfo) {
    391         delete fileInfo;
     419    delete fileInfo;
    392420  }
    393421  dprintf(("KERNEL32: HMDeviceFileClass::CloseHandle returned %08xh\n",
     
    436464  if(lpNumberOfBytesRead)
    437465    *lpNumberOfBytesRead = 0;
    438   else 
     466  else
    439467    lpNumberOfBytesRead = &bytesread;
    440468
    441469  if((pHMHandleData->dwFlags & FILE_FLAG_OVERLAPPED) && !lpOverlapped) {
    442         dprintf(("FILE_FLAG_OVERLAPPED flag set, but lpOverlapped NULL!!"));
    443         SetLastError(ERROR_INVALID_PARAMETER);
    444         return FALSE;
     470    dprintf(("FILE_FLAG_OVERLAPPED flag set, but lpOverlapped NULL!!"));
     471    SetLastError(ERROR_INVALID_PARAMETER);
     472    return FALSE;
    445473  }
    446474  if(!(pHMHandleData->dwFlags & FILE_FLAG_OVERLAPPED) && lpOverlapped) {
    447         dprintf(("Warning: lpOverlapped != NULL & !FILE_FLAG_OVERLAPPED; sync operation"));
    448   }
    449 
    450   //SvL: DosRead doesn't like writing to memory addresses returned by 
    451   //     DosAliasMem -> search for original memory mapped pointer and use 
     475    dprintf(("Warning: lpOverlapped != NULL & !FILE_FLAG_OVERLAPPED; sync operation"));
     476  }
     477
     478  //SvL: DosRead doesn't like writing to memory addresses returned by
     479  //     DosAliasMem -> search for original memory mapped pointer and use
    452480  //     that one + commit pages if not already present
    453481  map = Win32MemMapView::findMapByView((ULONG)lpBuffer, &offset, MEMMAP_ACCESS_WRITE);
    454482  if(map) {
    455         lpRealBuf = (LPVOID)((ULONG)map->getMappingAddr() + offset);
    456         DWORD nrpages = nNumberOfBytesToRead/4096;
    457         if(offset & 0xfff)
    458                 nrpages++;
    459         if(nNumberOfBytesToRead & 0xfff)
    460                 nrpages++;
    461 
    462         map->commitPage(offset & ~0xfff, TRUE, nrpages);
     483    lpRealBuf = (LPVOID)((ULONG)map->getMappingAddr() + offset);
     484    DWORD nrpages = nNumberOfBytesToRead/4096;
     485    if(offset & 0xfff)
     486        nrpages++;
     487    if(nNumberOfBytesToRead & 0xfff)
     488        nrpages++;
     489
     490    map->commitPage(offset & ~0xfff, TRUE, nrpages);
    463491  }
    464492  else  lpRealBuf = (LPVOID)lpBuffer;
    465493
    466494  if(pHMHandleData->dwFlags & FILE_FLAG_OVERLAPPED) {
    467         dprintf(("ERROR: Overlapped IO not yet implememented!!"));
     495    dprintf(("ERROR: Overlapped IO not yet implememented!!"));
    468496  }
    469497//  else {
    470         bRC = OSLibDosRead(pHMHandleData->hHMHandle,
     498    bRC = OSLibDosRead(pHMHandleData->hHMHandle,
    471499                           (PVOID)lpRealBuf,
    472500                           nNumberOfBytesToRead,
     
    475503
    476504  if(bRC == 0) {
    477         dprintf(("KERNEL32: HMDeviceFileClass::ReadFile returned %08xh %x\n",
     505        dprintf(("KERNEL32: HMDeviceFileClass::ReadFile returned %08xh %x\n",
    478506                  bRC, GetLastError()));
    479         dprintf(("%x -> %d", lpBuffer, IsBadWritePtr((LPVOID)lpBuffer, nNumberOfBytesToRead)));
     507    dprintf(("%x -> %d", lpBuffer, IsBadWritePtr((LPVOID)lpBuffer, nNumberOfBytesToRead)));
    480508  }
    481509
     
    559587  if(lpNumberOfBytesWritten)
    560588    *lpNumberOfBytesWritten = 0;
    561   else 
     589  else
    562590    lpNumberOfBytesWritten = &byteswritten;
    563591
    564592  if((pHMHandleData->dwFlags & FILE_FLAG_OVERLAPPED) && !lpOverlapped) {
    565         dprintf(("FILE_FLAG_OVERLAPPED flag set, but lpOverlapped NULL!!"));
    566         SetLastError(ERROR_INVALID_PARAMETER);
    567         return FALSE;
     593    dprintf(("FILE_FLAG_OVERLAPPED flag set, but lpOverlapped NULL!!"));
     594    SetLastError(ERROR_INVALID_PARAMETER);
     595    return FALSE;
    568596  }
    569597  if(!(pHMHandleData->dwFlags & FILE_FLAG_OVERLAPPED) && lpOverlapped) {
    570         dprintf(("Warning: lpOverlapped != NULL & !FILE_FLAG_OVERLAPPED; sync operation"));
    571   }
    572 
    573   //SvL: DosWrite doesn't like reading from memory addresses returned by 
    574   //     DosAliasMem -> search for original memory mapped pointer and use 
     598    dprintf(("Warning: lpOverlapped != NULL & !FILE_FLAG_OVERLAPPED; sync operation"));
     599  }
     600
     601  //SvL: DosWrite doesn't like reading from memory addresses returned by
     602  //     DosAliasMem -> search for original memory mapped pointer and use
    575603  //     that one + commit pages if not already present
    576604  map = Win32MemMapView::findMapByView((ULONG)lpBuffer, &offset, MEMMAP_ACCESS_READ);
    577605  if(map) {
    578         lpRealBuf = (LPVOID)((ULONG)map->getMappingAddr() + offset);
    579         DWORD nrpages = nNumberOfBytesToWrite/4096;
    580         if(offset & 0xfff)
    581                 nrpages++;
    582         if(nNumberOfBytesToWrite & 0xfff)
    583                 nrpages++;
    584 
    585         map->commitPage(offset & ~0xfff, TRUE, nrpages);
     606    lpRealBuf = (LPVOID)((ULONG)map->getMappingAddr() + offset);
     607    DWORD nrpages = nNumberOfBytesToWrite/4096;
     608    if(offset & 0xfff)
     609        nrpages++;
     610    if(nNumberOfBytesToWrite & 0xfff)
     611        nrpages++;
     612
     613    map->commitPage(offset & ~0xfff, TRUE, nrpages);
    586614  }
    587615  else  lpRealBuf = (LPVOID)lpBuffer;
    588616
    589617  if(pHMHandleData->dwFlags & FILE_FLAG_OVERLAPPED) {
    590         dprintf(("ERROR: Overlapped IO not yet implememented!!"));
     618    dprintf(("ERROR: Overlapped IO not yet implememented!!"));
    591619  }
    592620//  else {
    593         bRC = OSLibDosWrite(pHMHandleData->hHMHandle,
     621    bRC = OSLibDosWrite(pHMHandleData->hHMHandle,
    594622                            (PVOID)lpRealBuf,
    595623                            nNumberOfBytesToWrite,
     
    677705                                                    BY_HANDLE_FILE_INFORMATION* pHFI)
    678706{
    679   dprintfl(("KERNEL32: HMDeviceFileClass::GetFileInformationByHandle %s(%08xh,%08xh)\n",
    680            lpHMDeviceName,
    681            pHMHandleData,
    682            pHFI));
    683 
    684   if(OSLibDosGetFileInformationByHandle(pHMHandleData->hHMHandle,
    685                                         pHFI))
    686   {
    687         return TRUE;
    688   }
    689   dprintf(("GetFileInformationByHandle failed with error %d", GetLastError()));
    690   return FALSE;
     707    dprintfl(("KERNEL32: HMDeviceFileClass::GetFileInformationByHandle %s(%08xh,%08xh)\n",
     708              lpHMDeviceName, pHMHandleData, pHFI));
     709
     710    if(OSLibDosGetFileInformationByHandle(pHMHandleData->hHMHandle,
     711                                          pHFI))
     712    {
     713        return TRUE;
     714    }
     715    dprintf(("GetFileInformationByHandle failed with error %d", GetLastError()));
     716    return FALSE;
    691717
    692718}
     
    707733BOOL HMDeviceFileClass::SetEndOfFile(PHMHANDLEDATA pHMHandleData)
    708734{
    709   dprintfl(("KERNEL32: HMDeviceFileClass::SetEndOfFile %s(%08xh)\n",
    710            lpHMDeviceName,
    711            pHMHandleData));
    712 
    713   if(OSLibDosSetEndOfFile(pHMHandleData->hHMHandle)) {
    714         return TRUE;
    715   }
    716   dprintf(("SetEndOfFile failed with error %d", GetLastError()));
    717   return FALSE;
     735    dprintfl(("KERNEL32: HMDeviceFileClass::SetEndOfFile %s(%08xh)\n",
     736             lpHMDeviceName,
     737             pHMHandleData));
     738
     739    if(OSLibDosSetEndOfFile(pHMHandleData->hHMHandle)) {
     740        return TRUE;
     741    }
     742    dprintf(("SetEndOfFile failed with error %d", GetLastError()));
     743    return FALSE;
    718744}
    719745
     
    743769 WORD lastwritedate = 0, lastwritetime = 0;
    744770
    745   dprintfl(("KERNEL32: HMDeviceFileClass::SetFileTime %s(%08xh,%08xh,%08xh,%08xh)\n",
    746            lpHMDeviceName,
    747            pHMHandleData,
    748            pFT1,
    749            pFT2,
    750            pFT3));
    751 
    752   if(pFT1 && pFT1->dwLowDateTime && pFT1->dwHighDateTime) {
    753         FileTimeToDosDateTime(pFT1, &creationdate, &creationtime);
    754   }
    755 
    756   if(pFT2 && pFT2->dwLowDateTime && pFT2->dwHighDateTime) {
    757         FileTimeToDosDateTime(pFT2, &lastaccessdate, &lastaccesstime);
    758   }
    759 
    760   if(pFT3 && pFT3->dwLowDateTime && pFT3->dwHighDateTime) {
    761         FileTimeToDosDateTime(pFT3, &lastwritedate, &lastwritetime);
    762   }
    763 
    764   if(OSLibDosSetFileTime(pHMHandleData->hHMHandle,
    765                              creationdate, creationtime,
    766                              lastaccessdate, lastaccesstime,
    767                              lastwritedate, lastwritetime))
    768   {
    769         return TRUE;
    770   }
    771   dprintf(("SetFileTime failed with error %d", GetLastError()));
    772   return FALSE;
     771    dprintfl(("KERNEL32: HMDeviceFileClass::SetFileTime %s(%08xh,%08xh,%08xh,%08xh)\n",
     772              lpHMDeviceName, pHMHandleData, pFT1, pFT2, pFT3));
     773
     774    if(pFT1 && pFT1->dwLowDateTime && pFT1->dwHighDateTime) {
     775        FileTimeToDosDateTime(pFT1, &creationdate, &creationtime);
     776    }
     777
     778    if(pFT2 && pFT2->dwLowDateTime && pFT2->dwHighDateTime) {
     779        FileTimeToDosDateTime(pFT2, &lastaccessdate, &lastaccesstime);
     780    }
     781
     782    if(pFT3 && pFT3->dwLowDateTime && pFT3->dwHighDateTime) {
     783        FileTimeToDosDateTime(pFT3, &lastwritedate, &lastwritetime);
     784    }
     785
     786    if(OSLibDosSetFileTime(pHMHandleData->hHMHandle,
     787                           creationdate, creationtime,
     788                           lastaccessdate, lastaccesstime,
     789                           lastwritedate, lastwritetime))
     790    {
     791        return TRUE;
     792    }
     793    dprintf(("SetFileTime failed with error %d", GetLastError()));
     794    return FALSE;
    773795}
    774796
     
    799821
    800822  if(!pFT1 && !pFT2 && !pFT3) {//TODO: does NT do this?
    801         dprintf(("ERROR: GetFileTime: invalid parameter!"));
    802         SetLastError(ERROR_INVALID_PARAMETER);
    803         return FALSE;
     823    dprintf(("ERROR: GetFileTime: invalid parameter!"));
     824    SetLastError(ERROR_INVALID_PARAMETER);
     825    return FALSE;
    804826  }
    805827
    806828  if(OSLibDosGetFileTime(pHMHandleData->hHMHandle,
    807                          &creationdate, &creationtime, 
    808                          &lastaccessdate, &lastaccesstime, 
     829                         &creationdate, &creationtime,
     830                         &lastaccessdate, &lastaccesstime,
    809831                         &lastwritedate, &lastwritetime))
    810832  {
    811         if(pFT1) {
    812                 DosDateTimeToFileTime(creationdate, creationtime, pFT1);
    813         }
    814         if(pFT2) {
    815                 DosDateTimeToFileTime(lastaccessdate, lastaccesstime, pFT2);
    816         }
    817         if(pFT3) {
    818                 DosDateTimeToFileTime(lastwritedate, lastwritetime, pFT3);
    819         }
    820         return TRUE;
     833    if(pFT1) {
     834        DosDateTimeToFileTime(creationdate, creationtime, pFT1);
     835    }
     836    if(pFT2) {
     837        DosDateTimeToFileTime(lastaccessdate, lastaccesstime, pFT2);
     838    }
     839    if(pFT3) {
     840        DosDateTimeToFileTime(lastwritedate, lastwritetime, pFT3);
     841    }
     842    return TRUE;
    821843  }
    822844  dprintf(("GetFileTime failed with error %d", GetLastError()));
     
    886908
    887909  if(ret == -1) {
    888         dprintf(("SetFilePointer failed (error = %d)", GetLastError()));
     910    dprintf(("SetFilePointer failed (error = %d)", GetLastError()));
    889911  }
    890912  return ret;
     
    11171139  this->lpszFileName = (LPSTR)malloc(strlen(lpszFileName)+1);
    11181140  if(!this->lpszFileName) {
    1119         DebugInt3();
     1141    DebugInt3();
    11201142  }
    11211143  strcpy(this->lpszFileName, lpszFileName);
     
    11271149{
    11281150  if(lpszFileName) {
    1129         free(lpszFileName);
    1130         lpszFileName = NULL;
     1151    free(lpszFileName);
     1152    lpszFileName = NULL;
    11311153  }
    11321154}
Note: See TracChangeset for help on using the changeset viewer.