/** {@inheritDoc} */ public void parseFromCentralDirectoryData(byte[] buffer, int offset, int length) throws ZipException { // store for processing in reparseCentralDirectoryData rawCentralDirectoryData = new byte[length]; System.arraycopy(buffer, offset, rawCentralDirectoryData, 0, length); // if there is no size information in here, we are screwed and // can only hope things will get resolved by LFH data later // But there are some cases that can be detected // * all data is there // * length == 24 -> both sizes and offset // * length % 8 == 4 -> at least we can identify the diskStart field if (length >= 3 * DWORD + WORD) { parseFromLocalFileData(buffer, offset, length); } else if (length == 3 * DWORD) { size = new ZipEightByteInteger(buffer, offset); offset += DWORD; compressedSize = new ZipEightByteInteger(buffer, offset); offset += DWORD; relativeHeaderOffset = new ZipEightByteInteger(buffer, offset); } else if (length % DWORD == WORD) { diskStart = new ZipLong(buffer, offset + length - WORD); } }
/** {@inheritDoc} */ public void parseFromLocalFileData(byte[] buffer, int offset, int length) throws ZipException { if (length == 0) { // no local file data at all, may happen if an archive // only holds a ZIP64 extended information extra field // inside the central directory but not inside the local // file header return; } if (length < 2 * DWORD) { throw new ZipException(LFH_MUST_HAVE_BOTH_SIZES_MSG); } size = new ZipEightByteInteger(buffer, offset); offset += DWORD; compressedSize = new ZipEightByteInteger(buffer, offset); offset += DWORD; int remaining = length - 2 * DWORD; if (remaining >= DWORD) { relativeHeaderOffset = new ZipEightByteInteger(buffer, offset); offset += DWORD; remaining -= DWORD; } if (remaining >= WORD) { diskStart = new ZipLong(buffer, offset); offset += WORD; remaining -= WORD; } }
size = new ZipEightByteInteger(rawCentralDirectoryData, offset); offset += DWORD; compressedSize = new ZipEightByteInteger(rawCentralDirectoryData, offset); offset += DWORD; new ZipEightByteInteger(rawCentralDirectoryData, offset); offset += DWORD;
/** * If the entry needs Zip64 extra information inside the central * directory then configure its data. * * @param ze ZipEntry * @param lfhOffset long * @param needsZip64Extra boolean */ private void handleZip64Extra(ZipEntry ze, long lfhOffset, boolean needsZip64Extra) { if (needsZip64Extra) { Zip64ExtendedInformationExtraField z64 = getZip64Extra(ze); if (ze.getCompressedSize() >= ZIP64_MAGIC || ze.getSize() >= ZIP64_MAGIC) { z64.setCompressedSize(new ZipEightByteInteger(ze.getCompressedSize())); z64.setSize(new ZipEightByteInteger(ze.getSize())); } else { // reset value that may have been set for LFH z64.setCompressedSize(null); z64.setSize(null); } if (lfhOffset >= ZIP64_MAGIC) { z64.setRelativeHeaderOffset(new ZipEightByteInteger(lfhOffset)); } ze.setExtra(); } }
ze.setSize(z64.getSize().getLongValue()); } else if (hasCompressedSize) { z64.setSize(new ZipEightByteInteger(ze.getSize())); ze.setCompressedSize(z64.getCompressedSize().getLongValue()); } else if (hasUncompressedSize) { z64.setCompressedSize(new ZipEightByteInteger(ze.getCompressedSize()));
&& entry.entry.getSize() != -1) { size = new ZipEightByteInteger(entry.entry.getSize()); compressedSize = size;