/** * Note: the file sizes are rounded up to the next cipher block size, * so don't rely on file sizes of these custom encrypted zip file entries! */ @Override public Enumeration<? extends ZipArchiveEntry> getEntries() { return zipFile.getEntries(); }
@Override public Enumeration<? extends ZipArchiveEntry> getEntries() { if (zipArchive == null) throw new IllegalStateException("Zip File is closed"); return zipArchive.getEntries(); }
/** * Expands {@code archive} into {@code targetDirectory}. * * @param archive the file to expand * @param targetDirectory the directory to write to * @throws IOException if an I/O error occurs * @throws ArchiveException if the archive cannot be read for other reasons */ public void expand(final ZipFile archive, File targetDirectory) throws IOException, ArchiveException { final Enumeration<ZipArchiveEntry> entries = archive.getEntries(); expand(new ArchiveEntrySupplier() { @Override public ArchiveEntry getNextReadableEntry() throws IOException { ZipArchiveEntry next = entries.hasMoreElements() ? entries.nextElement() : null; while (next != null && !archive.canReadEntryData(next)) { next = entries.hasMoreElements() ? entries.nextElement() : null; } return next; } }, new EntryWriter() { @Override public void writeEntryDataTo(ArchiveEntry entry, OutputStream out) throws IOException { try (InputStream in = archive.getInputStream((ZipArchiveEntry) entry)) { IOUtils.copy(in, out); } } }, targetDirectory); }
@Override public ZipArchiveEntry getEntry(final String path) { String normalizedPath = path.replace('\\', '/'); final ZipArchiveEntry entry = zipArchive.getEntry(normalizedPath); if (entry != null) { return entry; } // the opc spec allows case-insensitive filename matching (see #49609) for (final ZipArchiveEntry ze : asIterable(asIterator(zipArchive.getEntries()))) { if (normalizedPath.equalsIgnoreCase(ze.getName().replace('\\','/'))) { return ze; } } return null; } }
if (zip.getEntry("META-INF/MANIFEST.MF") != null || zip.getEntry("META-INF/maven") != null) { final Enumeration<ZipArchiveEntry> entries = zip.getEntries(); while (entries.hasMoreElements()) { final ZipArchiveEntry entry = entries.nextElement();
Enumeration entries = zf.getEntries(); while (entries.hasMoreElements()) { ZipArchiveEntry entry = (ZipArchiveEntry) entries.nextElement();
public static MediaType detect(ZipFile zipFile) { MediaType type = null; Enumeration<? extends ZipEntry> entries = zipFile.getEntries(); while (entries.hasMoreElements()) { ZipEntry entry = entries.nextElement(); type = IWork13DocumentType.detectIfPossible(entry); if (type != null) return type; } // If we get here, we don't know what it is return UNKNOWN13.getType(); }
@SuppressWarnings("unchecked") private static MediaType detectIpa(ZipFile zip) { // Note - consider generalising this logic, if another format needs many regexp matching Set<Pattern> tmpPatterns = (Set<Pattern>)ipaEntryPatterns.clone(); Enumeration<ZipArchiveEntry> entries = zip.getEntries(); while (entries.hasMoreElements()) { ZipArchiveEntry entry = entries.nextElement(); String name = entry.getName(); Iterator<Pattern> ip = tmpPatterns.iterator(); while (ip.hasNext()) { if (ip.next().matcher(name).matches()) { ip.remove(); } } if (tmpPatterns.isEmpty()) { // We've found everything we need to find return MediaType.application("x-itunes-ipa"); } } // If we get here, not all required entries were found return null; }
private static MediaType detectKmz(ZipFile zip) { boolean kmlFound = false; Enumeration<ZipArchiveEntry> entries = zip.getEntries(); while (entries.hasMoreElements()) { ZipArchiveEntry entry = entries.nextElement(); String name = entry.getName(); if (!entry.isDirectory() && name.indexOf('/') == -1 && name.indexOf('\\') == -1) { if (name.endsWith(".kml") && !kmlFound) { kmlFound = true; } else { return null; } } } if (kmlFound) { return MediaType.application("vnd.google-earth.kmz"); } else { return null; } }
Enumeration<ZipArchiveEntry> entries = zf.getEntries(); HashSet<String> dirSet = new HashSet<String>(); while ( entries.hasMoreElements() )
protected Map<String, String> readZipArchive(InputStream inputStream) throws IOException { Map<String, String> data = new HashMap<String, String>(); Path tempFile = writeTemporaryArchiveFile(inputStream, "zip"); ZipFile zip = new ZipFile(tempFile.toFile()); Enumeration<ZipArchiveEntry> entries = zip.getEntries(); while (entries.hasMoreElements()) { ZipArchiveEntry entry = entries.nextElement(); ByteArrayOutputStream bos = new ByteArrayOutputStream(); IOUtils.copy(zip.getInputStream(entry), bos); data.put(entry.getName(), DigestUtils.md5Hex(bos.toByteArray())); } zip.close(); Files.delete(tempFile); return data; }
Enumeration<? extends ZipEntry> entries = zipFile.getEntries(); while (entries.hasMoreElements()) { ZipEntry entry = entries.nextElement();
/** * Note: the file sizes are rounded up to the next cipher block size, * so don't rely on file sizes of these custom encrypted zip file entries! */ @Override public Enumeration<? extends ZipArchiveEntry> getEntries() { return zipFile.getEntries(); }
@Override public Enumeration<? extends ZipArchiveEntry> getEntries() { if (zipArchive == null) throw new IllegalStateException("Zip File is closed"); return zipArchive.getEntries(); }
private static boolean zipFileHasExactlyOneEntry(ZipFile file) { Enumeration<ZipArchiveEntry> entries = file.getEntries(); if (entries.hasMoreElements()) { entries.nextElement(); return !entries.hasMoreElements(); } else { return false; } }
/** * Wrap a {@link Path} object. * * @throws IOException if there are issues with the underlying archive */ public ZipArchiveEntryByteIterator(Path p) throws IOException { this.zf = new ZipFile(p.toFile()); this.iter = this.zf.getEntries(); }
public ZipReader open() throws IOException { LOGGER.info("Reading zip file: {}", file); zipFile = new ZipFile(file); entries = zipFile.getEntries(); return this; }
public String getContents() throws IOException { ZipFile zipFile = new ZipFile(this); StringBuffer sb = new StringBuffer(); /* Get all elements */ Enumeration entries = zipFile.getEntries(); while (entries.hasMoreElements()) { ZipArchiveEntry entry = (ZipArchiveEntry) entries.nextElement(); sb.append(entry.getName()); sb.append('\n'); } return sb.toString(); }
public void printContents(PrintStream ps) throws IOException { ZipFile zipFile = new ZipFile(this); /* First create all directories */ Enumeration entries = zipFile.getEntries(); while (entries.hasMoreElements()) { ZipArchiveEntry entry = (ZipArchiveEntry) entries.nextElement(); ps.println(entry.getName()); } }
public static MediaType detect(ZipFile zipFile) { MediaType type = null; Enumeration<? extends ZipEntry> entries = zipFile.getEntries(); while (entries.hasMoreElements()) { ZipEntry entry = entries.nextElement(); type = IWork13DocumentType.detectIfPossible(entry); if (type != null) return type; } // If we get here, we don't know what it is return UNKNOWN13.getType(); }