/** * Creates a new zip entry with fields taken from the specified zip entry. * * <p>Assumes the entry represents a directory if and only if the * name ends with a forward slash "/".</p> * * @param entry the entry to get fields from * @throws ZipException on error */ public ZipArchiveEntry(final ZipArchiveEntry entry) throws ZipException { this((java.util.zip.ZipEntry) entry); setInternalAttributes(entry.getInternalAttributes()); setExternalAttributes(entry.getExternalAttributes()); setExtraFields(getAllExtraFieldsNoCopy()); setPlatform(entry.getPlatform()); final GeneralPurposeBit other = entry.getGeneralPurposeBit(); setGeneralPurposeBit(other == null ? null : (GeneralPurposeBit) other.clone()); }
final ZipEncoding entryEncoding = hasUTF8Flag ? ZipEncodingHelper.UTF8_ZIP_ENCODING : zipEncoding; current.hasDataDescriptor = gpFlag.usesDataDescriptor(); current.entry.setGeneralPurposeBit(gpFlag);
/** * Creates a new zip entry with fields taken from the specified zip entry. * * <p>Assumes the entry represents a directory if and only if the * name ends with a forward slash "/".</p> * * @param entry the entry to get fields from * @throws ZipException on error */ public ZipArchiveEntry(final ZipArchiveEntry entry) throws ZipException { this((java.util.zip.ZipEntry) entry); setInternalAttributes(entry.getInternalAttributes()); setExternalAttributes(entry.getExternalAttributes()); setExtraFields(getAllExtraFieldsNoCopy()); setPlatform(entry.getPlatform()); final GeneralPurposeBit other = entry.getGeneralPurposeBit(); setGeneralPurposeBit(other == null ? null : (GeneralPurposeBit) other.clone()); }
@Override public void writeEntry( ArchiveOutputStream archiveOutputStream, ArchiveEntry archiveEntry, @Nullable String name, ConsumerWhichThrows<? super OutputStream, ? extends IOException> writeContents ) throws IOException { if (!(archiveOutputStream instanceof ZipArchiveOutputStream)) { throw new IllegalArgumentException(archiveOutputStream.getClass().getName()); } ZipArchiveEntry nzae = new ZipArchiveEntry(name != null ? name : archiveEntry.getName()); nzae.setTime(archiveEntry.getLastModifiedDate().getTime()); if (archiveEntry instanceof ZipArchiveEntry) { ZipArchiveEntry zae = (ZipArchiveEntry) archiveEntry; nzae.setComment(zae.getComment()); nzae.setExternalAttributes(zae.getExternalAttributes()); nzae.setExtraFields(zae.getExtraFields(true)); nzae.setGeneralPurposeBit(zae.getGeneralPurposeBit()); nzae.setInternalAttributes(zae.getInternalAttributes()); nzae.setMethod(zae.getMethod()); if (nzae.isDirectory()) { nzae.setSize(0); nzae.setCrc(0); } } archiveOutputStream.putArchiveEntry(nzae); if (!archiveEntry.isDirectory()) writeContents.consume(archiveOutputStream); archiveOutputStream.closeArchiveEntry(); }
@Override public void writeEntry( ArchiveOutputStream archiveOutputStream, ArchiveEntry archiveEntry, @Nullable String name, ConsumerWhichThrows<? super OutputStream, ? extends IOException> writeContents ) throws IOException { if (!(archiveOutputStream instanceof ZipArchiveOutputStream)) { throw new IllegalArgumentException(archiveOutputStream.getClass().getName()); } ZipArchiveEntry nzae = new ZipArchiveEntry(name != null ? name : archiveEntry.getName()); nzae.setTime(archiveEntry.getLastModifiedDate().getTime()); if (archiveEntry instanceof ZipArchiveEntry) { ZipArchiveEntry zae = (ZipArchiveEntry) archiveEntry; nzae.setComment(zae.getComment()); nzae.setExternalAttributes(zae.getExternalAttributes()); nzae.setExtraFields(zae.getExtraFields(true)); nzae.setGeneralPurposeBit(zae.getGeneralPurposeBit()); nzae.setInternalAttributes(zae.getInternalAttributes()); nzae.setMethod(zae.getMethod()); if (nzae.isDirectory()) { nzae.setSize(0); nzae.setCrc(0); } } archiveOutputStream.putArchiveEntry(nzae); if (!archiveEntry.isDirectory()) writeContents.consume(archiveOutputStream); archiveOutputStream.closeArchiveEntry(); }
final ZipEncoding entryEncoding = hasUTF8Flag ? ZipEncodingHelper.UTF8_ZIP_ENCODING : zipEncoding; current.hasDataDescriptor = gpFlag.usesDataDescriptor(); current.entry.setGeneralPurposeBit(gpFlag);