Ignore:
Timestamp:
Jun 18, 2009, 11:53:26 AM (16 years ago)
Author:
ydario
Message:

Kernel32 updates.

File:
1 edited

Legend:

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

    r9892 r21302  
    253253{   
    254254  HANDLE hFind;
    255   char  *filename;
    256   int    namelen;
    257255
    258256    if(lpFileName == NULL || lpFindFileData == NULL || lpSearchFilter != NULL)
     
    285283    {
    286284    case FindExInfoStandard:
     285    {
     286        char  *filename;
     287        int    namelen;
     288
     289        //Strip the backslash if 'x:\'. This function is supposed
     290        //to work in that case, but fail with 'x:\directory\'
    287291        namelen = strlen(lpFileName);
    288         if(lpFileName[namelen-1] == '\\')
     292        if(namelen == 3 && lpFileName[1] == ':' && lpFileName[2] == '\\')
    289293        {
    290294            filename = (char *)alloca(namelen+1);
     
    296300 
    297301        return (HANDLE)OSLibDosFindFirst(filename, (WIN32_FIND_DATAA *)lpFindFileData);
     302    }
    298303
    299304    default: //should never happen
     
    445450//******************************************************************************
    446451//******************************************************************************
    447 DWORD WIN32API GetFileType(HANDLE hFile)
    448 {
    449   return(HMGetFileType(hFile));
    450 }
    451 //******************************************************************************
    452 //******************************************************************************
    453 DWORD WIN32API GetFileInformationByHandle(HANDLE arg1, BY_HANDLE_FILE_INFORMATION * arg2)
    454 {
    455   return(HMGetFileInformationByHandle(arg1,arg2));
    456 }
    457 //******************************************************************************
    458 //******************************************************************************
    459 BOOL WIN32API SetEndOfFile(HANDLE arg1)
    460 {
    461   return HMSetEndOfFile(arg1);
    462 }
    463 //******************************************************************************
    464 //******************************************************************************
    465 BOOL WIN32API  SetFileTime(HANDLE arg1, const FILETIME * arg2,
    466                            const FILETIME * arg3,
    467                            const FILETIME * arg4)
    468 {
    469   return HMSetFileTime(arg1,
    470                        arg2,
    471                        arg3,
    472                        arg4);
    473 }
    474 //******************************************************************************
    475 //******************************************************************************
    476452INT WIN32API CompareFileTime(FILETIME * lpft1, FILETIME * lpft2)
    477453{
     
    497473//******************************************************************************
    498474//******************************************************************************
    499 BOOL WIN32API GetFileTime(HANDLE hFile, LPFILETIME arg2, LPFILETIME arg3, LPFILETIME arg4)
    500 {
    501     return HMGetFileTime(hFile, arg2, arg3, arg4);
    502 }
    503 //******************************************************************************
    504 //******************************************************************************
    505475BOOL WIN32API CopyFileA(LPCSTR arg1, LPCSTR arg2, BOOL arg3)
    506476{
     477    dprintf(("CopyFileA %s %s %d", arg1, arg2, arg3));
    507478  return OSLibDosCopyFile(arg1, arg2, arg3);
    508479}
     
    622593//******************************************************************************
    623594//******************************************************************************
    624 DWORD WIN32API GetFileSize(HANDLE arg1, PDWORD arg2)
    625 {
    626   return HMGetFileSize(arg1,
    627                        arg2);
    628 }
    629 //******************************************************************************
    630 //******************************************************************************
    631595BOOL WIN32API DeleteFileA(LPCSTR lpszFile)
    632596{
     
    678642{
    679643    dprintf(("GetTempFileNameA %s %s", lpPathName, lpPrefixString));
    680     return O32_GetTempFileName(lpPathName, lpPrefixString, uUnique, lpTempFileName);
     644    UINT rc = O32_GetTempFileName(lpPathName, lpPrefixString, uUnique, lpTempFileName);
     645    dprintf(("GetTempFileNameA: returns %d (%s)\n", rc, rc > 0 && lpTempFileName ? lpTempFileName : "<nothing>"));
     646    return rc;
    681647}
    682648//******************************************************************************
     
    812778//******************************************************************************
    813779//******************************************************************************
    814 DWORD WIN32API SetFilePointer(HANDLE hFile, LONG lDistanceToMove,
    815                               PLONG lpDistanceToMoveHigh, DWORD dwMoveMethod)
    816 {
    817   return(HMSetFilePointer(hFile,
    818                          lDistanceToMove,
    819                          lpDistanceToMoveHigh,
    820                          dwMoveMethod));
    821 }
    822 //******************************************************************************
    823 //******************************************************************************
    824780DWORD WIN32API GetFileAttributesA(LPCSTR lpszFileName)
    825781{
    826782    DWORD rc, error;
    827783
     784    //Disable error popus.
     785    ULONG oldmode = SetErrorMode(SEM_FAILCRITICALERRORS);
     786
    828787    rc = OSLibGetFileAttributes((LPSTR)lpszFileName);
     788
     789    SetErrorMode(oldmode);
    829790
    830791    //SvL: Open32 returns FILE_ATTRIBUTE_DIRECTORY|FILE_ATTRIBUTE_NORMAL for
     
    855816
    856817  astring = UnicodeToAsciiString((LPWSTR)arg1);
     818  dprintf(("GetFileAttributesW %s", astring));
    857819  rc = GetFileAttributesA(astring);
    858820  FreeAsciiString(astring);
     
    919881           asciibuffer, asciipart));
    920882
    921   if(rc && asciibuffer)
     883  if(rc>0 && rc<nBufferLength && asciibuffer)
    922884    AsciiToUnicode(asciibuffer,
    923885                   lpBuffer);
     
    933895  if(asciibuffer) free(asciibuffer);
    934896  return(rc);
    935 }
    936 //******************************************************************************
    937 //******************************************************************************
    938 BOOL WIN32API LockFile(HANDLE arg1, DWORD arg2,
    939                        DWORD arg3, DWORD arg4,
    940                        DWORD arg5)
    941 {
    942   return HMLockFile(arg1,
    943                     arg2,
    944                     arg3,
    945                     arg4,
    946                     arg5);
    947 }
    948 
    949 
    950 /*****************************************************************************
    951  * Name      : BOOL LockFileEx
    952  * Purpose   : The LockFileEx function locks a byte range within an open file for shared or exclusive access.
    953  * Parameters: HANDLE hFile                     handle of file to lock
    954  *             DWORD  dwFlags                   functional behavior modification flags
    955  *             DWORD  dwReserved                reserved, must be set to zero
    956  *             DWORD  nNumberOfBytesToLockLow   low-order 32 bits of length to lock
    957  *             DWORD  nNumberOfBytesToLockHigh  high-order 32 bits of length to lock
    958  *             LPOVERLAPPED  LPOVERLAPPED       addr. of structure with lock region start offset
    959  * Variables :
    960  * Result    : TRUE / FALSE
    961  * Remark    :
    962  * Status    : UNTESTED STUB
    963  *
    964  * Author    : Patrick Haller [Mon, 1998/06/15 08:00]
    965  *****************************************************************************/
    966 
    967 BOOL LockFileEx(HANDLE hFile, DWORD dwFlags, DWORD dwReserved,
    968                 DWORD nNumberOfBytesToLockLow,
    969                 DWORD nNumberOfBytesToLockHigh,
    970                 LPOVERLAPPED lpOverlapped)
    971 {
    972   return(HMLockFile(hFile,
    973                     lpOverlapped->Offset,
    974                     lpOverlapped->OffsetHigh,
    975                     nNumberOfBytesToLockLow,
    976                     nNumberOfBytesToLockHigh));
    977897}
    978898//******************************************************************************
     
    11041024 
    11051025  return(rc);
    1106 }
    1107 //******************************************************************************
    1108 /*****************************************************************************
    1109 ODINFUNCTION3(*, :,
    1110               HFILE, WIN32API,
    1111               OpenFile *, Purpose,
    1112               :, forwardOpenFile to Open32
    1113  * Parameters:
    1114  * Variables :
    1115  * Result    : API returncode
    1116  * Remark    : modified for handle translation support
    1117  * Status    : @@@PH verify if 0 is a valid "invalid handle" :)
    1118  *
    1119  * Author    : Patrick Haller [Fri, 1998/06/12 02:53]
    1120  *****************************************************************************/
    1121 
    1122 HFILE WIN32API OpenFile(LPCSTR lpszFile, OFSTRUCT *lpOpenBuff,
    1123                         UINT fuMode)
    1124 {
    1125   HFILE hFile;
    1126 
    1127   dprintf(("KERNEL32: OpenFile(%s, %08xh, %08xh)\n",
    1128            lpszFile,
    1129            lpOpenBuff,
    1130            fuMode));
    1131 
    1132   hFile = HMOpenFile(lpszFile,                                      /* call open32 */
    1133                      lpOpenBuff,
    1134                      fuMode);
    1135 
    1136   return (hFile);
    1137 }
    1138 //******************************************************************************
    1139 //******************************************************************************
    1140 BOOL WIN32API UnlockFile(HANDLE arg1, DWORD arg2, DWORD arg3,
    1141                          DWORD arg4,  DWORD arg5)
    1142 {
    1143   return HMUnlockFile(arg1,
    1144                       arg2,
    1145                       arg3,
    1146                       arg4,
    1147                       arg5);
    1148 }
    1149 
    1150 
    1151 /*****************************************************************************
    1152  * Name      : BOOL UnlockFileEx
    1153  * Purpose   : The UnlockFileEx function unlocks a previously locked byte range in an open file.
    1154  * Parameters: HANDLE hFile                     handle of file to lock
    1155  *             DWORD  dwReserved                reserved, must be set to zero
    1156  *             DWORD  nNumberOfBytesToLockLow   low-order 32 bits of length to lock
    1157  *             DWORD  nNumberOfBytesToLockHigh  high-order 32 bits of length to lock
    1158  *             LPOVERLAPPED  LPOVERLAPPED       addr. of structure with lock region start offset
    1159  * Variables :
    1160  * Result    : TRUE / FALSE
    1161  * Remark    :
    1162  * Status    : UNTESTED STUB
    1163  *
    1164  * Author    : Patrick Haller [Mon, 1998/06/15 08:00]
    1165  *****************************************************************************/
    1166 
    1167 BOOL WIN32API UnlockFileEx(HANDLE hFile, DWORD dwReserved,
    1168                            DWORD nNumberOfBytesToLockLow,
    1169                            DWORD nNumberOfBytesToLockHigh,
    1170                            LPOVERLAPPED lpOverlapped)
    1171 {
    1172   return(HMUnlockFileEx(hFile, dwReserved,
    1173                         nNumberOfBytesToLockLow,
    1174                         nNumberOfBytesToLockHigh,
    1175                         lpOverlapped));
    11761026}
    11771027//******************************************************************************
     
    16751525    return hChange;
    16761526}
    1677 //******************************************************************************
    1678 //******************************************************************************
    1679 BOOL WIN32API DeviceIoControl(HANDLE hDevice, DWORD dwIoControlCode,
    1680                               LPVOID lpInBuffer, DWORD nInBufferSize,
    1681                               LPVOID lpOutBuffer, DWORD nOutBufferSize,
    1682                               LPDWORD lpBytesReturned, LPOVERLAPPED lpOverlapped)
    1683 {
    1684     return HMDeviceIoControl(hDevice, dwIoControlCode, lpInBuffer, nInBufferSize,
    1685                              lpOutBuffer, nOutBufferSize, lpBytesReturned, lpOverlapped);
    1686 }
    1687 /*****************************************************************************
    1688  * Name      : BOOL WIN32API CancelIo
    1689  * Purpose   : The CancelIO function cancels all pending input and output
    1690  *             (I/O) operations that were issued by the calling thread for
    1691  *             the specified file handle. The function does not cancel
    1692  *             I/O operations issued for the file handle by other threads.
    1693  * Parameters: HANDLE hFile   file handle for which to cancel I/O
    1694  * Variables :
    1695  * Result    : If the function succeeds, the return value is nonzero All pending
    1696  *             I/O operations issued by the calling thread for the file handle
    1697  *             were successfully canceled.
    1698  *             If the function fails, the return value is zero.
    1699  *             To get extended error information, call GetLastError.
    1700  * Remark    : If there are any I/O operations in progress for the specified
    1701  *             file HANDLE and they were issued by the calling thread, the
    1702  *             CancelIO function cancels them.
    1703  *             Note that the I/O operations must have been issued as
    1704  *             overlapped I/O. If they were not, the I/O operations would not
    1705  *             have returned to allow the thread to call the CancelIO function.
    1706  *             Calling the CancelIO function with a file handle that was not
    1707  *             opened with FILE_FLAG_OVERLAPPED does nothing.
    1708  *             All I/O operations that are canceled will complete with the
    1709  *             error ERROR_OPERATION_ABORTED. All completion notifications
    1710  *             for the I/O operations will occur normally.
    1711  * Status    :
    1712  *
    1713  * Author    : Markus Montkowski [Thu, 1998/05/19 11:46]
    1714  *****************************************************************************/
    1715 BOOL WIN32API CancelIo(HANDLE hFile)
    1716 {
    1717   return HMCancelIo(hFile);
    1718 }
    17191527/*****************************************************************************
    17201528 * Name      : BOOL GetOverlappedResult
Note: See TracChangeset for help on using the changeset viewer.