commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mt...@apache.org
Subject svn commit: r767914 - /commons/sandbox/runtime/trunk/src/main/native/os/win32/file.c
Date Thu, 23 Apr 2009 13:19:47 GMT
Author: mturk
Date: Thu Apr 23 13:19:47 2009
New Revision: 767914

URL: http://svn.apache.org/viewvc?rev=767914&view=rev
Log:
Remove \??\ from symlinks

Modified:
    commons/sandbox/runtime/trunk/src/main/native/os/win32/file.c

Modified: commons/sandbox/runtime/trunk/src/main/native/os/win32/file.c
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/native/os/win32/file.c?rev=767914&r1=767913&r2=767914&view=diff
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/native/os/win32/file.c (original)
+++ commons/sandbox/runtime/trunk/src/main/native/os/win32/file.c Thu Apr 23 13:19:47 2009
@@ -51,7 +51,7 @@
              */
             wchar_t  tmpname[ACR_HBUFF_SIZ];
             wchar_t *tmpoff = NULL;
-            if (!ACR_StrMatchW(fname, L"\\\\*\\PIPE\\*", NULL, 1))
+            if (!ACR_StrMatchW(fname, L"\\\\.\\PIPE\\*", NULL, 1))
                 type = ACR_FT_PIPE;
             else if (GetFullPathNameW(fname, ACR_HBUFF_LEN,
                                       tmpname, &tmpoff)) {
@@ -181,9 +181,10 @@
             if (sh != INVALID_HANDLE_VALUE) {
                 DWORD dl;
                 PREPARSE_DATA_BUFFER repb;
-                char *pb;
-                size_t noff;
-                size_t nlen;
+                wchar_t *wb;
+                char    *pb;
+                size_t   noff;
+                size_t   nlen;
                 DeviceIoControl(sh,
                                 FSCTL_GET_REPARSE_POINT,
                                 NULL,
@@ -195,26 +196,40 @@
                 repb = (PREPARSE_DATA_BUFFER)buf;
                 switch (repb->ReparseTag) {
                     case IO_REPARSE_TAG_MOUNT_POINT:
-                        pb = (char *)repb->MountPointReparseBuffer.PathBuffer;
-                        nlen = repb->MountPointReparseBuffer.PrintNameLength;
+                        pb   = (char *)repb->MountPointReparseBuffer.PathBuffer;
+                        nlen = repb->MountPointReparseBuffer.PrintNameLength / sizeof(WCHAR);
+                        noff = repb->MountPointReparseBuffer.PrintNameOffset;
+                        wb   = (wchar_t *)(pb + noff);
                         if (!nlen) {
                             nlen = repb->MountPointReparseBuffer.SubstituteNameLength;
                             noff = repb->MountPointReparseBuffer.SubstituteNameOffset;
                         }
                         else
-                            noff = repb->MountPointReparseBuffer.PrintNameOffset;
-                        rv = (*_E)->NewString(_E, (const jchar *)(pb + noff), nlen / sizeof(WCHAR));
+                        rv = (*_E)->NewString(_E, (const jchar *)wb, nlen);
                     break;
                     case IO_REPARSE_TAG_SYMLINK:
-                        pb = (char *)repb->SymbolicLinkReparseBuffer.PathBuffer;
-                        nlen = repb->SymbolicLinkReparseBuffer.PrintNameLength;
-                        if (!nlen) {
-                            nlen = repb->SymbolicLinkReparseBuffer.SubstituteNameLength;
+                        pb   = (char *)repb->SymbolicLinkReparseBuffer.PathBuffer;
+                        nlen = repb->SymbolicLinkReparseBuffer.PrintNameLength / sizeof(WCHAR);
+                        noff = repb->SymbolicLinkReparseBuffer.PrintNameOffset;
+                        wb   = (wchar_t *)(pb + noff);
+                        if (!ACR_StrMatchW(wb, L"\\\\.\\PIPE\\*", NULL, 1)) {
+                            rv = (*_E)->NewString(_E, (const jchar *)wb, nlen);
+                        }
+                        else {
+                            nlen = repb->SymbolicLinkReparseBuffer.SubstituteNameLength
/ sizeof(WCHAR);
                             noff = repb->SymbolicLinkReparseBuffer.SubstituteNameOffset;
+                            wb   = (wchar_t *)(pb + noff);
+                            if (!wcsncmp(wb, L"\\??\\", 4)) {
+                                nlen -= 4;
+                                wb   += 4;
+                                if (!wcsncmp(wb, L"UNC\\", 3)) {
+                                    nlen -= 2;
+                                    wb[2] = L'\\';
+                                    wb   += 2;
+                                }
+                            }
+                            rv = (*_E)->NewString(_E, (const jchar *)wb, nlen);
                         }
-                        else
-                            noff = repb->SymbolicLinkReparseBuffer.PrintNameOffset;
-                        rv = (*_E)->NewString(_E, (const jchar *)(pb + noff), nlen / sizeof(WCHAR));
                     break;
                     default:
                         ACR_ThrowException(_E, THROW_NMARK, ACR_EX_EIO, ACR_EBADF);



Mime
View raw message