/** * Refresh the jar entries. */ public synchronized boolean refresh() { boolean changed = false; // Only the root node needs to be refreshed. if(entry==null && new File(jarpath).lastModified()>lastmodified) { changed = true; this.lastmodified = new File(jarpath).lastModified(); // Read entries into multi-collection (path->entries). MultiCollection entries = createEntries(); // Recursively create files for entries. this.entryfiles = new HashMap(); this.entries = createFiles("/", entries); } // System.out.println("refresh: "+entry+", "+changed); return changed; }
/** * Refresh the jar entries. */ public synchronized boolean refresh() { boolean changed = false; // Only the root node needs to be refreshed. if(isRefresh() && new File(jarpath).lastModified()>lastmodified) { changed = true; this.lastmodified = new File(jarpath).lastModified(); // Read entries into multi-collection (path->entries). MultiCollection<String, ZipEntry> entries = createEntries(); // Recursively create files for entries. this.entryfiles = new HashMap<String, JarAsDirectory>(); this.entries = createFiles("/", entries); } // System.out.println("refresh: "+entry+", "+changed); return changed; }
/** * Create the files for an entry. * Recursive implementation for directory entries. */ public File[] createFiles(String key, MultiCollection entries) { Collection col = entries.getCollection(key); JarAsDirectory[] ret = new JarAsDirectory[col.size()]; Iterator it = col.iterator(); for(int i=0; it.hasNext(); i++) { ZipEntry entry = (ZipEntry)it.next(); ret[i] = new JarAsDirectory(jarpath, entry); if(ret[i].isDirectory()) { ret[i].entries = createFiles(ret[i].entry.getName(), entries); } entryfiles.put(entry.getName(), ret[i]); } // System.out.println("create files: "+key+", "+SUtil.arrayToString(ret)); return ret; }
/** * Create the files for an entry. * Recursive implementation for directory entries. */ public File[] createFiles(String key, MultiCollection<String, ZipEntry> entries) { Collection<ZipEntry> col = entries.getCollection(key); JarAsDirectory[] ret = new JarAsDirectory[col.size()]; Iterator<ZipEntry> it = col.iterator(); for(int i=0; it.hasNext(); i++) { ZipEntry entry = (ZipEntry)it.next(); ret[i] = new JarAsDirectory(jarpath, entry); if(ret[i].isDirectory()) { ret[i].entries = createFiles(ret[i].getEntryName(), entries); } entryfiles.put(entry.getName(), ret[i]); } // System.out.println("create files: "+key+", "+SUtil.arrayToString(ret)); return ret; }