Changeset 15405


Ignore:
Timestamp:
10/10/20 21:43:43 (2 years ago)
Author:
Mark Evenson
Message:

INCOMPLETE Implement Zip from InputStream? access

ZipCache?.Archive.getEntry() now works on pathnames relative to the
root of the Archive.

Able to retrieve the reference to the InputStream? for a nested pathname.

Now need to implement accessing entries within this reference.

TODO Rework decision to always use fully qualified pathname in the cache.

  • * *

Fix Pathname.copyFrom() not to change order of DEVICE cons

Reproduce via:

#p"jar:jar:file:/var/tmp/cl-ppcre-all-2.1.1.jar!/cl-ppcre/packages.abcl!/**/*"
(namestring *)

  • * *

PROBE-FILE fails for archive stream

Somewhere in the code we can construct root jar as a Pathname rather
than PathnameURL which means that the two values are not
java.lang.Object.equals(), so not matched.

TODO figure out how we are getting such a value

  • * *

Start being more explicit about the truename method

  • * *

Delegate cloning of device to the JAR-PATHNAME Java object

TODO PathnameXXX.createXXX() routines uniformly return object over
LispObject. Is this really necessary? It seems to work now in a kind
of "mixed" state.

Location:
trunk/abcl
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/abcl/src/org/armedbear/lisp/Pathname.java

    r15404 r15405  
    166166  }
    167167
    168   void copyFrom(Pathname p) {
     168  /**
     169   *
     170   */
     171  Pathname copyFrom(Pathname p) {
    169172        if (p.host != NIL) {
    170173            if (p.host instanceof SimpleString) {
     
    183186            } else if (p.getDevice() instanceof Cons) {
    184187              LispObject jars = p.getDevice();
    185               jars = jars.nreverse();
    186               device = NIL;
     188              setDevice(NIL);
     189              PathnameURL root = PathnameURL.create((Pathname)jars.car());
     190              device = device.push(root);
     191              jars = jars.cdr();
    187192              while (jars.car() != NIL) {
    188                 Pathname jar = (Pathname) Pathname.create(((Pathname)jars.car()).getNamestring());
     193                Pathname jar
     194                  = (Pathname) Pathname.create(((Pathname)jars.car()).getNamestring());
    189195                device = device.push(jar);
    190196                jars = jars.cdr();
    191197              }
     198              device.nreverse();
    192199            } else if (p.device instanceof Symbol) { // When is this the case?
    193200                device = p.device;
     
    241248        }
    242249    }
     250    return this;
    243251  }
    244252
     
    12181226        p.validateDirectory(true);
    12191227
    1220         // TODO:  need to check for downcast to PathnameURL as well
     1228        // ???  need to check for downcast to PathnameURL as well?
    12211229        // Possibly downcast type to PathnameJar
    12221230        if (p.getDevice() instanceof Cons) {
    12231231          PathnameJar result = new PathnameJar();
    1224           ncoerce(p, result);
     1232          result
     1233            .copyFrom(p)
     1234            .setDevice(PathnameJar.makeJarDeviceFrom(p));
     1235         
    12251236          // sanity check that the pathname has been constructed correctly
    12261237          result.validateComponents();
     
    18271838    }
    18281839
    1829     public static final LispObject truename(Pathname pathname) {
     1840    public static LispObject truename(Pathname pathname) {
    18301841        return truename(pathname, false);
    18311842    }
    18321843
    1833     public static final LispObject truename(LispObject arg) {
     1844    public static LispObject truename(LispObject arg) {
    18341845        return truename(arg, false);
    18351846    }
    18361847
    1837     public static final LispObject truename(LispObject arg, boolean errorIfDoesNotExist) {
     1848    public static LispObject truename(LispObject arg, boolean errorIfDoesNotExist) {
    18381849        final Pathname pathname = coerceToPathname(arg);
    18391850        return truename(pathname, errorIfDoesNotExist);
     
    18441855     * LispError if there are logical problems with the input.
    18451856     */
    1846     public static final LispObject truename(Pathname pathname,
    1847                                             boolean errorIfDoesNotExist) {
     1857    public static LispObject truename(Pathname pathname,
     1858            boolean errorIfDoesNotExist) {
    18481859      if (pathname == null || pathname.equals(NIL)) { 
    18491860        return doTruenameExit(pathname, errorIfDoesNotExist);
     
    21362147  }
    21372148
    2138   /** @return The representation of this pathname suitable for
    2139    *  referencing an entry in a Zip/JAR file
     2149  /** @return The representation of the DIRECTORY/NAME/TYPE elements
     2150   *  of pathname suitable for referencing an entry in a Zip/JAR file.
     2151   *
     2152   *  This representation is always a relative path.
    21402153   */
    21412154  protected String asEntryPath() {
  • trunk/abcl/src/org/armedbear/lisp/PathnameJar.java

    r15404 r15405  
    5858  protected PathnameJar() {}
    5959
    60   public static Pathname create() {
     60  public static PathnameJar create() {
    6161    return new PathnameJar();
    6262  }
     
    6666  }
    6767
    68   public static LispObject createFromPathname(Pathname p) {
     68  public static PathnameJar createFromPathname(Pathname p) {
    6969    if (p instanceof PathnameURL) {
    7070      return PathnameJar.create(JAR_URI_PREFIX
     
    7777                                + JAR_URI_SUFFIX);
    7878    } else {
    79       return p;
    80     }
    81   }
    82 
    83   static public LispObject createFromFile(String s) {
     79      return (PathnameJar)p;
     80    }
     81  }
     82
     83  static public PathnameJar createFromFile(String s) {
    8484    return PathnameJar.create(JAR_URI_PREFIX + "file:" + s + JAR_URI_SUFFIX);
    8585  }
    8686
    87   static public LispObject createEntryFromFile(String jar, String entry) {
     87  static public PathnameJar createEntryFromFile(String jar, String entry) {
    8888    return PathnameJar.create(JAR_URI_PREFIX + "file:" + jar + JAR_URI_SUFFIX + entry);
    8989  }
    9090
    91   static public LispObject createEntryFromJar(PathnameJar jar, String entry) {
     91  static public PathnameJar createEntryFromJar(PathnameJar jar, String entry) {
    9292    if (jar.isArchiveEntry()) {
    93       return simple_error("Failed to create the entry ~a in ~a", entry, jar);
     93      simple_error("Failed to create the entry ~a in ~a", entry, jar);
     94      return (PathnameJar)UNREACHED;
    9495    }
    9596    return PathnameJar.create(jar.getNamestring() + entry);
     
    159160  }
    160161
    161   static public LispObject create(String s) {
     162  static public PathnameJar create(String s) {
    162163    if (!s.startsWith(JAR_URI_PREFIX)) {
    163       return parse_error("Cannot create a PATHNAME-JAR from namestring: " + s);
     164      parse_error("Cannot create a PATHNAME-JAR from namestring: " + s);
     165      return (PathnameJar)UNREACHED;
    164166    }
    165167   
     
    167169
    168170    if (contents == null) {
    169       return parse_error("Couldn't parse PATHNAME-JAR from namestring: " + s);
     171      parse_error("Couldn't parse PATHNAME-JAR from namestring: " + s);
     172      return (PathnameJar)UNREACHED;
    170173    }
    171174   
    172175    PathnameJar result = new PathnameJar();
    173176
    174     LispObject rootPathname = Pathname.create(contents.get(0));
     177    // Normalize the root jar to be a URL
     178    String rootNamestring = contents.get(0);
     179    if (!isValidURL(rootNamestring)) {
     180      rootNamestring = "file:" + rootNamestring;
     181    }
     182
     183    PathnameURL rootPathname = (PathnameURL)PathnameURL.create(rootNamestring);
    175184
    176185    LispObject jars = NIL;
     
    207216
    208217    LispObject jars = getDevice();
     218
     219    LispObject rootJar = getRootJar();
     220    if (!(rootJar instanceof PathnameURL)) {
     221        return type_error("The first element in the DEVICE component of a JAR-PATHNAME is not of expected type",
     222                          rootJar,
     223                          Symbol.URL_PATHNAME);
     224    }
     225
     226    jars = jars.cdr();
     227   
    209228    while (!jars.car().equals(NIL)) {
    210229      LispObject jar = jars.car();
     
    221240    return T;
    222241  }
    223    
    224242
    225243  public String getNamestring() {
    226244    StringBuffer sb = new StringBuffer();
    227245
    228     LispObject jars = getDevice();
     246    LispObject jars = getJars();
    229247
    230248    if (jars.equals(NIL) || jars.equals(Keyword.UNSPECIFIC)) {
    231       type_error("JAR-PATHNAME has bad DEVICE",
    232                  jars,
    233                  list(Symbol.NOT,
    234                       list(Symbol.OR,
    235                            list(Symbol.EQL, NIL),
    236                            list(Symbol.EQL, Keyword.UNSPECIFIC))));
    237       return (String)UNREACHED;
     249      // type_error("JAR-PATHNAME has bad DEVICE",
     250      //            jars,
     251      //            list(Symbol.NOT,
     252      //                 list(Symbol.OR,
     253      //                      list(Symbol.EQL, NIL),
     254      //                      list(Symbol.EQL, Keyword.UNSPECIFIC))));
     255      return null;
    238256    }
    239257
     
    242260    }
    243261
    244     LispObject root = jars.car();
     262    LispObject root = getRootJar();
    245263
    246264    if (root instanceof PathnameURL) {
     
    259277    }
    260278
    261     if (jars.length() > 1) {
    262       LispObject innerJars = jars.cdr();
    263       while (innerJars.car() != NIL) {
    264         Pathname jar = (Pathname)innerJars.car();
    265         Pathname p = new Pathname();
    266         p.copyFrom(jar)
    267          .setDevice(NIL);
    268         String ns = p.getNamestring();
    269         sb.append(ns)
    270           .append(JAR_URI_SUFFIX);
    271         innerJars = innerJars.cdr();
    272       }
     279    LispObject innerJars = jars.cdr();
     280    while (innerJars.car() != NIL) {
     281      Pathname jar = (Pathname)innerJars.car();
     282      Pathname p = new Pathname();
     283      p.copyFrom(jar)
     284        .setDevice(NIL);
     285      String ns = p.getNamestring();
     286      sb.append(ns)
     287        .append(JAR_URI_SUFFIX);
     288      innerJars = innerJars.cdr();
    273289    }
    274290
     
    316332  }
    317333
    318   public static final LispObject truename(PathnameJar pathname,
    319                                           boolean errorIfDoesNotExist) {
    320     PathnameJar result = pathname;
    321 
    322     LispObject jars = pathname.getJars();
    323     Pathname rootJar = (Pathname) pathname.getRootJar();
    324     LispObject enclosingJars = jars.cdr();
    325 
    326     // if (!rootJar.isLocalFile()) {
    327        
    328     // }
    329 
     334  public static LispObject truename(Pathname pathname,
     335            boolean errorIfDoesNotExist) {
     336    if (!(pathname instanceof PathnameJar)) {
     337      return PathnameURL.truename(pathname, errorIfDoesNotExist);
     338    }
    330339    PathnameJar p = new PathnameJar();
    331340    p.copyFrom(pathname);
    332     p.setDevice(new Cons(rootJar, enclosingJars));
     341
     342    PathnameURL rootJar = (PathnameURL) p.getRootJar();
     343    if (rootJar.isLocalFile()) {
     344      LispObject trueRootJar = PathnameURL.truename(rootJar, errorIfDoesNotExist);
     345      if (trueRootJar.equals(NIL)) {
     346  return Pathname.doTruenameExit(rootJar, errorIfDoesNotExist);
     347      }
     348      LispObject otherJars = p.getJars().cdr();
     349      p.setDevice(new Cons(trueRootJar, otherJars));
     350    }
    333351
    334352    if (!p.isArchiveEntry()) {
     
    396414  }
    397415
    398   /** List the contents of the directory */
     416  /** List the contents of a directory within a JAR archive */
    399417  static public LispObject listDirectory(PathnameJar pathname) {
    400418    String directory = pathname.asEntryPath();
     
    404422    }
    405423
    406     // if (pathname.getDevice().cdr() instanceof Cons) {
    407     //   return error(new FileError("Unimplemented directory listing of JAR within JAR.", pathname));
    408     // }
    409    
    410424    if (directory.length() == 0) {
    411425      directory = "/*";
     
    419433
    420434    Pathname wildcard = (Pathname)Pathname.create(directory);
    421     //    String wildcard = new SimpleString(directory);
    422     // directories in a a jar aren't marked with a suffixed slash
    423     //    SimpleString wildcardDirectory = new SimpleString(directory + "/");
    424435
    425436    LispObject result = NIL;
    426     //LispObject matches;
    427437   
    428438    Iterator<Map.Entry<PathnameJar,ZipEntry>> iterator = ZipCache.getEntriesIterator(pathname);
     
    430440      Map.Entry<PathnameJar,ZipEntry> e = iterator.next();
    431441      PathnameJar entry = e.getKey();
    432       // PathnameJar jarPath = (PathnameJar)PathnameJar.create(e.getKey());
    433       // ZipEntry entry = e.getValue();
    434      
    435       // if (entryName.endsWith("/")) {
    436       //   matches = Symbol.PATHNAME_MATCH_P
    437       //     .execute(new SimpleString(entryName), wildcardDirectory);
    438       // } else {
    439       //   matches = Symbol.PATHNAME_MATCH_P.
    440       //     execute(new SimpleString(entryName), wildcard);
    441       // }
    442442      if (!Symbol.PATHNAME_MATCH_P.execute(entry, wildcard).equals(NIL)) {
    443443        result = result.push(entry);
     
    469469        return new FileError("Not a wild pathname.", pathname);
    470470      }
    471       if (!((PathnameJar)pathname).getJars().cdr().equals(NIL)) {
    472         return simple_error("Unimplemented match on contents of inner jars"); // FIXME
    473       }
    474471
    475472      PathnameJar jarPathname = new PathnameJar();
    476       jarPathname.copyFrom(pathname);
    477473      jarPathname
     474        .copyFrom(pathname)
    478475        .setDirectory(NIL)
    479476        .setName(NIL)
     
    499496      }
    500497
    501       // FIXME implement recursive jars
    502       // if (pathname.getDevice().cdr() instanceof Cons) {
    503       //   ZipFile outerJar = ZipCache.get((Pathname)pathname.getDevice().car());
    504       //   String entryPath = ((Pathname)pathname.getDevice().cdr().car()).getNamestring(); //???
    505       //   if (entryPath.startsWith("/")) {
    506       //     entryPath = entryPath.substring(1);
    507       //   }
    508       //   ZipEntry entry = outerJar.getEntry(entryPath);
    509       //   InputStream inputStream = null;
    510       //   try {
    511       //     inputStream = outerJar.getInputStream(entry);
    512       //   } catch (IOException e) {
    513       //     return new FileError("Failed to read zip input stream inside zip.",
    514       //                          pathname);
    515       //   }
    516       //   ZipInputStream zipInputStream
    517       //     = new ZipInputStream(inputStream);
    518 
    519       //   try {
    520       //     while ((entry = zipInputStream.getNextEntry()) != null) {
    521       //       String entryName = "/" + entry.getName();
    522       //       LispObject matches = Symbol.PATHNAME_MATCH_P
    523       //         .execute(new SimpleString(entryName), wildcard);
    524            
    525       //       if (!matches.equals(NIL)) {
    526       //         String namestring = new String(pathname.getNamestring());
    527       //         namestring = namestring.substring(0, namestring.lastIndexOf("!/") + 2)
    528       //           + entry.getName();
    529       //         Pathname p = (Pathname)Pathname.create(namestring);
    530       //         result = new Cons(p, result);
    531       //       }
    532       //     }
    533       //   } catch (IOException e) {
    534       //     return new FileError("Failed to seek through zip inputstream inside zip.",
    535       //                          pathname);
    536       //   }
    537       // } else {
    538       // }
    539498      return result;
    540499    }
     
    555514    return 0;
    556515  }
     516
     517  static PathnameJar joinEntry(PathnameJar root, Pathname entry) {
     518    PathnameJar result = new PathnameJar();
     519    result
     520      .copyFrom(root)
     521      .setDirectory(entry.getDirectory())
     522      .setName(entry.getName())
     523      .setType(entry.getType()); // ??? VERSION
     524    return result;
     525  }
     526
     527  static LispObject makeDeviceFrom(PathnameJar p) {
     528    PathnameJar result = new PathnameJar();
     529    result.copyFrom(p);
     530    Pathname rootJar = (Pathname)result.getRootJar();
     531    if (!rootJar.equals(NIL)
     532        && (rootJar instanceof Pathname)) {
     533      rootJar = (Pathname)PathnameURL.createFromFile(rootJar);
     534      result.setDevice(new Cons(rootJar, result.getJars().cdr()));
     535    }
     536    return result;
     537  }
     538
     539  static LispObject makeJarDeviceFrom(Pathname p) {
     540    PathnameJar result = new PathnameJar();
     541    result.copyFrom(p);
     542    Pathname rootJar = (Pathname)result.getRootJar();
     543    // Ensure
     544    if (!rootJar.equals(NIL)
     545        && (rootJar instanceof Pathname)) {
     546      rootJar = (Pathname)PathnameURL.createFromFile(rootJar);
     547      result.setDevice(new Cons(rootJar, result.getJars().cdr()));
     548    }
     549    return result.getDevice();
     550  }
    557551}
  • trunk/abcl/src/org/armedbear/lisp/PathnameURL.java

    r15404 r15405  
    5959  }
    6060
     61  public static PathnameURL create(Pathname p) {
     62    return (PathnameURL)createFromFile((Pathname)p);
     63  }
     64
    6165  public static PathnameURL create(PathnameURL p) {
    6266    return (PathnameURL) PathnameURL.create(p.getNamestring());
     
    7175  }
    7276
    73   public static LispObject create(String s) {
     77  public static LispObject createFromFile(Pathname p) {
     78    String ns = "file:" + p.getNamestring();
     79    return create(ns);
     80  }
     81
     82  public static PathnameURL create(String s) {
    7483    if (!isValidURL(s)) {
    7584      parse_error("Cannot form a PATHNAME-URL from " + s);
     
    8493      url = new URL(s);
    8594    } catch (MalformedURLException e) {
    86       return parse_error("Malformed URL in namestring '" + s + "': " + e.toString());
     95      parse_error("Malformed URL in namestring '" + s + "': " + e.toString());
     96      return (PathnameURL) UNREACHED;
    8797    }
    8898    String scheme = url.getProtocol();
     
    92102        uri = new URI(s);
    93103      } catch (URISyntaxException ex) {
    94         return parse_error("Improper URI syntax for "
    95                            + "'" + url.toString() + "'"
    96                            + ": " + ex.toString());
     104        parse_error("Improper URI syntax for "
     105        + "'" + url.toString() + "'"
     106        + ": " + ex.toString());
     107  return (PathnameURL)UNREACHED;
    97108      }
    98109           
     
    103114        uriPath = uri.getSchemeSpecificPart();
    104115        if (uriPath == null || uriPath.equals("")) {
    105           return parse_error("The namestring URI has no path: " + uri);
     116          parse_error("The namestring URI has no path: " + uri);
     117    return (PathnameURL)UNREACHED;
    106118        }
    107119      }
     
    126138      uri = url.toURI().normalize();
    127139    } catch (URISyntaxException e) {
    128       return parse_error("Couldn't form URI from "
    129                          + "'" + url + "'"
    130                          + " because: " + e);
     140      parse_error("Couldn't form URI from "
     141      + "'" + url + "'"
     142      + " because: " + e);
     143      return (PathnameURL)UNREACHED;
    131144    }
    132145    String authority = uri.getAuthority();
     
    265278  }
    266279
     280  public static LispObject truename(Pathname p, boolean errorIfDoesNotExist) {
     281    PathnameURL pathnameURL = (PathnameURL)PathnameURL.createFromFile(p);
     282    return PathnameURL.truename(pathnameURL, errorIfDoesNotExist);
     283  }
     284
    267285  public static LispObject truename(PathnameURL p, boolean errorIfDoesNotExist) {
    268286    if (p.getHost().equals(NIL)
    269         || Symbol.GETF.execute(p.getHost(), PathnameURL.SCHEME, NIL).equals("file")) {
    270       return Pathname.truename((Pathname)p, errorIfDoesNotExist);
     287     || Symbol.GETF.execute(p.getHost(), PathnameURL.SCHEME, NIL)
     288          .equals("file")) {
     289      return Pathname.truename(p, errorIfDoesNotExist);
    271290    }
    272291       
  • trunk/abcl/src/org/armedbear/lisp/ZipCache.java

    r15400 r15405  
    211211    extends Archive
    212212  {
    213     InputStream source;
     213    ZipInputStream source;
     214
     215    // TODO wrap in a weak reference to allow JVM to possibly reclaim memory
     216    LinkedHashMap<PathnameJar, ByteArrayOutputStream> contents
     217      = new LinkedHashMap<PathnameJar, ByteArrayOutputStream>();
    214218
    215219    public InputStream getEntryAsInputStream(PathnameJar entry) {
     220      ByteArrayOutputStream bytes = contents.get(entry);
     221      if (bytes != null) {
     222        return new ByteArrayInputStream(bytes.toByteArray());
     223      }
    216224      return null;
    217225    }
    218226
     227    boolean populated = false;
     228
    219229    public ZipEntry getEntry(PathnameJar entry) {
    220       return null;
    221     }
    222 
    223     void populateAllEntries() {}
     230      if (!populated) {
     231        populateAllEntries();
     232      }
     233      ZipEntry result = entries.get(entry);
     234      return result;
     235    }
     236
     237    void populateAllEntries() {
     238      if (populated) {
     239        return;
     240      }
     241      ZipEntry entry;
     242      try {
     243        while ((entry = source.getNextEntry()) != null) {
     244          String name = entry.getName();
     245          PathnameJar entryPathname
     246            = (PathnameJar)PathnameJar.createEntryFromJar(root, name);
     247          entries.put(entryPathname, entry);
     248          ByteArrayOutputStream bytes
     249            = readEntry(source);
     250          contents.put(entryPathname, bytes);
     251        }
     252        populated = true;
     253      } catch (IOException e) {
     254        simple_error("Failed to read entries from zip archive", root);
     255      }
     256    }
    224257
    225258    void close () {
     
    323356      try {
    324357        result = file.getInputStream(zipEntry);
    325       } catch (IOException e) {}
     358      } catch (IOException e) {} // FIXME how to signal a meaningful error?
    326359
    327360      return result;
     
    336369    }
    337370  }
    338  
    339371
    340372  static boolean cacheEnabled = true;
     
    368400  }
    369401
    370 
    371402  static ZipEntry getZipEntry(PathnameJar archiveEntry) {
    372403    PathnameJar archiveJar = archiveEntry.getArchive();
     
    376407  }
    377408
     409  // ??? we assume that DIRECTORY, NAME, and TYPE components are NIL
    378410  synchronized public static Archive getArchive(PathnameJar jar) {
    379     Archive cached = cache.get(jar);
    380     if (cached != null) {
    381       return cached;
     411    Archive result = cache.get(jar);
     412    if (result != null) {
     413      return result;
    382414    }
    383415
     
    392424      return getArchiveFile(jar);
    393425    } else {
    394       PathnameJar rootPathname = (PathnameJar)PathnameJar.createFromPathname(rootJar);
    395 
    396       Archive current = ZipCache.getArchive(rootPathname);
    397 
    398       // FIXME
    399       //while (innerJars.car() != NIL) {
    400       // TODO Finish me!
    401       // Pathname next = (Pathname)innerJars.car();
    402       //  String entryPath = next.asEntryPath();
    403       // InputStream source;
    404       // if (current instanceof ArchiveFile) {
    405       //   ArchiveFile zipFile = ((ArchiveFile)current).get();
    406       //   ZipEntry entry = zipFile.getEntry(entryPath);
    407       //   source = zipFile.getInputStream(entry);
    408       //   ArchiveStream stream = new ArchiveStream();
    409       //   stream.source = source;
    410       // }
    411       // }
    412 
    413       simple_error("Currently unimplemented recursive archive: ~a" , jar);
    414       return (Archive)UNREACHED;
     426      PathnameJar root = new PathnameJar();
     427      root.setDevice(new Cons(rootJar, NIL));
     428      ArchiveFile rootArchiveFile = (ArchiveFile)getArchiveFile(root);
     429
     430      PathnameJar innerArchive = new PathnameJar();
     431      Pathname nextJar = (Pathname)innerJars.car();
     432      LispObject jars = list(rootJar, nextJar);
     433      innerArchive.setDevice(jars);
     434
     435      PathnameJar innerArchiveAsEntry = new PathnameJar();
     436      innerArchiveAsEntry
     437        .setDevice(new Cons(rootJar, NIL))
     438        .setDirectory(nextJar.getDirectory())
     439        .setName(nextJar.getName())
     440        .setType(nextJar.getType());
     441
     442      ZipEntry entry = rootArchiveFile.getEntry(innerArchiveAsEntry);
     443      if (entry == null) {
     444        return null;
     445      }
     446      InputStream inputStream = rootArchiveFile.getEntryAsInputStream(innerArchiveAsEntry);
     447      if (inputStream == null) {
     448        return null;
     449      }
     450      ArchiveStream stream = new ArchiveStream();
     451      stream.source = new ZipInputStream(inputStream);
     452      stream.root = innerArchive;
     453      stream.lastModified = entry.getTime();
     454      result = stream;
     455      cache.put(innerArchive, result);
     456     
     457      innerJars = innerJars.cdr();
     458      while (innerJars.car() != NIL) {
     459        simple_error("Currently unimplemented nested zip archive of depth greater than two: ~a" , jar);
     460        return (Archive)UNREACHED;
     461      }
     462
     463      return result;
    415464    }
    416465  }
  • trunk/abcl/src/org/armedbear/lisp/probe_file.java

    r15395 r15405  
    5252        public LispObject execute(LispObject arg)
    5353        {
     54    if (arg == null || arg.equals(NIL)) {
     55      return NIL;
     56    }
    5457          Pathname p = coerceToPathname(arg);
     58          if (p.isWild()) {
     59            return error(new FileError("Cannot find the TRUENAME for a wild pathname.",
     60                                       p));
     61          }
    5562          // TODO: refactor Pathname{,Jar,URL}.truename() to be non-static?
    5663          if (p instanceof PathnameJar) {
    57             return PathnameJar.truename((PathnameJar)p, false);
     64            return PathnameJar.truename(p, false);
    5865          } else if (p instanceof PathnameURL) {
    59             return PathnameURL.truename((PathnameURL)p, false);
     66            return PathnameURL.truename(p, false);
    6067          } else {
    6168            return Pathname.truename(p, false);
     
    7784        {
    7885          Pathname p = coerceToPathname(arg);
     86          if (p.isWild()) {
     87            return error(new FileError("Cannot find the TRUENAME for a wild pathname.",
     88                                       p));
     89          }
     90
    7991          // TODO: refactor Pathname{,Jar,URL}.truename() to be non-static?
    8092          if (p instanceof PathnameJar) {
    81             return PathnameJar.truename((PathnameJar)p, true);
     93            return PathnameJar.truename(p, true);
    8294          } else if (p instanceof PathnameURL) {
    83             return PathnameURL.truename((PathnameURL)p, true);
     95            return PathnameURL.truename(p, true);
    8496          } else {
    8597            return Pathname.truename(p, true);
  • trunk/abcl/test/src/org/armedbear/lisp/ZipTest.java

    r15397 r15405  
    2020  // FIXME These need to be created as part of executing the tests
    2121  String zipFile = "/Users/evenson/work/abcl/dist/abcl-contrib.jar";
     22  // created via
     23  //   (require :abcl-contrib)
     24  //   (asdf:load-system :asdf-jar)
     25  //   (asdf-jar:package :cl-ppcre)
     26  String nestedJarFile = "/var/tmp/cl-ppcre-all-2.1.1.jar";
    2227  PathnameJar zip;
    23   String nestedJarFile = "/var/tmp/cl-ppcre-2.1.1.jar";
    2428  PathnameJar nestedJar;
    2529
     
    6165  }
    6266
     67  @Test
     68  public void getNestedJar() {
     69    String nestedNamestring = "jar:jar:file:/var/tmp/cl-ppcre-all-2.1.1.jar!/cl-ppcre/packages.abcl!/";
     70    PathnameJar nested = (PathnameJar)PathnameJar.create(nestedNamestring);
     71    ZipCache.Archive archive = ZipCache.getArchive(nested);
     72    assertTrue("Able to retrieve nested jar archive",
     73               !archive.equals(null));
     74  }
    6375
    64   @Test
    65   public void nestedJar() {
    66     String nestedNamestring = "jar:jar:file:/var/tmp/cl-ppcre-2.1.1.jar!/cl-ppcre/packages.abcl!/__loader__._";
    67     Pathname nested = (Pathname)PathnameJar.create(nestedNamestring);
     76  //  @Test
     77  public void getNestedJarEntry() {
     78    String nestedNamestring = "jar:jar:file:/var/tmp/cl-ppcre-all-2.1.1.jar!/cl-ppcre/packages.abcl!/__loader__._";
    6879  }
    69  
     80
    7081 
    7182
Note: See TracChangeset for help on using the changeset viewer.