apr-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bnicho...@apache.org
Subject cvs commit: apr/file_io/win32 filepath.c
Date Fri, 03 May 2002 15:34:45 GMT
bnicholes    02/05/03 08:34:45

  Modified:    file_io/win32 filepath.c
  Log:
  For NetWare first check to make sure that we have a path before trying to
  use it.  Then only deconstruct the path if we need to.  Otherwise figure out
  the relative path and return the appropriate response.
  
  Revision  Changes    Path
  1.24      +35 -24    apr/file_io/win32/filepath.c
  
  Index: filepath.c
  ===================================================================
  RCS file: /home/cvs/apr/file_io/win32/filepath.c,v
  retrieving revision 1.23
  retrieving revision 1.24
  diff -u -r1.23 -r1.24
  --- filepath.c	24 Apr 2002 03:31:46 -0000	1.23
  +++ filepath.c	3 May 2002 15:34:45 -0000	1.24
  @@ -86,47 +86,58 @@
       char volume[MAX_VOLUME_NAME+1];
       char path[MAX_PATH_NAME+1];
       char file[MAX_FILE_NAME+1];
  +    char *volsep = NULL;
       int elements;
   
  +    if (inpath && *inpath)
  +        volsep = strchr (*inpath, ':');
  +    else
  +        return APR_EBADPATH;
  +
       seperator[0] = (flags & APR_FILEPATH_NATIVE) ? '\\' : '/';
   
       /* Allocate and initialize each of the segment buffers
       */
       server[0] = volume[0] = path[0] = file[0] = '\0';
   
  -    /* Split the inpath into its separate parts. If it fails then
  -        we know we have a bad path.
  -    */
  -    if (deconstruct(testpath, server, volume, path, file, NULL, &elements, PATH_UNDEF))
{
  -        if (errno == EINVAL)
  -            return APR_EBADPATH;
  -    }
  -    
  -    /* If we got a volume part then continue splitting out the root.
  -        Otherwise we either have an incomplete or relative path
  +    /* If we don't have a volume separator then don't bother deconstructing
  +        the path since we won't use the deconstructed information anyway.
       */
  -    if (volume && strlen(volume) > 0) {
  -        newpath = apr_pcalloc(p, strlen(server)+strlen(volume)+5);
  -        construct(newpath, server, volume, NULL, NULL, NULL, PATH_NETWARE);
  -
  -        /* NetWare doesn't add the root slash so we need to add it manually.
  +    if (volsep) {
  +        /* Split the inpath into its separate parts. If it fails then
  +            we know we have a bad path.
           */
  -        strcat(newpath, seperator);
  -        *rootpath = newpath;
  -
  -        /* Skip the inpath pointer down to the first non-root character
  +        if (deconstruct(testpath, server, volume, path, file, NULL, &elements, PATH_UNDEF))
{
  +            if (errno == EINVAL)
  +                return APR_EBADPATH;
  +        }
  +    
  +        /* If we got a volume part then continue splitting out the root.
  +            Otherwise we either have an incomplete or relative path
           */
  -        newpath = strchr (*inpath, ':');
  -        if (newpath) {
  +        if (volume && strlen(volume) > 0) {
  +            newpath = apr_pcalloc(p, strlen(server)+strlen(volume)+5);
  +            construct(newpath, server, volume, NULL, NULL, NULL, PATH_NETWARE);
  +
  +            /* NetWare doesn't add the root slash so we need to add it manually.
  +            */
  +            strcat(newpath, seperator);
  +            *rootpath = newpath;
  +
  +            /* Skip the inpath pointer down to the first non-root character
  +            */
  +            newpath = volsep;
               do {
                   ++newpath;
               } while (*newpath && ((*newpath == '/') || (*newpath == '\\')));
               *inpath = newpath;
  -        }
   
  -/* Need to handle APR_FILEPATH_TRUENAME checking here. */
  +            /* Need to handle APR_FILEPATH_TRUENAME checking here. */
   
  -        return APR_SUCCESS;
  +            return APR_SUCCESS;
  +        }
  +        else
  +            return APR_EBADPATH;
       }
       else if ((**inpath == '/') || (**inpath == '\\')) {
           /* if we have a root path without a volume then just split
  
  
  

Mime
View raw message