apr-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From wr...@apache.org
Subject cvs commit: apr/file_io/win32 open.c
Date Sun, 30 Dec 2001 22:25:50 GMT
wrowe       01/12/30 14:25:49

  Modified:    file_io/win32 open.c
  Log:
    Doug MacEachern commented to me that perl, and some other apps, are
    calling GetModuleName or other Win32 APIs to retrieve the relative or
    working path.  Since some of these app authors have never observed an
    '\\?\D\Somepath" style unlimited-length filename, and retrieve as much
    when we spawn a process with that format, it's probably much safer to
    drop the extra decoration when we don't need it (because our filename
    is smaller than the Win32 MAX_PATH length.)
  
    So this patch does just that, and only uses "\\?\" notation when the
    filename is quite huge.
  
  Revision  Changes    Path
  1.87      +28 -14    apr/file_io/win32/open.c
  
  Index: open.c
  ===================================================================
  RCS file: /home/cvs/apr/file_io/win32/open.c,v
  retrieving revision 1.86
  retrieving revision 1.87
  diff -u -r1.86 -r1.87
  --- open.c	28 Dec 2001 23:50:48 -0000	1.86
  +++ open.c	30 Dec 2001 22:25:49 -0000	1.87
  @@ -84,20 +84,34 @@
       int srcremains = strlen(srcstr) + 1;
       apr_wchar_t *t = retstr;
       apr_status_t rv;
  -    if (srcstr[1] == ':' && (srcstr[2] == '/' || srcstr[2] == '\\')) {
  -        wcscpy (retstr, L"\\\\?\\");
  -        retlen -= 4;
  -        t += 4;
  -    }
  -    else if ((srcstr[0] == '/' || srcstr[0] == '\\')
  -          && (srcstr[1] == '/' || srcstr[1] == '\\')
  -          && (srcstr[2] != '?')) {
  -        /* Skip the slashes */
  -        srcstr += 2;
  -        srcremains -= 2;
  -        wcscpy (retstr, L"\\\\?\\UNC\\");
  -        retlen -= 8;
  -        t += 8;
  +
  +    /* This is correct, we don't twist the filename if it is will
  +     * definately be shorter than MAX_PATH.  It merits some 
  +     * performance testing to see if this has any effect, but there
  +     * seem to be applications that get confused by the resulting
  +     * Unicode \\?\ style file names, especially if they use argv[0]
  +     * or call the Win32 API functions such as GetModuleName, etc.
  +     * Not every application is prepared to handle such names.
  +     *
  +     * Note that a utf-8 name can never result in more wide chars
  +     * than the original number of utf-8 narrow chars.
  +     */
  +    if (srcremains > MAX_PATH) {
  +        if (srcstr[1] == ':' && (srcstr[2] == '/' || srcstr[2] == '\\')) {
  +            wcscpy (retstr, L"\\\\?\\");
  +            retlen -= 4;
  +            t += 4;
  +        }
  +        else if ((srcstr[0] == '/' || srcstr[0] == '\\')
  +              && (srcstr[1] == '/' || srcstr[1] == '\\')
  +              && (srcstr[2] != '?')) {
  +            /* Skip the slashes */
  +            srcstr += 2;
  +            srcremains -= 2;
  +            wcscpy (retstr, L"\\\\?\\UNC\\");
  +            retlen -= 8;
  +            t += 8;
  +        }
       }
   
       if (rv = conv_utf8_to_ucs2(srcstr, &srcremains, t, &retlen)) {
  
  
  

Mime
View raw message