Ignore:
Timestamp:
Nov 3, 1999, 6:13:28 PM (26 years ago)
Author:
phaller
Message:

Fix: undocumented behaviour in SearchPathA and bugfix in SearchPathW

File:
1 edited

Legend:

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

    r1481 r1570  
    1 /* $Id: Fileio.cpp,v 1.12 1999-10-27 18:11:38 sandervl Exp $ */
     1/* $Id: Fileio.cpp,v 1.13 1999-11-03 17:12:20 phaller Exp $ */
    22
    33/*
     
    363363//******************************************************************************
    364364//******************************************************************************
    365 ODINFUNCTION6(DWORD, SearchPathA,
    366               LPCSTR, arg1,
    367               LPCSTR, arg2,
    368               LPCSTR, arg3,
    369               DWORD, arg4,
    370               LPSTR, arg5,
    371               LPSTR *, arg6)
    372 {
    373     dprintf(("KERNEL32:  SearchPathA\n"));
    374     return O32_SearchPath(arg1, arg2, arg3, arg4, arg5, arg6);
    375 }
    376 //******************************************************************************
    377 //******************************************************************************
    378 ODINFUNCTION6(DWORD, SearchPathW,
    379               LPCWSTR, lpPath,
    380               LPCWSTR, lpFileName,
    381               LPCWSTR, lpExtension,
    382               DWORD, nBufferLength,
    383               LPWSTR, lpBuffer,
    384               LPWSTR *, lpFilePart)
    385 {
    386  char *asciipath, *asciifile, *asciiext, *asciibuffer, *asciipart;
    387  DWORD rc;
    388 
    389     dprintf(("KERNEL32:  SearchPathW"));
    390     asciibuffer = (char *)malloc(nBufferLength+1);
    391     asciipath = UnicodeToAsciiString((LPWSTR)lpPath);
    392     asciifile = UnicodeToAsciiString((LPWSTR)lpFileName);
    393     asciiext  = UnicodeToAsciiString((LPWSTR)lpFileName);
    394     rc = O32_SearchPath(asciipath, asciifile, asciiext, nBufferLength, asciibuffer, &asciipart);
    395 
    396     if(rc) {
    397         AsciiToUnicode(asciibuffer, lpBuffer);
    398         *lpFilePart = lpBuffer + ((int)asciipart - (int)asciibuffer);
    399     }
    400     FreeAsciiString(asciiext);
    401     FreeAsciiString(asciifile);
    402     FreeAsciiString(asciipath);
    403     free(asciibuffer);
    404     return(rc);
     365ODINFUNCTION6(DWORD,  SearchPathA,
     366              LPCSTR, lpszPath,
     367              LPCSTR, lpszFile,
     368              LPCSTR, lpszExtension,
     369              DWORD,  cchReturnBuffer,
     370              LPSTR,  lpszReturnBuffer,
     371              LPSTR *, plpszFilePart)
     372{
     373  LPSTR lpszFilePart;
     374
     375  // @@@PH 1999/11/03 ANV.EXE seems to pass in NULL here, looks like
     376  // windows ignores that behaviour altough it's undocumented.
     377  if (plpszFilePart == NULL)
     378    plpszFilePart = &lpszFilePart; // just provide a valid pointer
     379
     380  return O32_SearchPath(lpszPath,
     381                        lpszFile,
     382                        lpszExtension,
     383                        cchReturnBuffer,
     384                        lpszReturnBuffer,
     385                        plpszFilePart);
     386}
     387//******************************************************************************
     388//******************************************************************************
     389ODINFUNCTION6(DWORD,    SearchPathW,
     390              LPCWSTR,  lpszPath,
     391              LPCWSTR,  lpszFileName,
     392              LPCWSTR,  lpszExtension,
     393              DWORD,    cchReturnBufferLength,
     394              LPWSTR,   lpszReturnBuffer,
     395              LPWSTR *, plpszFilePart)
     396{
     397  char *asciipath,
     398       *asciifile,
     399       *asciiext,
     400       *asciibuffer,
     401       *asciipart;
     402  DWORD rc;
     403
     404  asciibuffer = (char *)malloc(cchReturnBufferLength+1);
     405  asciipath = UnicodeToAsciiString((LPWSTR)lpszPath);
     406  asciifile = UnicodeToAsciiString((LPWSTR)lpszFileName);
     407  asciiext  = UnicodeToAsciiString((LPWSTR)lpszExtension);
     408  rc = ODIN_SearchPathA(asciipath,
     409                        asciifile,
     410                        asciiext,
     411                        cchReturnBufferLength,
     412                        asciibuffer,
     413                        &asciipart);
     414
     415  if(rc)
     416  {
     417      AsciiToUnicode(asciibuffer, lpszReturnBuffer);
     418      *plpszFilePart = lpszReturnBuffer + ((int)asciipart - (int)asciibuffer);
     419  }
     420
     421  FreeAsciiString(asciiext);
     422  FreeAsciiString(asciifile);
     423  FreeAsciiString(asciipath);
     424  free(asciibuffer);
     425  return(rc);
    405426}
    406427//******************************************************************************
Note: See TracChangeset for help on using the changeset viewer.