Changeset 7555 for trunk/src


Ignore:
Timestamp:
Dec 6, 2001, 11:14:45 AM (24 years ago)
Author:
sandervl
Message:

partly implemented FindFirstFileExA/W

Location:
trunk/src/kernel32
Files:
3 edited

Legend:

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

    r7550 r7555  
    1 /* $Id: Fileio.cpp,v 1.59 2001-12-05 18:05:58 sandervl Exp $ */
     1/* $Id: Fileio.cpp,v 1.60 2001-12-06 10:14:45 sandervl Exp $ */
    22
    33/*
     
    77 * Copyright 1998 Patrick Haller
    88 *
    9  * Some parts copied from Wine (CopyFileExA/W)
     9 * Some parts copied from Wine (CopyFileExA/W, FindFirstFileExW)
    1010 *
    1111 * Copyright 1993 John Burton
     12 * Copyright 1993 Erik Bos
    1213 * Copyright 1996 Alexandre Julliard
    1314 *
     
    227228//******************************************************************************
    228229//******************************************************************************
    229 ODINFUNCTION2(HANDLE, FindFirstFileA,
    230               LPCSTR, lpFileName,
    231               WIN32_FIND_DATAA *, lpFindFileData)
    232 {
     230HANDLE WINAPI FindFirstFileA(LPCSTR lpFileName, WIN32_FIND_DATAA *lpFindFileData)
     231{
     232  return FindFirstFileExA(lpFileName, FindExInfoStandard, lpFindFileData,
     233                          FindExSearchNameMatch, NULL, 0);
     234}
     235/*****************************************************************************
     236 * Name      : HANDLE WIN32API FindFirstFileExA
     237 * Purpose   : The FindFirstFileExA function searches a directory for a file
     238 *             whose name and attributes match those specified in the
     239 *             function call.
     240 * Parameters: LPCSTR lpFileName                 pointer to the name of the file
     241 *                                               to search for
     242 *             FINDEX_INFO_LEVELS fInfoLevelId   information level of the returned data
     243 *             LPVOID lpFindFileData             pointer to the returned information
     244 *             FINDEX_SEARCH_OPS fSearchOp       type of filtering to perform
     245 *             LPVOID lpSearchFilter             pointer to search criteria
     246 *             DWORD dwAdditionalFlags           additional search control flags
     247 * Variables :
     248 * Result    : If the function succeeds, the return value is a search handle
     249 *             that can be used in a subsequent call to the FindNextFile or
     250 *             FindClose functions.
     251 *             If the function fails, the return value is INVALID_HANDLE_VALUE
     252 * Remark    :
     253 * Status    :
     254 *
     255 * Author    : SvL
     256 *****************************************************************************/
     257ODINFUNCTION6(HANDLE, FindFirstFileExA, LPCSTR, lpFileName,
     258                                        FINDEX_INFO_LEVELS, fInfoLevelId,
     259                                        LPVOID, lpFindFileData,
     260                                        FINDEX_SEARCH_OPS, fSearchOp,
     261                                        LPVOID, lpSearchFilter,
     262                                        DWORD, dwAdditionalFlags)
     263{   
    233264  HANDLE hFind;
    234265  char  *filename;
    235266  int    namelen;
    236267
    237   dprintf(("FindFirstFileA %s", lpFileName));
    238  
    239   if(lpFileName == NULL || lpFindFileData == NULL)
    240   {
    241     SetLastError(ERROR_INVALID_PARAMETER);
    242     return -1;
    243   }
    244  
    245   namelen = strlen(lpFileName);
    246   if(lpFileName[namelen-1] == '\\')
    247   {
    248     filename = (char *)alloca(namelen+1);
    249     strcpy(filename, lpFileName);
    250     filename[namelen-1] = 0;
    251   }
    252   else 
    253     filename = (char *)lpFileName;
    254 
    255   return (HANDLE)OSLibDosFindFirst(filename,lpFindFileData);
     268    if(lpFileName == NULL || lpFindFileData == NULL)
     269    {
     270        SetLastError(ERROR_INVALID_PARAMETER);
     271        return INVALID_HANDLE_VALUE;
     272    }
     273
     274    if ((fSearchOp != FindExSearchNameMatch) || (dwAdditionalFlags != 0))
     275    {
     276        dprintf(("!ERROR!: options not implemented 0x%08x 0x%08lx\n", fSearchOp, dwAdditionalFlags ));
     277        SetLastError(ERROR_INVALID_PARAMETER);
     278        return INVALID_HANDLE_VALUE;
     279    }
     280
     281    dprintf(("FindFirstFileExA %s %x %x %x %x %x", lpFileName, fInfoLevelId, lpFindFileData, fSearchOp, lpSearchFilter, dwAdditionalFlags));
     282
     283    switch(fInfoLevelId)
     284    {
     285    case FindExInfoStandard:
     286        namelen = strlen(lpFileName);
     287        if(lpFileName[namelen-1] == '\\')
     288        {
     289            filename = (char *)alloca(namelen+1);
     290            strcpy(filename, lpFileName);
     291            filename[namelen-1] = 0;
     292        }
     293        else 
     294            filename = (char *)lpFileName;
     295     
     296        return (HANDLE)OSLibDosFindFirst(filename, (WIN32_FIND_DATAA *)lpFindFileData);
     297
     298    default: //TODO
     299        dprintf(("!ERROR! unsupported fInfoLevelId"));
     300        SetLastError(ERROR_INVALID_PARAMETER);
     301        break;
     302    }     
     303    return INVALID_HANDLE_VALUE;
     304}
     305//******************************************************************************
     306//******************************************************************************
     307HANDLE WINAPI FindFirstFileW(LPCWSTR lpFileName, WIN32_FIND_DATAW *lpFindFileData)
     308{
     309    return FindFirstFileExW(lpFileName, FindExInfoStandard, lpFindFileData,
     310                            FindExSearchNameMatch, NULL, 0);
     311}
     312/*****************************************************************************
     313 * Name      : HANDLE WIN32API FindFirstFileExW
     314 * Purpose   : The FindFirstFileExW function searches a directory for a file
     315 *             whose name and attributes match those specified in the
     316 *             function call.
     317 * Parameters: LPCWSTR lpFileName                pointer to the name of the file
     318 *                                               to search for
     319 *             FINDEX_INFO_LEVELS fInfoLevelId   information level of the returned data
     320 *             LPVOID lpFindFileData             pointer to the returned information
     321 *             FINDEX_SEARCH_OPS fSearchOp       type of filtering to perform
     322 *             LPVOID lpSearchFilter             pointer to search criteria
     323 *             DWORD dwAdditionalFlags           additional search control flags
     324 * Variables :
     325 * Result    : If the function succeeds, the return value is a search handle
     326 *             that can be used in a subsequent call to the FindNextFile or
     327 *             FindClose functions.
     328 *             If the function fails, the return value is INVALID_HANDLE_VALUE
     329 * Remark    :
     330 * Status    :
     331 *
     332 * Author    : Wine
     333 *****************************************************************************/
     334ODINFUNCTION6(HANDLE, FindFirstFileExW, LPCWSTR, lpFileName,
     335                                        FINDEX_INFO_LEVELS, fInfoLevelId,
     336                                        LPVOID, lpFindFileData,
     337                                        FINDEX_SEARCH_OPS, fSearchOp,
     338                                        LPVOID, lpSearchFilter,
     339                                        DWORD, dwAdditionalFlags)
     340{
     341    HANDLE handle;
     342    WIN32_FIND_DATAA dataA;
     343    LPVOID _lpFindFileData;
     344    LPSTR pathA;
     345
     346    switch(fInfoLevelId)
     347    {
     348      case FindExInfoStandard:
     349        {
     350          _lpFindFileData = &dataA;
     351        }
     352        break;
     353      default:
     354        dprintf(("!ERROR! unsupported fInfoLevelId"));
     355        SetLastError(ERROR_INVALID_PARAMETER);
     356        break;
     357    }
     358
     359    pathA = HEAP_strdupWtoA( GetProcessHeap(), 0, lpFileName );
     360    handle = FindFirstFileExA(pathA, fInfoLevelId, _lpFindFileData, fSearchOp, lpSearchFilter, dwAdditionalFlags);
     361    HeapFree( GetProcessHeap(), 0, pathA );
     362    if (handle == INVALID_HANDLE_VALUE) return handle;
     363   
     364    switch(fInfoLevelId)
     365    {
     366      case FindExInfoStandard:
     367        {
     368          WIN32_FIND_DATAW *dataW = (WIN32_FIND_DATAW*) lpFindFileData;
     369          dataW->dwFileAttributes = dataA.dwFileAttributes;
     370          dataW->ftCreationTime   = dataA.ftCreationTime;
     371          dataW->ftLastAccessTime = dataA.ftLastAccessTime;
     372          dataW->ftLastWriteTime  = dataA.ftLastWriteTime;
     373          dataW->nFileSizeHigh    = dataA.nFileSizeHigh;
     374          dataW->nFileSizeLow     = dataA.nFileSizeLow;
     375          MultiByteToWideChar( CP_ACP, 0, dataA.cFileName, -1,
     376                               dataW->cFileName, sizeof(dataW->cFileName)/sizeof(WCHAR) );
     377          MultiByteToWideChar( CP_ACP, 0, dataA.cAlternateFileName, -1,
     378                               dataW->cAlternateFileName,
     379                               sizeof(dataW->cAlternateFileName)/sizeof(WCHAR) );
     380        }
     381        break;
     382    }
     383    return handle;
    256384}
    257385//******************************************************************************
     
    264392{
    265393    return (HANDLE)OSLibDosFindFirstMulti(lpFileName,lpFindFileData,count);
    266 }
    267 //******************************************************************************
    268 //******************************************************************************
    269 ODINFUNCTION2(HANDLE,  FindFirstFileW,
    270               LPCWSTR, lpFileName,
    271               WIN32_FIND_DATAW *, lpFindFileData)
    272 {
    273   HANDLE           rc;
    274   char             *astring;
    275   WIN32_FIND_DATAA wfda;
    276 
    277     astring = UnicodeToAsciiString((LPWSTR)lpFileName);
    278     dprintf(("FindFirstFileW %s", astring));
    279     rc = (HANDLE)OSLibDosFindFirst(astring,&wfda);
    280 
    281     if(rc == -1) {
    282         memset(lpFindFileData, 0, sizeof(WIN32_FIND_DATAW));
    283     }
    284     else {
    285         // convert back the result structure
    286         memcpy(lpFindFileData,
    287                  &wfda,
    288                  sizeof(WIN32_FIND_DATAA));
    289 
    290         lstrcpynAtoW (lpFindFileData->cFileName,
    291                       wfda.cFileName,
    292                       sizeof(wfda.cFileName));
    293 
    294         lstrcpynAtoW (lpFindFileData->cAlternateFileName,
    295                       wfda.cAlternateFileName,
    296                       sizeof(wfda.cAlternateFileName));
    297     }
    298     FreeAsciiString(astring);
    299     return(rc);
    300394}
    301395//******************************************************************************
  • trunk/src/kernel32/KERNEL32.DEF

    r7326 r7555  
    1 ; $Id: KERNEL32.DEF,v 1.126 2001-11-12 23:04:56 phaller Exp $
     1; $Id: KERNEL32.DEF,v 1.127 2001-12-06 10:14:45 sandervl Exp $
    22
    33;Basis is Windows95 KERNEL32
     
    343343     FindFirstChangeNotificationW  = _FindFirstChangeNotificationW@12 @249
    344344     FindFirstFileA             = _FindFirstFileA@8               @250
    345 ;@PH these functions may only be enabled if correctly implemented.
    346 ;@PH FindFirstFileExA           = _FindFirstFileExA@24                   ;NT
    347 ;@PH FindFirstFileExW           = _FindFirstFileExW@24                   ;NT
     345     FindFirstFileExA           = _FindFirstFileExA@24            @850
     346     FindFirstFileExW           = _FindFirstFileExW@24            @851
    348347     FindFirstFileW             = _FindFirstFileW@8               @251
    349348     FindNextChangeNotification = _FindNextChangeNotification@4   @252
  • trunk/src/kernel32/stubs.cpp

    r7480 r7555  
    1 /* $Id: stubs.cpp,v 1.35 2001-11-29 10:31:07 phaller Exp $
     1/* $Id: stubs.cpp,v 1.36 2001-12-06 10:14:45 sandervl Exp $
    22 *
    33 * Win32 KERNEL32 Subsystem for OS/2
     
    8787
    8888
    89 // For FindFirstFileEx
    90 
    91 #define FIND_FIRST_EX_CASE_SENSITIVE   0x00000001
    9289
    9390/*****************************************************************************
    9491 * Structures                                                                *
    9592 *****************************************************************************/
    96 
    97  // For FindFirstFileEx
    98 
    99 typedef enum _FINDEX_INFO_LEVELS {
    100     FindExInfoStandard,
    101     FindExInfoMaxInfoLevel
    102 } FINDEX_INFO_LEVELS;
    103 
    104 typedef enum _FINDEX_SEARCH_OPS {
    105     FindExSearchNameMatch,
    106     FindExSearchLimitToDirectories,
    107     FindExSearchLimitToDevices,
    108     FindExSearchMaxSearchOp
    109 } FINDEX_SEARCH_OPS;
    11093
    11194 // For Backup funtions
     
    820803}
    821804
    822 
    823 /*****************************************************************************
    824  * Name      : HANDLE WIN32API FindFirstFileExA
    825  * Purpose   : The FindFirstFileExA function searches a directory for a file
    826  *             whose name and attributes match those specified in the
    827  *             function call.
    828  * Parameters: LPCSTR lpFileName                 pointer to the name of the file
    829  *                                               to search for
    830  *             FINDEX_INFO_LEVELS fInfoLevelId   information level of the returned data
    831  *             LPVOID lpFindFileData             pointer to the returned information
    832  *             FINDEX_SEARCH_OPS fSearchOp       type of filtering to perform
    833  *             LPVOID lpSearchFilter             pointer to search criteria
    834  *             DWORD dwAdditionalFlags           additional search control flags
    835  * Variables :
    836  * Result    : If the function succeeds, the return value is a search handle
    837  *             that can be used in a subsequent call to the FindNextFile or
    838  *             FindClose functions.
    839  *             If the function fails, the return value is INVALID_HANDLE_VALUE
    840  * Remark    :
    841  * Status    : UNTESTED STUB
    842  *
    843  * Author    : Markus Montkowski [Tha, 1998/05/21 20:57]
    844  *****************************************************************************/
    845 
    846 HANDLE WIN32API FindFirstFileExA( LPCSTR lpFileName,
    847                                      FINDEX_INFO_LEVELS fInfoLevelId,
    848                                      LPVOID lpFindFileData,
    849                                      FINDEX_SEARCH_OPS fSearchOp,
    850                                      LPVOID lpSearchFilter,
    851                                      DWORD dwAdditionalFlags)
    852 {
    853 
    854   dprintf(("KERNEL32:  FindFirstFileExA(%08x,%08x,%08x,%08x,%08x,%08x)not implemented - INVALID_HANDLE_VALUE\n",
    855            lpFileName,
    856            fInfoLevelId,
    857            lpFindFileData,
    858            fSearchOp,
    859            lpSearchFilter,
    860            dwAdditionalFlags
    861           ));
    862 
    863   return (INVALID_HANDLE_VALUE);
    864 }
    865 
    866 /*****************************************************************************
    867  * Name      : HANDLE WIN32API FindFirstFileExW
    868  * Purpose   : The FindFirstFileExW function searches a directory for a file
    869  *             whose name and attributes match those specified in the
    870  *             function call.
    871  * Parameters: LPCWSTR lpFileName                pointer to the name of the file
    872  *                                               to search for
    873  *             FINDEX_INFO_LEVELS fInfoLevelId   information level of the returned data
    874  *             LPVOID lpFindFileData             pointer to the returned information
    875  *             FINDEX_SEARCH_OPS fSearchOp       type of filtering to perform
    876  *             LPVOID lpSearchFilter             pointer to search criteria
    877  *             DWORD dwAdditionalFlags           additional search control flags
    878  * Variables :
    879  * Result    : If the function succeeds, the return value is a search handle
    880  *             that can be used in a subsequent call to the FindNextFile or
    881  *             FindClose functions.
    882  *             If the function fails, the return value is INVALID_HANDLE_VALUE
    883  * Remark    :
    884  * Status    : UNTESTED STUB
    885  *
    886  * Author    : Markus Montkowski [Tha, 1998/05/21 20:57]
    887  *****************************************************************************/
    888 
    889 HANDLE WIN32API FindFirstFileExW( LPCWSTR lpFileName,
    890                                      FINDEX_INFO_LEVELS fInfoLevelId,
    891                                      LPVOID lpFindFileData,
    892                                      FINDEX_SEARCH_OPS fSearchOp,
    893                                      LPVOID lpSearchFilter,
    894                                      DWORD dwAdditionalFlags)
    895 {
    896 
    897   dprintf(("KERNEL32:  FindFirstFileExW(%08x,%08x,%08x,%08x,%08x,%08x)not implemented - INVALID_HANDLE_VALUE\n",
    898            lpFileName,
    899            fInfoLevelId,
    900            lpFindFileData,
    901            fSearchOp,
    902            lpSearchFilter,
    903            dwAdditionalFlags
    904           ));
    905 
    906   return (INVALID_HANDLE_VALUE);
    907 }
    908 
    909805/*****************************************************************************
    910806 * Name      : int WIN32API FoldStringA
Note: See TracChangeset for help on using the changeset viewer.