httpd-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From wr...@locus.apache.org
Subject cvs commit: apache-2.0/src/lib/apr/file_io/win32 dir.c open.c
Date Sat, 11 Nov 2000 02:20:29 GMT
wrowe       00/11/10 18:20:29

  Modified:    src/lib/apr/file_io/win32 dir.c open.c
  Log:
    Add unlimited path length support for //server/share/ format UNC names.
  
  Revision  Changes    Path
  1.37      +16 -10    apache-2.0/src/lib/apr/file_io/win32/dir.c
  
  Index: dir.c
  ===================================================================
  RCS file: /home/cvs/apache-2.0/src/lib/apr/file_io/win32/dir.c,v
  retrieving revision 1.36
  retrieving revision 1.37
  diff -u -r1.36 -r1.37
  --- dir.c	2000/11/10 19:58:45	1.36
  +++ dir.c	2000/11/11 02:20:29	1.37
  @@ -107,11 +107,22 @@
           apr_wchar_t *wch;
           (*new) = apr_pcalloc(cont, sizeof(apr_dir_t));
           (*new)->w.entry = apr_pcalloc(cont, sizeof(WIN32_FIND_DATAW));
  -        wch = (*new)->w.dirname = apr_palloc(cont, (dirremains + 7) * 2);
           if (dirname[1] == ':' && dirname[2] == '/') {
  +            (*new)->w.dirname = apr_palloc(cont, (dirremains + 7) * 2);
               wcscpy((*new)->w.dirname, L"\\\\?\\");
  -            wch += 4;
  +            wch = (*new)->w.dirname + 4;
           }
  +        else if (dirname[0] == '/' && dirname[1] == '/') {
  +            /* Skip the leading slashes */
  +            dirname += 2;
  +            srcremains = dirremains = (len -= 2);
  +            (*new)->w.dirname = apr_palloc(cont, (dirremains + 11) * 2);
  +            wcscpy ((*new)->w.dirname, L"\\\\?\\UNC\\");
  +            wch = (*new)->w.dirname + 8;
  +        }
  +        else
  +            wch = (*new)->w.dirname = apr_palloc(cont, (dirremains + 3) * 2);
  +        
           if (conv_utf8_to_ucs2(dirname, &srcremains,
                                 wch, &dirremains) || srcremains) {
               (*new) = NULL;
  @@ -289,14 +300,9 @@
       apr_oslevel_e os_level;
       if (!apr_get_oslevel(thedir->cntxt, &os_level) && os_level >= APR_WIN_NT)
       {
  -        /* The usual Unicode to char* accessor doesn't work here.  Since we don't
  -         * have a full path, and don't need to transpose slashes, we don't need it
  -         */
  -        int entremains = wcslen(thedir->w.entry->cFileName) + 1;
  -        int retremains = (entremains - 1) * 3 + 1;
  -        (*new) = apr_palloc(thedir->cntxt, retremains);
  -        if (conv_ucs2_to_utf8(thedir->w.entry->cFileName, &entremains,
  -                              *new, &retremains) || entremains)
  +        (*new) = unicode_to_utf8_path(thedir->w.entry->cFileName, 
  +                                      thedir->cntxt);
  +        if (!*new)
               return APR_ENAMETOOLONG;
       }
       else
  
  
  
  1.59      +37 -18    apache-2.0/src/lib/apr/file_io/win32/open.c
  
  Index: open.c
  ===================================================================
  RCS file: /home/cvs/apache-2.0/src/lib/apr/file_io/win32/open.c,v
  retrieving revision 1.58
  retrieving revision 1.59
  diff -u -r1.58 -r1.59
  --- open.c	2000/11/10 21:49:19	1.58
  +++ open.c	2000/11/11 02:20:29	1.59
  @@ -77,23 +77,26 @@
        * the \\?\ form doesn't allow '/' path seperators.
        *
        * Note that the \\?\ form only works for local drive paths, and
  -     * not for UNC paths.
  +     * \\?\UNC\ is needed UNC paths.
        */
       int srcremains = strlen(srcstr) + 1;
  -    int retremains = srcremains + 4;
  +    int retremains = srcremains;
       apr_wchar_t *retstr, *t;
       if (srcstr[1] == ':' && srcstr[2] == '/') {
  -        retstr = apr_palloc(p, retremains * 2);
  +        retstr = apr_palloc(p, (retremains + 4) * 2);
           wcscpy (retstr, L"\\\\?\\");
  -        retremains -= 4;
           t = retstr + 4;
       }
  -    else /* Short path: count the trailing NULL */
  -    {
  -        if (retremains > MAX_PATH)
  -            retremains = MAX_PATH;
  -        t = retstr = apr_palloc(p, retremains * 2);
  +    else if (srcstr[0] == '/' && srcstr[1] == '/') {
  +        /* Skip the slashes */
  +        srcstr += 2;
  +        retremains = (srcremains -= 2);
  +        retstr = apr_palloc(p, (retremains + 8) * 2);
  +        wcscpy (retstr, L"\\\\?\\UNC\\");
  +        t = retstr + 8;
       }
  +    else
  +        t = retstr = apr_palloc(p, retremains * 2);
       if (conv_utf8_to_ucs2(srcstr, &srcremains,
                             t, &retremains) || srcremains)
           return NULL;
  @@ -109,24 +112,40 @@
        * the true size of the retstr, but that's a memory over speed
        * tradeoff that isn't appropriate this early in development.
        *
  -     * Skip the leading 4 characters, allocate the maximum string
  +     * Skip the leading 4 characters if the path begins \\?\, or substitute
  +     * // for the \\?\UNC\ path prefix, allocating the maximum string
        * length based on the remaining string, plus the trailing null.
  -     * then transform \\'s back into /'s since the \\?\ form didn't
  -     * allow '/' path seperators, but APR always uses '/'s.
  +     * then transform \\'s back into /'s since the \\?\ form never
  +     * allows '/' path seperators, and APR always uses '/'s.
        */
       int srcremains = wcslen(srcstr) + 1;
       int retremains = (srcremains - 5) * 3 + 1;
  -    char *t, *retstr = apr_palloc(p, retremains);
  +    char *t, *retstr;
       if (srcstr[0] == L'\\' && srcstr[1] == L'\\' && 
           srcstr[2] == L'?'  && srcstr[3] == L'\\') {
  -        srcremains -= 4;
  -        retremains -= 12;
  -        srcstr += 4;    
  +        if (srcstr[4] == L'U' && srcstr[5] == L'N' && 
  +            srcstr[6] == L'C' && srcstr[7] == L'\\') {
  +            srcremains -= 8;
  +            retremains -= 24;
  +            srcstr += 8;
  +            retstr = apr_palloc(p, retremains + 2);
  +            strcpy(retstr, "//");
  +            t = retstr + 2;
  +        }
  +        else {
  +            srcremains -= 4;
  +            retremains -= 12;
  +            srcstr += 4;
  +            t = retstr = apr_palloc(p, retremains);
  +        }
       }
  +    else
  +        t = retstr = apr_palloc(p, retremains);
  +        
       if (conv_ucs2_to_utf8(srcstr, &srcremains,
  -                          retstr, &retremains) || srcremains)
  +                          t, &retremains) || srcremains)
           return NULL;
  -    for (t = retstr; *t; ++t)
  +    for (; *t; ++t)
           if (*t == L'/')
               *t = L'\\';
       return retstr;
  
  
  

Mime
View raw message