Author: mturk
Date: Sun Aug 16 08:23:27 2009
New Revision: 804649

URL: http://svn.apache.org/viewvc?rev=804649&view=rev
Log:
Allow /FilePath along with unc //FilePath

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

Modified: commons/sandbox/runtime/trunk/src/main/native/os/win32/wutil.c
URL: 
http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/native/os/win32/wutil.c?rev=804649&r1=804648&r2=804649&view=diff
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/native/os/win32/wutil.c (original)
+++ commons/sandbox/runtime/trunk/src/main/native/os/win32/wutil.c Sun Aug 16 
08:23:27 2009
@@ -24,6 +24,7 @@
 #include "acr_descriptor.h"
 #include "acr_crypto.h"
 
+#include <direct.h>
 /*
  * XXX: Make sure it is synced with ACR_DT_ types
  */
@@ -90,7 +91,7 @@
      * Note that a utf-8 name can never result in more wide chars
      * than the original number of utf-8 narrow chars.
      */
-    if (srcremains >  NON_UNC_PATH_LENGTH) {
+    if (srcken >  NON_UNC_PATH_LENGTH) {
         if (srcstr[1] == ':' && (srcstr[2] == '/' || srcstr[2] == '\\')) {
             wcscpy (retstr, L"\\\\?\\");
             retlen -= 4;
@@ -106,6 +107,24 @@
             retlen -= 8;
             t += 8;
         }
+        else if ((srcstr[0] == '/' || srcstr[0] == '\\')) {
+            int cd;
+            /* Addition to APR. Allow \FilePath
+             * and construct \\?\CurrenttDrive:\FilePath
+             * We use _getdrive CRT function       
+             */
+            wcscpy (retstr, L"\\\\?\\");
+            if ((cd = _getdrive()))
+                retstr[4] = L'A' + cd - 1;
+            else {
+                /* C:\ should always be there
+                 * If not later open will fail anyhow
+                 */
+                retstr[4] = L'C';
+            retstr[5] = L':';
+            retlen -= 6;
+            t += 6;
+        }
     }
     if (!MultiByteToWideChar(CP_UTF8,  MB_PRECOMPOSED | MB_ERR_INVALID_CHARS,
                              srcstr, srclen, t, retlen))


Reply via email to