Changeset 1761 for trunk/dll/srchpath.c


Ignore:
Timestamp:
Mar 22, 2014, 12:29:52 AM (11 years ago)
Author:
Steven Levine
Message:

Implement IsAbsolutePath and modify SearchPathForFile to use

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/dll/srchpath.c

    r1750 r1761  
    1515  17 JAN 10 GKY Changes to get working with Watcom 1.9 Beta (1/16/10). Mostly cast CHAR CONSTANT * as CHAR *.
    1616  01 Mar 14 JBS Ticket #524: Made "searchapath" thread-safe. Function names and signatures were changed.
     17  21 Mar 14 SHL SearchPathForFile: use IsAbsolutePath
    1718
    1819***********************************************************************/
     
    106107 * SearchPathForFile: Search for a file along a path
    107108 *
    108  * @param pPathname: the name of a path environment variable (input)
    109  *    Used only if pFilename has no directory separators or ':' for a drive sepcification
     109 * @param pszEnvVarName: the name of a path environment variable (input)
     110 *    Used only if pFilename has not an absoluate path
    110111 *
    111112 * @param pFilename: the name of a file to search for (input)
    112  *    If the file name includes a directory separator or the ':' for a drive specification then
     113 *    If the file name is an absolute path then
    113114 *        DosQueryPathInfo is used for the search
    114115 *    else
    115  *        DosSearchPath is used, along with the pPathname parameter
     116 *        DosSearchPath is used, along with the pszEnvVarName parameter
    116117 *
    117118 * @param pFullFilename: address of where to place fully-qulified name if search succeeds (output)
     
    121122 *
    122123 */
    123 APIRET SearchPathForFile(PCSZ pPathname,
     124APIRET SearchPathForFile(PCSZ pszEnvVarName,
    124125                         PCSZ pFilename,
    125126                         PCHAR pFullFilename)
     
    128129  CHAR szFullFilename[CCHMAXPATH];
    129130
    130   if (!pPathname || !*pPathname || !pFilename || !*pFilename)
     131  if (!pszEnvVarName || !*pszEnvVarName || !pFilename || !*pFilename)
    131132    return ERROR_INVALID_PARAMETER;
    132133
    133   if (strchr(pFilename, '\\') || strchr(pFilename, '/')
    134       || strchr(pFilename, ':')) {
     134  if (IsAbsolutePath(pFilename)) {
    135135    rc = DosQueryPathInfo(pFilename, FIL_QUERYFULLNAME,
    136                           (PVOID)szFullFilename, (ULONG) CCHMAXPATH-1);
     136                          (PVOID)szFullFilename, (ULONG)CCHMAXPATH-1);
    137137  }
    138138  else {
    139139   rc = DosSearchPath(SEARCH_IGNORENETERRS | SEARCH_ENVIRONMENT |
    140140                      SEARCH_CUR_DIRECTORY,
    141                       (CHAR *) pPathname,
     141                      (CHAR *) pszEnvVarName,
    142142                      (CHAR *) pFilename,
    143143                      (PBYTE) szFullFilename,
    144144                      CCHMAXPATH - 1);
    145145  }
    146   if (!rc && pFullFilename) {
     146  if (!rc && pFullFilename)
    147147    strcpy(pFullFilename, szFullFilename);
    148   }
     148
    149149  return rc;
    150150}
Note: See TracChangeset for help on using the changeset viewer.