[kaffe] bug: jar -t/-x does't handle paths correctly
Kurt Miller
truk at optonline.net
Tue Jul 19 11:41:02 PDT 2005
From: "Kurt Miller" <truk at optonline.net>
> When jar is passed a path as a parameter using -t or -x, it
> doesn't recurse into the directory and list/extract the files and
> directories under it.
>
> For example: given a test jar that looks like this:
> $ jar tf test.jar
> META-INF/
> META-INF/MANIFEST.MF
> com/
> com/intricatesoft/
> com/intricatesoft/test.class
>
> $ jar tf test.jar com
>
> lists nothing. jar xf com extracts nothing too.
>
> This is with 1.1.5. I have tried 1.1.5 with
> libraries/javalib/kaffe/tools/jar/Jar.java patched to match the
> HEAD version too.
The below patch to HEAD adds support to jar to handle paths
as described above. Paths ending in / and not ending in /
are handled.
--- libraries/javalib/kaffe/tools/jar/Jar.java.head Tue Jul 19 10:41:48 2005
+++ libraries/javalib/kaffe/tools/jar/Jar.java Tue Jul 19 12:33:46 2005
@@ -642,8 +642,8 @@
// see if the current ZipEntry's name equals
- // the file we want to extract. If equal then
- // print the name of the file to stdout.
+ // the file we want to extract or if it starts
+ // with a path matching the dir we want to extract.
String entry_name = entry.getName();
boolean match = (shortnames == null);
@@ -657,6 +657,17 @@
for (int i = 0; i < shortnames.length ; i++) {
if (entry_name.equals(shortnames[i])) {
match = true;
+ break;
+ } else if (shortnames[i].endsWith("/")) {
+ if (entry_name.startsWith(shortnames[i])) {
+ match = true;
+ break;
+ }
+ } else {
+ if (entry_name.startsWith(shortnames[i] + '/')) {
+ match = true;
+ break;
+ }
}
}
}
@@ -752,6 +763,20 @@
if (entry_name.equals(shortnames[i])) {
match = true;
longname = longnames[i];
+ break;
+ } else if (shortnames[i].endsWith("/")) {
+ if (entry_name.startsWith(shortnames[i])) {
+ String shortname = shortnames[i].substring(0, shortnames[i].length() -1);
+ match = true;
+ longname = longnames[i].substring(0, longnames[i].lastIndexOf(shortname)) + entry_name;
+ break;
+ }
+ } else {
+ if (entry_name.startsWith(shortnames[i] + '/')) {
+ match = true;
+ longname = longnames[i].substring(0, longnames[i].lastIndexOf(shortnames[i])) + entry_name;
+ break;
+ }
}
}
}
More information about the kaffe
mailing list