[armedbear-cvs] r13349 - trunk/abcl/src/org/armedbear/lisp
mevenson at common-lisp.net
mevenson at common-lisp.net
Mon Jun 20 12:01:18 UTC 2011
Author: mevenson
Date: Mon Jun 20 05:01:18 2011
New Revision: 13349
Log:
Implement DIRECTORY wildcard matching for zip inside zip.
With this commit, one can load ABCL fasls ("*.abcl") included inside
jars successfully. I thought this has been working previously, but am
unable to quickly find the evidence.
Modified:
trunk/abcl/src/org/armedbear/lisp/Pathname.java
Modified: trunk/abcl/src/org/armedbear/lisp/Pathname.java
==============================================================================
--- trunk/abcl/src/org/armedbear/lisp/Pathname.java Sat Jun 18 07:26:16 2011 (r13348)
+++ trunk/abcl/src/org/armedbear/lisp/Pathname.java Mon Jun 20 05:01:18 2011 (r13349)
@@ -1625,29 +1625,61 @@
LispObject result = NIL;
String wild = "/" + pathname.asEntryPath();
-
- if (pathname.device.cdr() instanceof Cons) {
- return error(new FileError("Unimplemented directory listing of JAR within JAR.", pathname));
- }
-
final SimpleString wildcard = new SimpleString(wild);
- ZipFile jar = ZipCache.get((Pathname)pathname.device.car());
-
- for (Enumeration<? extends ZipEntry> entries = jar.entries(); entries.hasMoreElements();) {
- ZipEntry entry = entries.nextElement();
- String entryName = "/" + entry.getName();
-
- LispObject matches = Symbol.PATHNAME_MATCH_P
- .execute(new SimpleString(entryName), wildcard);
+ if (pathname.device.cdr() instanceof Cons) {
+ ZipFile outerJar = ZipCache.get((Pathname)pathname.device.car());
+ String entryPath = ((Pathname)pathname.device.cdr().car()).getNamestring(); //???
+ if (entryPath.startsWith("/")) {
+ entryPath = entryPath.substring(1);
+ }
+ ZipEntry entry = outerJar.getEntry(entryPath);
+ InputStream inputStream = null;
+ try {
+ inputStream = outerJar.getInputStream(entry);
+ } catch (IOException e) {
+ return new FileError("Failed to read zip input stream inside zip.",
+ pathname);
+ }
+ ZipInputStream zipInputStream
+ = new ZipInputStream(inputStream);
- if (!matches.equals(NIL)) {
- String namestring = new String(pathname.getNamestring());
- namestring = namestring.substring(0, namestring.lastIndexOf("!/") + 2)
- + entry.getName();
- Pathname p = new Pathname(namestring);
- result = new Cons(p, result);
+ try {
+ while ((entry = zipInputStream.getNextEntry()) != null) {
+ String entryName = "/" + entry.getName();
+ LispObject matches = Symbol.PATHNAME_MATCH_P
+ .execute(new SimpleString(entryName), wildcard);
+
+ if (!matches.equals(NIL)) {
+ String namestring = new String(pathname.getNamestring());
+ namestring = namestring.substring(0, namestring.lastIndexOf("!/") + 2)
+ + entry.getName();
+ Pathname p = new Pathname(namestring);
+ result = new Cons(p, result);
+ }
+ }
+ } catch (IOException e) {
+ return new FileError("Failed to seek through zip inputstream inside zip.",
+ pathname);
}
+ } else {
+ ZipFile jar = ZipCache.get((Pathname)pathname.device.car());
+ for (Enumeration<? extends ZipEntry> entries = jar.entries();
+ entries.hasMoreElements();)
+ {
+ ZipEntry entry = entries.nextElement();
+ String entryName = "/" + entry.getName();
+ LispObject matches = Symbol.PATHNAME_MATCH_P
+ .execute(new SimpleString(entryName), wildcard);
+
+ if (!matches.equals(NIL)) {
+ String namestring = new String(pathname.getNamestring());
+ namestring = namestring.substring(0, namestring.lastIndexOf("!/") + 2)
+ + entry.getName();
+ Pathname p = new Pathname(namestring);
+ result = new Cons(p, result);
+ }
+ }
}
return result;
}
More information about the armedbear-cvs
mailing list