harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From regi...@apache.org
Subject svn commit: r772580 - in /harmony/enhanced/classlib/trunk/modules: luni/src/test/api/windows/org/apache/harmony/luni/tests/java/io/WinFileTest.java portlib/src/main/native/port/windows/hyfile.c
Date Thu, 07 May 2009 10:01:37 GMT
Author: regisxu
Date: Thu May  7 10:01:37 2009
New Revision: 772580

URL: http://svn.apache.org/viewvc?rev=772580&view=rev
Log:
Apply patch HARMONY-6041-v3.diff for HARMONY-6041: [classlib][portlib] incorrect parse path
contains special unicode charactor

Modified:
    harmony/enhanced/classlib/trunk/modules/luni/src/test/api/windows/org/apache/harmony/luni/tests/java/io/WinFileTest.java
    harmony/enhanced/classlib/trunk/modules/portlib/src/main/native/port/windows/hyfile.c

Modified: harmony/enhanced/classlib/trunk/modules/luni/src/test/api/windows/org/apache/harmony/luni/tests/java/io/WinFileTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/luni/src/test/api/windows/org/apache/harmony/luni/tests/java/io/WinFileTest.java?rev=772580&r1=772579&r2=772580&view=diff
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/luni/src/test/api/windows/org/apache/harmony/luni/tests/java/io/WinFileTest.java
(original)
+++ harmony/enhanced/classlib/trunk/modules/luni/src/test/api/windows/org/apache/harmony/luni/tests/java/io/WinFileTest.java
Thu May  7 10:01:37 2009
@@ -66,7 +66,6 @@
                 "12" + File.separator + "34" + File.separator + ".." + File.separator + ".."
+ File.separator + "dir4",
                 "12" + File.separator + ".." + File.separator + "34" + File.separator + ".."
+ File.separator + "dir5",
                 ".abcd." + File.separator + ".." + File.separator + "dir6.",
-                ".abcd.." + File.separator + "dir7",
                 ".abcd.." + File.separator + ".." + File.separator + "dir8"
         };
         String []ss2 = {
@@ -76,7 +75,6 @@
                 "dir4",
                 "dir5",
                 "dir6",
-                ".abcd" + File.separator + "dir7",
                 "dir8"                
         };
         for (int i=0; i<ss1.length; i++)

Modified: harmony/enhanced/classlib/trunk/modules/portlib/src/main/native/port/windows/hyfile.c
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/portlib/src/main/native/port/windows/hyfile.c?rev=772580&r1=772579&r2=772580&view=diff
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/portlib/src/main/native/port/windows/hyfile.c
(original)
+++ harmony/enhanced/classlib/trunk/modules/portlib/src/main/native/port/windows/hyfile.c
Thu May  7 10:01:37 2009
@@ -405,16 +405,9 @@
 {
     int len;
     int wlen;
-    char *canonicalpath;
-    int srcArrayCount=0;
-    int destArrayCount=0;
-    int slashCount=0; //record how many slashes it met.
-    int dotsCount=0; //record how many dots following a separator.
-    int *slashStack; //record position of every separator.
-    
-    // Buffer to store absolute path name.
-    char absPath[ABS_PATH_BUF_LEN];
- 
+    wchar_t *wPath = 0;
+    wchar_t tmpPath[ABS_PATH_BUF_LEN];
+
     if (!path) {
         *pathW = (void*) 0;
         return;
@@ -428,65 +421,20 @@
         return;
     }
 
-    // calculate an absolute path first
-    if (!GetFullPathNameA(path, ABS_PATH_BUF_LEN, absPath, (void*) 0))
-    {
-        // error occurred
-        *pathW = (void*) 0;
-        return;
+    wlen = MultiByteToWideChar(CP_UTF8, 0, path, -1, wPath, 0);
+    wPath = portLibrary->mem_allocate_memory(portLibrary, wlen*sizeof(wchar_t));
+    MultiByteToWideChar(CP_UTF8, 0, path, -1, wPath, wlen);
+
+    if (!GetFullPathNameW(wPath, ABS_PATH_BUF_LEN, tmpPath, (void*)0)) {
+        *pathW = (void*)0;
+    } else {
+        wlen = sizeof(tmpPath) + 5;
+        *pathW = portLibrary->mem_allocate_memory(portLibrary, wlen);
+        wcscpy(*pathW, L"\\\\?\\");
+        wcscat(*pathW, tmpPath);
     }
 
-    len = strlen(absPath);
-
-    slashStack = portLibrary->mem_allocate_memory(portLibrary, len*sizeof(int));
-    canonicalpath = portLibrary->mem_allocate_memory(portLibrary, len+5);
-
-    strcpy(canonicalpath,"\\\\?\\");
-
-    for(srcArrayCount=0,destArrayCount=4;srcArrayCount<len;srcArrayCount++){
-        // we have an absolute path already.
-        if(absPath[srcArrayCount]=='.'){
-            // count the dots following last separator.
-            if(dotsCount>0 || absPath[srcArrayCount-1]=='\\'){
-                dotsCount++;
-                continue;
-            }
-        }
-        // deal with the dots when we meet next separator.
-        if(absPath[srcArrayCount]=='\\'){
-            if(dotsCount == 1){
-                dotsCount = 0;
-                continue;
-            }else if (dotsCount > 1){
-                if(slashCount-2<0){
-                    slashCount=2;
-                }
-                destArrayCount=slashStack[slashCount-2];
-                dotsCount = 0;
-                slashCount--;
-            }else{
-                while(canonicalpath[destArrayCount-1] == '.'){
-                    destArrayCount--;
-                }
-                slashStack[slashCount++]=destArrayCount;
-            }
-        }
-        // for normal character.
-        while(dotsCount >0){
-            canonicalpath[destArrayCount++]='.';
-            dotsCount--;
-        }
-        canonicalpath[destArrayCount++]=absPath[srcArrayCount];
-    }
-    while(canonicalpath[destArrayCount-1] == '.'){
-        destArrayCount--;
-    }        
-    canonicalpath[destArrayCount]='\0';
-    wlen = MultiByteToWideChar(CP_UTF8, 0, canonicalpath, -1, *pathW, 0);
-    *pathW = portLibrary->mem_allocate_memory(portLibrary, wlen*sizeof(wchar_t));
-    MultiByteToWideChar(CP_UTF8, 0, canonicalpath, -1, *pathW, wlen);
-    portLibrary->mem_free_memory(portLibrary, canonicalpath);
-    portLibrary->mem_free_memory(portLibrary, slashStack);
+    portLibrary->mem_free_memory(portLibrary, wPath);
 }
 
 #undef ABS_PATH_BUF_LEN



Mime
View raw message