You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@harmony.apache.org by re...@apache.org on 2009/04/14 09:19:53 UTC

svn commit: r764692 - /harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/io/File.java

Author: regisxu
Date: Tue Apr 14 07:19:52 2009
New Revision: 764692

URL: http://svn.apache.org/viewvc?rev=764692&view=rev
Log:
Apply patch for HARMONY-6125: [classlib][luni] - remove duplicated security check in File.list

Modified:
    harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/io/File.java

Modified: harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/io/File.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/io/File.java?rev=764692&r1=764691&r2=764692&view=diff
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/io/File.java (original)
+++ harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/io/File.java Tue Apr 14 07:19:52 2009
@@ -929,10 +929,17 @@
         if (security != null) {
             security.checkRead(path);
         }
-        if (!isDirectory() || !canRead()) {
+
+        if (path.length() == 0) {
+            return null;
+        }
+
+        byte[] bs = properPath(true);
+        if (!isDirectoryImpl(bs) || !existsImpl(bs) || isWriteOnlyImpl(bs)) {
             return null;
         }
-        byte[][] implList = listImpl(properPath(true));
+
+        byte[][] implList = listImpl(bs);
         if (implList == null) {
             // empty list
             return new String[0];
@@ -1022,10 +1029,17 @@
         if (security != null) {
             security.checkRead(path);
         }
-        if (!isDirectory() || !canRead()) {
+
+        if (path.length() == 0) {
+            return null;
+        }
+
+        byte[] bs = properPath(true);
+        if (!isDirectoryImpl(bs) || !existsImpl(bs) || isWriteOnlyImpl(bs)) {
             return null;
         }
-        byte[][] implList = listImpl(properPath(true));
+
+        byte[][] implList = listImpl(bs);
         if (implList == null) {
             return new File[0];
         }
@@ -1062,24 +1076,30 @@
         if (security != null) {
             security.checkRead(path);
         }
-        if (!isDirectory() || !canRead()) {
+
+        if (path.length() == 0) {
+            return null;
+        }
+
+        byte[] bs = properPath(true);
+        if (!isDirectoryImpl(bs) || !existsImpl(bs) || isWriteOnlyImpl(bs)) {
             return null;
         }
-        byte[][] implList = listImpl(properPath(true));
+
+        byte[][] implList = listImpl(bs);
         if (implList == null) {
             // empty list
             return new String[0];
         }
-        java.util.Vector<String> tempResult = new java.util.Vector<String>();
+        List<String> tempResult = new ArrayList<String>();
         for (int index = 0; index < implList.length; index++) {
             String aName = Util.toString(implList[index]);
             if (filter == null || filter.accept(this, aName)) {
-                tempResult.addElement(aName);
+                tempResult.add(aName);
             }
         }
-        String[] result = new String[tempResult.size()];
-        tempResult.copyInto(result);
-        return result;
+
+        return tempResult.toArray(new String[tempResult.size()]);
     }
 
     private synchronized static native byte[][] listImpl(byte[] path);