Changeset 1761 for trunk/dll


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

Implement IsAbsolutePath and modify SearchPathForFile to use

Location:
trunk/dll
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/dll/pathutil.c

    r1750 r1761  
    1414  15 Oct 08 GKY Fix NormalizeCmdLine to check all 5 executable extensions when no extension provided;
    1515                use searchapath to check for existance of file types not checked by DosQAppType;
    16                 close DosFind.
     16                close DosFind.
    1717  28 Jun 09 GKY Added AddBackslashToPath() to remove repeatative code
    1818  12 Jul 09 GKY Add xDosQueryAppType and xDosAlloc... to allow FM/2 to load in high memory
     
    2020  17 Sep 11 GKY Fix commandline quoting issues
    2121  01 Mar 14 JBS Ticket #524: Made "searchapath" thread-safe. Function names and signatures were changed.
    22                 So calls to these functions had to be changed.
     22                So calls to these functions had to be changed.
     23  21 Mar 14 SHL Add IsAbsolutePath
    2324
    2425***********************************************************************/
     
    2627#include <stdlib.h>
    2728#include <string.h>
     29#include <ctype.h>
    2830
    2931#define INCL_WIN
     
    140142  }
    141143  return pszQuotedFileName;
     144}
     145
     146/**
     147 * Return TRUE if absolute path name
     148 * @param pszPathName points to path name
     149 * @returns TRUE if absolute path, with or without drive letter
     150 * @note Odd inputs return FALSE
     151 *
     152 */
     153
     154BOOL IsAbsolutePath(PCSZ pszPathName)
     155{
     156  return pszPathName &&
     157         pszPathName[0] &&
     158         ((pszPathName[0] == '\\' || pszPathName[0] == '/') ||
     159          (toupper(pszPathName[0]) >= 'A' &&
     160           toupper(pszPathName[0]) <= 'Z' &&
     161           pszPathName[1] &&
     162           pszPathName[1] == ':' &&
     163           (pszPathName[2] == '\\' || pszPathName[2] == '/')));
    142164}
    143165
     
    211233               pszCmdLine_);
    212234      if (!offsetexe && !offsetcom) {
    213         if (!SearchPathForFile(PCSZ_PATH, szCmdLine, NULL))
    214           ret = 0;
     235        if (!SearchPathForFile(PCSZ_PATH, szCmdLine, NULL))
     236          ret = 0;
    215237      }
    216238      else
     
    410432#pragma alloc_text(PATHUTIL,BldQuotedFullPathName)
    411433#pragma alloc_text(PATHUTIL,NormalizeCmdLine)
     434#pragma alloc_text(PATHUTIL,IsAbsolutePath)
  • trunk/dll/pathutil.h

    r1545 r1761  
    1313  28 Jun 09 GKY Added AddBackslashToPath() to remove repeatative code.
    1414  23 Oct 10 GKY Add ForwardslashToBackslash function to streamline code
     15  21 Mar 14 SHL Add IsAbsolutePath
    1516
    1617***********************************************************************/
     
    2425#endif
    2526
    26 PSZ ForwardslashToBackslash(PSZ pszPathName);
    2727PSZ AddBackslashToPath(PSZ pszPathName);
     28
    2829PSZ BldFullPathName(PSZ pszFullPathName, PCSZ pszPathName, PCSZ pszFileName);
    2930PSZ BldQuotedFullPathName(PSZ pszFullPathName, PCSZ pszPathName, PCSZ pszFileName);
    3031PSZ BldQuotedFileName(PSZ pszQuotedFileName, PCSZ pszFileName);
     32
     33BOOL IsAbsolutePath(PCSZ pszPathName);
     34PSZ ForwardslashToBackslash(PSZ pszPathName);
     35
    3136PCSZ NormalizeCmdLine(PSZ pszWorkBuf, PSZ pszCmdLine_);
    3237
  • 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.