2009/6/7 Sahoo <[email protected]> > [Please excuse me if this email got delivered multiple times. I tried > sending this email earlier, but never saw them appearing in mailing list, so > I am sending again.] > Hi, > > Can anyone tell me how I can iterate over all the entries of a bundle > jar? I don't want any entries from the fragment. So, I thought > Bundle.getEntryPaths() would do the job, but I don't see the desired > behavior. For testing purpose, I am using the following code: > > void printEntryPaths(Bundle b, String s) { > Enumeration e = b.getEntryPaths(s); > if (e!=null) { > while (e.hasMoreElements()) { > String next = (String)e.nextElement(); > System.out.println(next); > printEntryPaths(b, next); > } > } > } > > If I call printEntryPaths(someBundle, "/"), it should print all the > entries, right? But, it does not do so for all bundles. I test it for a > bundle for which "jar" > command prints the following: > jar tf /tmp/someBundle.jar > > META-INF/MANIFEST.MF > WEB-INF/web.xml > index.html > > (Notice the lack of directory entries for META-INF/ and WEB-INF/ in the > output above) > For this bundle, the above code only prints: > index.html >
Well, the javadoc for "getEntryPaths" states: "Returns an Enumeration of all the paths (String objects) to entries within this bundle whose longest sub-path matches the specified path." so if the Jar is missing those directory entries then this result is technically correct, albeit not so useful I think it is related to the fact that there are no directory entries for > META-INF and WEB-INF in the jar. I ran the code against Equinox and > Knopflerfish, and got the desired result. > I think Equinox and KF are being more lenient wrt. the Jar structure - strictly speaking a well-formed Jar should not have any missing directory entries, but many tools will let you create Jars without them. Perhaps we should be more lenient as well? Thanks, > Sahoo > > > > --------------------------------------------------------------------- > > To unsubscribe, e-mail: [email protected] > For additional commands, e-mail: [email protected] > > -- Cheers, Stuart

