You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@felix.apache.org by ri...@apache.org on 2006/02/07 10:02:39 UTC

svn commit: r375551 - /incubator/felix/trunk/org.apache.felix.framework/src/main/java/org/apache/felix/moduleloader/JarContent.java

Author: rickhall
Date: Tue Feb  7 01:02:37 2006
New Revision: 375551

URL: http://svn.apache.org/viewcvs?rev=375551&view=rev
Log:
Modified getEntryPaths() to only display the contents of the specified
path rather than every matching entry as per the spec.

Modified:
    incubator/felix/trunk/org.apache.felix.framework/src/main/java/org/apache/felix/moduleloader/JarContent.java

Modified: incubator/felix/trunk/org.apache.felix.framework/src/main/java/org/apache/felix/moduleloader/JarContent.java
URL: http://svn.apache.org/viewcvs/incubator/felix/trunk/org.apache.felix.framework/src/main/java/org/apache/felix/moduleloader/JarContent.java?rev=375551&r1=375550&r2=375551&view=diff
==============================================================================
--- incubator/felix/trunk/org.apache.felix.framework/src/main/java/org/apache/felix/moduleloader/JarContent.java (original)
+++ incubator/felix/trunk/org.apache.felix.framework/src/main/java/org/apache/felix/moduleloader/JarContent.java Tue Feb  7 01:02:37 2006
@@ -297,12 +297,28 @@
 
         private Object findNext()
         {
+            // This method filters the entries of the zip file, such that
+            // it only displays the contents of the directory specified by
+            // the path argument; much like using "ls" to list the contents
+            // of a directory.
             while (m_enumeration.hasMoreElements())
             {
+                // Get the next zip entry.
                 ZipEntry entry = (ZipEntry) m_enumeration.nextElement();
-                if (entry.getName().startsWith(m_path))
+                // Check to see if it is a child of the specified path.
+                if (!entry.getName().equals(m_path) && entry.getName().startsWith(m_path))
                 {
-                    return entry.getName();
+                    // Verify that it is a child of the path and not a
+                    // grandchild by examining its remaining path length.
+                    // this code uses the knowledge that zip entries
+                    // corresponding to directories end in '/'. It checks
+                    // to see if the next occurrence of '/' is also the
+                    // end of the string or if there are no more occurrences.
+                    int idx = entry.getName().indexOf('/', m_path.length());
+                    if ((idx < 0) || (idx == (entry.getName().length() - 1)))
+                    {
+                        return entry.getName();
+                    }
                 }
             }
             return null;