Changeset 15435


Ignore:
Timestamp:
10/29/20 16:54:27 (2 years ago)
Author:
Mark Evenson
Message:

Initial implementation of accessing recursive entries in local jars

SYS:CLEAR-ZIP-CACHE will clear the cache

  • * *

Fix accessing remote jar contents

  • * *

Speculatively fix merging remote jar pathnames

Location:
trunk/abcl/src/org/armedbear/lisp
Files:
4 edited

Legend:

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

    r13440 r15435  
    151151  }
    152152
     153  @Override
     154  public int hashCode() {
     155    return this.sxhash();
     156  }
     157 
    153158  @Override
    154159  public final int sxhash()
  • trunk/abcl/src/org/armedbear/lisp/JarPathname.java

    r15423 r15435  
    343343
    344344  String getRootJarAsURLString() {
    345    return
    346      JarPathname.JAR_URI_PREFIX
    347      + ((Pathname)getRootJar()).getNamestring()
    348      + JarPathname.JAR_URI_SUFFIX;
     345    return
     346      JarPathname.JAR_URI_PREFIX
     347      + ((URLPathname)getRootJar()).getNamestring()
     348      + JarPathname.JAR_URI_SUFFIX;
    349349  }
    350350
     
    398398      return true;
    399399    }
    400     return super.isLocalFile();
     400    return false;
    401401  }
    402402
  • trunk/abcl/src/org/armedbear/lisp/Pathname.java

    r15424 r15435  
    17201720          }
    17211721        } else {
    1722     if (p.isLocalFile() && d.isLocalFile()) {
     1722    if (p.isLocalFile()) {
    17231723      result.setDevice(d.getDevice());
    17241724    } else {
  • trunk/abcl/src/org/armedbear/lisp/ZipCache.java

    r15425 r15435  
    280280        = (JarURLConnection) rootJarURL.openConnection();
    281281
    282       this.root = root;
    283       this.connection = connection;
     282      this.root = jar;
     283      this.connection = jarConnection;
    284284      this.file = (ZipFile)connection.getJarFile();
    285285      this.lastModified = connection.getLastModified();
     
    413413      return result;
    414414    }
    415 
    416415    Pathname rootJar = (Pathname) jar.getRootJar();
    417416    LispObject innerJars = jar.getJars().cdr();
     
    424423      return getArchiveFile(jar);
    425424    } else {
     425      result = getArchiveStreamFromFile(jar);
     426      cache.put(result.root, result);
     427
     428      JarPathname nextArchive = new JarPathname();
     429      nextArchive
     430        .setDevice(new Cons(rootJar,
     431                            new Cons(innerJars.car(), NIL)))
     432        .setDirectory(NIL)
     433        .setName(NIL)
     434        .setType(NIL);
     435     
     436      innerJars = innerJars.cdr();
     437      while (innerJars.car() != NIL) {
     438        Pathname nextJarArchive = (Pathname)innerJars.car();
     439
     440        JarPathname nextAsEntry = new JarPathname();
     441        nextAsEntry
     442          .setDevice(nextArchive.getDevice())
     443          .setDirectory(nextJarArchive.getDirectory())
     444          .setName(nextJarArchive.getName())
     445          .setType(nextJarArchive.getType());
     446        // FIXME
     447        // The pathnames for subsquent entries in a PATHNAME-JAR are relative.  Should they be?
     448        if (nextAsEntry.getDirectory().car().equals(Keyword.RELATIVE)) {
     449          LispObject directories = nextAsEntry.getDirectory();
     450          directories = directories.cdr();
     451          directories = directories.push(Keyword.ABSOLUTE);
     452          nextAsEntry.setDirectory(directories);
     453        }
     454        nextArchive.setDevice(nextArchive.getDevice().reverse().push(nextJarArchive).reverse());
     455        ArchiveStream stream = (ArchiveStream) result;
     456
     457        ZipEntry entry = stream.getEntry(nextAsEntry);
     458        if (entry == null) {
     459          return null;
     460        }
     461       
     462        InputStream inputStream = stream.getEntryAsInputStream(nextAsEntry);
     463        if (inputStream == null) {
     464          return null;
     465        }
     466        stream = new ArchiveStream(inputStream, nextArchive, entry);
     467        result = stream;
     468        cache.put(nextArchive, result);
     469
     470        innerJars = innerJars.cdr();
     471        if (innerJars.cdr().equals(NIL)
     472            && (!jar.getDirectory().equals(NIL)
     473                || !jar.getName().equals(NIL)
     474                || !jar.getType().equals(NIL))) {
     475          simple_error("Currently unimplemented retrieval of an entry in a nested pathnames");
     476          return (Archive)UNREACHED;
     477        }
     478      }
     479
     480      return result;
     481    }
     482  }
     483
     484  static ArchiveStream getArchiveStreamFromFile(JarPathname p) {
    426485      JarPathname root = new JarPathname();
    427       root.setDevice(new Cons(rootJar, NIL));
     486      root.setDevice(new Cons(p.getRootJar(), NIL));
     487      Pathname nextJar = (Pathname)p.getJars().cdr().car();     
    428488      ArchiveFile rootArchiveFile = (ArchiveFile)getArchiveFile(root);
    429489
    430490      JarPathname innerArchive = new JarPathname();
    431       Pathname nextJar = (Pathname)innerJars.car();
    432       LispObject jars = list(rootJar, nextJar);
     491
     492      LispObject jars = list(p.getRootJar(), nextJar);
    433493      innerArchive.setDevice(jars);
    434494
    435495      JarPathname innerArchiveAsEntry = new JarPathname();
    436496      innerArchiveAsEntry
    437         .setDevice(new Cons(rootJar, NIL))
     497        .setDevice(new Cons(root, NIL))
    438498        .setDirectory(nextJar.getDirectory())
    439499        .setName(nextJar.getName())
     
    448508        return null;
    449509      }
    450       ArchiveStream stream = new ArchiveStream(inputStream, innerArchive, entry);
    451       result = stream;
    452       cache.put(innerArchive, result);
    453      
    454       innerJars = innerJars.cdr();
    455       while (innerJars.car() != NIL) {
    456         simple_error("Currently unimplemented nested zip archive of depth greater than two: ~a" , jar);
    457         return (Archive)UNREACHED;
    458       }
    459 
    460       return result;
    461     }
    462   }
     510      ArchiveStream result = new ArchiveStream(inputStream, innerArchive, entry);
     511      return result;
     512  }
     513   
     514 
    463515
    464516  public static Archive getArchiveURL(JarPathname jar) {
     
    552604  }
    553605
     606  // ## clear-zip-cache  => boolean
     607  private static final Primitive CLEAR_ZIP_CACHE = new clear_zip_cache();
     608  private static class clear_zip_cache extends Primitive {
     609    clear_zip_cache() {
     610      super("clear-zip-cache", PACKAGE_SYS, true);
     611    }
     612    @Override
     613    public LispObject execute() {
     614      int size = cache.size();
     615      cache.clear();
     616      return size == 0 ? NIL : T;
     617    }
     618  }
     619
    554620  // ## remove-zip-cache-entry pathname => boolean
    555621  private static final Primitive REMOVE_ZIP_CACHE_ENTRY = new remove_zip_cache_entry();
Note: See TracChangeset for help on using the changeset viewer.