/** * Update the original {@link ZipArchiveEntry} with sizes/crc * Do not use this methods from threads that did not create the instance itself ! * @return the zipArchiveEntry that is basis for this request */ public ZipArchiveEntry transferToArchiveEntry(){ final ZipArchiveEntry entry = zipArchiveEntryRequest.getZipArchiveEntry(); entry.setCompressedSize(compressedSize); entry.setSize(size); entry.setCrc(crc); entry.setMethod(zipArchiveEntryRequest.getMethod()); return entry; } }
ze.setCrc(crc.getValue());
private void readDataDescriptor() throws IOException { readFully(wordBuf); ZipLong val = new ZipLong(wordBuf); if (ZipLong.DD_SIG.equals(val)) { // data descriptor with signature, skip sig readFully(wordBuf); val = new ZipLong(wordBuf); } current.entry.setCrc(val.getValue()); // if there is a ZIP64 extra field, sizes are eight bytes // each, otherwise four bytes each. Unfortunately some // implementations - namely Java7 - use eight bytes without // using a ZIP64 extra field - // https://bugs.sun.com/bugdatabase/view_bug.do?bug_id=7073588 // just read 16 bytes and check whether bytes nine to twelve // look like one of the signatures of what could follow a data // descriptor (ignoring archive decryption headers for now). // If so, push back eight bytes and assume sizes are four // bytes, otherwise sizes are eight bytes each. readFully(twoDwordBuf); final ZipLong potentialSig = new ZipLong(twoDwordBuf, DWORD); if (potentialSig.equals(ZipLong.CFH_SIG) || potentialSig.equals(ZipLong.LFH_SIG)) { pushback(twoDwordBuf, DWORD, DWORD); current.entry.setCompressedSize(ZipLong.getValue(twoDwordBuf)); current.entry.setSize(ZipLong.getValue(twoDwordBuf, WORD)); } else { current.entry.setCompressedSize(ZipEightByteInteger.getLongValue(twoDwordBuf)); current.entry.setSize(ZipEightByteInteger.getLongValue(twoDwordBuf, DWORD)); } }
current.entry.setCrc(ZipLong.getValue(lfhBuf, off)); off += WORD;
ze.setMethod( ZipArchiveEntry.STORED ); ze.setCrc( EMPTY_CRC );
protected ArchiveEntry newStoredEntry(String name, byte[] data) { ZipArchiveEntry zipEntry = new ZipArchiveEntry(name); zipEntry.setSize(data.length); zipEntry.setCompressedSize(zipEntry.getSize()); CRC32 crc32 = new CRC32(); crc32.update(data); zipEntry.setCrc(crc32.getValue()); return zipEntry; }
protected ArchiveEntry newStoredEntry(String name, byte[] data) { ZipArchiveEntry zipEntry = new ZipArchiveEntry(name); zipEntry.setSize(data.length); zipEntry.setCompressedSize(zipEntry.getSize()); CRC32 crc32 = new CRC32(); crc32.update(data); zipEntry.setCrc(crc32.getValue()); return zipEntry; }
protected ArchiveEntry newStoredEntry(String name, byte[] data) { ZipArchiveEntry zipEntry = new ZipArchiveEntry(name); zipEntry.setSize(data.length); zipEntry.setCompressedSize(zipEntry.getSize()); CRC32 crc32 = new CRC32(); crc32.update(data); zipEntry.setCrc(crc32.getValue()); return zipEntry; }
private static ArchiveEntry newTailArchive(String name, byte[] tail) { ZipArchiveEntry zipEntry = new ZipArchiveEntry(name); zipEntry.setSize(tail.length); zipEntry.setCompressedSize(zipEntry.getSize()); CRC32 crc32 = new CRC32(); crc32.update(tail); zipEntry.setCrc(crc32.getValue()); return zipEntry; }
protected ArchiveEntry newStoredEntry(String name, byte[] data) { ZipArchiveEntry zipEntry = new ZipArchiveEntry(name); zipEntry.setSize(data.length); zipEntry.setCompressedSize(zipEntry.getSize()); CRC32 crc32 = new CRC32(); crc32.update(data); zipEntry.setCrc(crc32.getValue()); return zipEntry; } }
private static ArchiveEntry newArchive(File file) throws IOException { ZipArchiveEntry zipEntry = new ZipArchiveEntry(file.getName()); zipEntry.setSize(file.length()); zipEntry.setCompressedSize(zipEntry.getSize()); zipEntry.setCrc(FileUtils.checksumCRC32(file)); return zipEntry; }
/** * Update the original {@link ZipArchiveEntry} with sizes/crc * Do not use this methods from threads that did not create the instance itself ! * @return the zipArchiveEntry that is basis for this request */ public ZipArchiveEntry transferToArchiveEntry(){ final ZipArchiveEntry entry = zipArchiveEntryRequest.getZipArchiveEntry(); entry.setCompressedSize(compressedSize); entry.setSize(size); entry.setCrc(crc); entry.setMethod(zipArchiveEntryRequest.getMethod()); return entry; } }
ze.setCrc(crc.getValue());
@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(); }
private void readDataDescriptor() throws IOException { readFully(wordBuf); ZipLong val = new ZipLong(wordBuf); if (ZipLong.DD_SIG.equals(val)) { // data descriptor with signature, skip sig readFully(wordBuf); val = new ZipLong(wordBuf); } current.entry.setCrc(val.getValue()); // if there is a ZIP64 extra field, sizes are eight bytes // each, otherwise four bytes each. Unfortunately some // implementations - namely Java7 - use eight bytes without // using a ZIP64 extra field - // http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=7073588 // just read 16 bytes and check whether bytes nine to twelve // look like one of the signatures of what could follow a data // descriptor (ignoring archive decryption headers for now). // If so, push back eight bytes and assume sizes are four // bytes, otherwise sizes are eight bytes each. readFully(twoDwordBuf); final ZipLong potentialSig = new ZipLong(twoDwordBuf, DWORD); if (potentialSig.equals(ZipLong.CFH_SIG) || potentialSig.equals(ZipLong.LFH_SIG)) { pushback(twoDwordBuf, DWORD, DWORD); current.entry.setCompressedSize(ZipLong.getValue(twoDwordBuf)); current.entry.setSize(ZipLong.getValue(twoDwordBuf, WORD)); } else { current.entry.setCompressedSize(ZipEightByteInteger.getLongValue(twoDwordBuf)); current.entry.setSize(ZipEightByteInteger.getLongValue(twoDwordBuf, DWORD)); } }
current.entry.setCrc(ZipLong.getValue(lfhBuf, off)); off += WORD;