@Override public InputStream getEntryInputStream(ArchiveEntry entry, ArchiveEntryIterator entryIterator) throws IOException, UnsupportedFileOperationException { InputStream in = getInputStream(); ArchiveEntryIterator iterator = new ArArchiveEntryIterator(in); ArchiveEntry currentEntry; while((currentEntry = iterator.nextEntry())!=null) { if(currentEntry.getName().equals(entry.getName())) { LOGGER.trace("found entry {}", entry.getName()); return new BoundedInputStream(in, entry.getSize(), false); } } // Entry not found, should not normally happen LOGGER.info("Warning: entry not found, throwing IOException"); throw new IOException(); } }
/** * Returns the contents (direct children) of the specified tree node. * * @throws UnsupportedFileOperationException if {@link FileOperation#READ_FILE} operations are not supported by the * underlying file protocol. */ private AbstractFile[] ls(DefaultMutableTreeNode treeNode, AbstractFile parentFile, FilenameFilter filenameFilter, FileFilter fileFilter) throws IOException, UnsupportedFileOperationException { AbstractFile files[]; int nbChildren = treeNode.getChildCount(); // No FilenameFilter, create entry files and store them directly into an array if(filenameFilter==null) { files = new AbstractFile[nbChildren]; for(int c=0; c<nbChildren; c++) { files[c] = getArchiveEntryFile((ArchiveEntry)(((DefaultMutableTreeNode)treeNode.getChildAt(c)).getUserObject()), parentFile); } } // Use provided FilenameFilter and temporarily store created entry files that match the filter in a Vector else { Vector<AbstractFile> filesV = new Vector<AbstractFile>(); for(int c=0; c<nbChildren; c++) { ArchiveEntry entry = (ArchiveEntry)(((DefaultMutableTreeNode)treeNode.getChildAt(c)).getUserObject()); if(!filenameFilter.accept(entry.getName())) continue; filesV.add(getArchiveEntryFile(entry, parentFile)); } files = new AbstractFile[filesV.size()]; filesV.toArray(files); } return fileFilter==null?files:fileFilter.filter(files); }
return zin; throw new IOException("Unknown Zip entry: "+entry.getName());
throw new IOException("Unknown TAR entry: "+entry.getName());