harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From py...@apache.org
Subject svn commit: r475868 - /incubator/harmony/enhanced/classlib/trunk/modules/portlib/src/main/native/port/windows/hyfile.c
Date Thu, 16 Nov 2006 18:57:25 GMT
Author: pyang
Date: Thu Nov 16 10:57:24 2006
New Revision: 475868

URL: http://svn.apache.org/viewvc?view=rev&rev=475868
Log:
Apply patch for HARMONY-2157 ([classlib][luni]not able to make a directory whose length is
greater than 248)

Modified:
    incubator/harmony/enhanced/classlib/trunk/modules/portlib/src/main/native/port/windows/hyfile.c

Modified: incubator/harmony/enhanced/classlib/trunk/modules/portlib/src/main/native/port/windows/hyfile.c
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/portlib/src/main/native/port/windows/hyfile.c?view=diff&rev=475868&r1=475867&r2=475868
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/portlib/src/main/native/port/windows/hyfile.c
(original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/portlib/src/main/native/port/windows/hyfile.c
Thu Nov 16 10:57:24 2006
@@ -330,12 +330,45 @@
 I_32 VMCALL
 hyfile_mkdir (struct HyPortLibrary * portLibrary, const char *path)
 {
-  if (CreateDirectory (path, 0))
+    char *canonicalpath;
+    int returnVar;
+    int len = strlen(path);
+    int i=0;
+    int j=0;
+    int lastbackslash=0;
+    if(len >= 248){
+        len =len + 4;
+        canonicalpath = portLibrary->mem_allocate_memory(portLibrary, len);
+        strcpy(canonicalpath,"\\\\?\\");
+        for(i==0,j=4;i<len;i++){
+            if(path[i]=='.'){
+                if(path[i+1]=='\\'){
+                    i++;
+                }
+                if(path[i+1]=='.'){
+                    j=lastbackslash;
+                }
+            }
+            else{
+                if(path[i]=='\\'){
+                    lastbackslash = i;
+                }
+                canonicalpath[j]=path[i];
+                j++;
+            }
+        }
+        returnVar = CreateDirectory (canonicalpath, 0);
+        portLibrary->mem_free_memory(portLibrary, canonicalpath);
+    }else{
+        returnVar = CreateDirectory (path, 0);
+    }
+    
+  if (returnVar)
     {
       return 0;
     }
   else
-    {
+    { 
       I_32 error = GetLastError ();
       portLibrary->error_set_last_error (portLibrary, error,
 					 findError (error));



Mime
View raw message