/** * Is there a ZIP64 extended information extra field for the * entry? * * @since 1.3 */ private boolean hasZip64Extra(final ZipArchiveEntry ze) { return ze.getExtraField(Zip64ExtendedInformationExtraField .HEADER_ID) != null; }
/** * Get the existing ZIP64 extended information extra field or * create a new one and add it to the entry. * * @since 1.3 */ private Zip64ExtendedInformationExtraField getZip64Extra(final ZipArchiveEntry ze) { if (entry != null) { entry.causedUseOfZip64 = !hasUsedZip64; } hasUsedZip64 = true; Zip64ExtendedInformationExtraField z64 = (Zip64ExtendedInformationExtraField) ze.getExtraField(Zip64ExtendedInformationExtraField .HEADER_ID); if (z64 == null) { /* System.err.println("Adding z64 for " + ze.getName() + ", method: " + ze.getMethod() + " (" + (ze.getMethod() == STORED) + ")" + ", channel: " + (channel != null)); */ z64 = new Zip64ExtendedInformationExtraField(); } // even if the field is there already, make sure it is the first one ze.addAsFirstExtraField(z64); return z64; }
/** * Adds an extra field - replacing an already present extra field * of the same type. * * <p>The new extra field will be the first one.</p> * @param ze an extra field */ public void addAsFirstExtraField(final ZipExtraField ze) { if (ze instanceof UnparseableExtraFieldData) { unparseableExtra = (UnparseableExtraFieldData) ze; } else { if (getExtraField(ze.getHeaderId()) != null){ removeExtraField(ze.getHeaderId()); } final ZipExtraField[] copy = extraFields; final int newLen = extraFields != null ? extraFields.length + 1: 1; extraFields = new ZipExtraField[newLen]; extraFields[0] = ze; if (copy != null){ System.arraycopy(copy, 0, extraFields, 1, extraFields.length - 1); } } setExtra(); }
/** * If the entry has Unicode*ExtraFields and the CRCs of the * names/comments match those of the extra fields, transfer the * known Unicode values from the extra field. */ static void setNameAndCommentFromExtraFields(final ZipArchiveEntry ze, final byte[] originalNameBytes, final byte[] commentBytes) { final UnicodePathExtraField name = (UnicodePathExtraField) ze.getExtraField(UnicodePathExtraField.UPATH_ID); final String newName = getUnicodeStringIfOriginalMatches(name, originalNameBytes); if (newName != null) { ze.setName(newName); ze.setNameSource(ZipArchiveEntry.NameSource.UNICODE_EXTRA_FIELD); } if (commentBytes != null && commentBytes.length > 0) { final UnicodeCommentExtraField cmt = (UnicodeCommentExtraField) ze.getExtraField(UnicodeCommentExtraField.UCOM_ID); final String newComment = getUnicodeStringIfOriginalMatches(cmt, commentBytes); if (newComment != null) { ze.setComment(newComment); ze.setCommentSource(ZipArchiveEntry.CommentSource.UNICODE_EXTRA_FIELD); } } }
/** * Adds an extra field - replacing an already present extra field * of the same type. * * <p>If no extra field of the same type exists, the field will be * added as last field.</p> * @param ze an extra field */ public void addExtraField(final ZipExtraField ze) { if (ze instanceof UnparseableExtraFieldData) { unparseableExtra = (UnparseableExtraFieldData) ze; } else { if (extraFields == null) { extraFields = new ZipExtraField[]{ ze}; } else { if (getExtraField(ze.getHeaderId())!= null){ removeExtraField(ze.getHeaderId()); } final ZipExtraField[] zipExtraFields = copyOf(extraFields, extraFields.length + 1); zipExtraFields[zipExtraFields.length -1] = ze; extraFields = zipExtraFields; } } setExtra(); }
private byte[] createLocalFileHeader(final ZipArchiveEntry ze, final ByteBuffer name, final boolean encodable, final boolean phased, long archiveOffset) { ResourceAlignmentExtraField oldAlignmentEx = (ResourceAlignmentExtraField) ze.getExtraField(ResourceAlignmentExtraField.ID); if (oldAlignmentEx != null) { ze.removeExtraField(ResourceAlignmentExtraField.ID);
existing = unparseableExtra; } else { existing = getExtraField(element.getHeaderId());
/** * Records whether a Zip64 extra is present and sets the size * information from it if sizes are 0xFFFFFFFF and the entry * doesn't use a data descriptor. */ private void processZip64Extra(final ZipLong size, final ZipLong cSize) { final Zip64ExtendedInformationExtraField z64 = (Zip64ExtendedInformationExtraField) current.entry.getExtraField(Zip64ExtendedInformationExtraField.HEADER_ID); current.usesZip64 = z64 != null; if (!current.hasDataDescriptor) { if (z64 != null // same as current.usesZip64 but avoids NPE warning && (cSize.equals(ZipLong.ZIP64_MAGIC) || size.equals(ZipLong.ZIP64_MAGIC)) ) { current.entry.setCompressedSize(z64.getCompressedSize().getLongValue()); current.entry.setSize(z64.getSize().getLongValue()); } else { current.entry.setCompressedSize(cSize.getValue()); current.entry.setSize(size.getValue()); } } }
public String getName() { try { final UnicodePathExtraField unicodePath = (UnicodePathExtraField) zipEntry.getExtraField( UnicodePathExtraField.UPATH_ID ); return unicodePath != null ? new String( unicodePath.getUnicodeName(), "UTF-8" ) : zipEntry.getName(); } catch ( final UnsupportedEncodingException e ) { throw new AssertionError( e ); } }
final Zip64ExtendedInformationExtraField z64 = (Zip64ExtendedInformationExtraField) ze.getExtraField(Zip64ExtendedInformationExtraField.HEADER_ID); if (z64 != null) { final boolean hasUncompressedSize = ze.getSize() == ZIP64_MAGIC;
/** * Is there a ZIP64 extended information extra field for the * entry? * * @since 1.3 */ private boolean hasZip64Extra(final ZipArchiveEntry ze) { return ze.getExtraField(Zip64ExtendedInformationExtraField .HEADER_ID) != null; }
/** * Get the existing ZIP64 extended information extra field or * create a new one and add it to the entry. * * @since 1.3 */ private Zip64ExtendedInformationExtraField getZip64Extra(final ZipArchiveEntry ze) { if (entry != null) { entry.causedUseOfZip64 = !hasUsedZip64; } hasUsedZip64 = true; Zip64ExtendedInformationExtraField z64 = (Zip64ExtendedInformationExtraField) ze.getExtraField(Zip64ExtendedInformationExtraField .HEADER_ID); if (z64 == null) { /* System.err.println("Adding z64 for " + ze.getName() + ", method: " + ze.getMethod() + " (" + (ze.getMethod() == STORED) + ")" + ", channel: " + (channel != null)); */ z64 = new Zip64ExtendedInformationExtraField(); } // even if the field is there already, make sure it is the first one ze.addAsFirstExtraField(z64); return z64; }
/** * Adds an extra field - replacing an already present extra field * of the same type. * * <p>The new extra field will be the first one.</p> * @param ze an extra field */ public void addAsFirstExtraField(final ZipExtraField ze) { if (ze instanceof UnparseableExtraFieldData) { unparseableExtra = (UnparseableExtraFieldData) ze; } else { if (getExtraField(ze.getHeaderId()) != null){ removeExtraField(ze.getHeaderId()); } final ZipExtraField[] copy = extraFields; final int newLen = extraFields != null ? extraFields.length + 1: 1; extraFields = new ZipExtraField[newLen]; extraFields[0] = ze; if (copy != null){ System.arraycopy(copy, 0, extraFields, 1, extraFields.length - 1); } } setExtra(); }
/** * If the entry has Unicode*ExtraFields and the CRCs of the * names/comments match those of the extra fields, transfer the * known Unicode values from the extra field. */ static void setNameAndCommentFromExtraFields(final ZipArchiveEntry ze, final byte[] originalNameBytes, final byte[] commentBytes) { final UnicodePathExtraField name = (UnicodePathExtraField) ze.getExtraField(UnicodePathExtraField.UPATH_ID); final String newName = getUnicodeStringIfOriginalMatches(name, originalNameBytes); if (newName != null) { ze.setName(newName); ze.setNameSource(ZipArchiveEntry.NameSource.UNICODE_EXTRA_FIELD); } if (commentBytes != null && commentBytes.length > 0) { final UnicodeCommentExtraField cmt = (UnicodeCommentExtraField) ze.getExtraField(UnicodeCommentExtraField.UCOM_ID); final String newComment = getUnicodeStringIfOriginalMatches(cmt, commentBytes); if (newComment != null) { ze.setComment(newComment); ze.setCommentSource(ZipArchiveEntry.CommentSource.UNICODE_EXTRA_FIELD); } } }
/** * Adds an extra field - replacing an already present extra field * of the same type. * * <p>If no extra field of the same type exists, the field will be * added as last field.</p> * @param ze an extra field */ public void addExtraField(final ZipExtraField ze) { if (ze instanceof UnparseableExtraFieldData) { unparseableExtra = (UnparseableExtraFieldData) ze; } else { if (extraFields == null) { extraFields = new ZipExtraField[]{ ze}; } else { if (getExtraField(ze.getHeaderId())!= null){ removeExtraField(ze.getHeaderId()); } final ZipExtraField[] zipExtraFields = copyOf(extraFields, extraFields.length + 1); zipExtraFields[zipExtraFields.length -1] = ze; extraFields = zipExtraFields; } } setExtra(); }
private byte[] createLocalFileHeader(final ZipArchiveEntry ze, final ByteBuffer name, final boolean encodable, final boolean phased, long archiveOffset) { ResourceAlignmentExtraField oldAlignmentEx = (ResourceAlignmentExtraField) ze.getExtraField(ResourceAlignmentExtraField.ID); if (oldAlignmentEx != null) { ze.removeExtraField(ResourceAlignmentExtraField.ID);
existing = unparseableExtra; } else { existing = getExtraField(element.getHeaderId());
/** * Records whether a Zip64 extra is present and sets the size * information from it if sizes are 0xFFFFFFFF and the entry * doesn't use a data descriptor. */ private void processZip64Extra(final ZipLong size, final ZipLong cSize) { final Zip64ExtendedInformationExtraField z64 = (Zip64ExtendedInformationExtraField) current.entry.getExtraField(Zip64ExtendedInformationExtraField.HEADER_ID); current.usesZip64 = z64 != null; if (!current.hasDataDescriptor) { if (z64 != null // same as current.usesZip64 but avoids NPE warning && (cSize.equals(ZipLong.ZIP64_MAGIC) || size.equals(ZipLong.ZIP64_MAGIC)) ) { current.entry.setCompressedSize(z64.getCompressedSize().getLongValue()); current.entry.setSize(z64.getSize().getLongValue()); } else { current.entry.setCompressedSize(cSize.getValue()); current.entry.setSize(size.getValue()); } } }
final Zip64ExtendedInformationExtraField z64 = (Zip64ExtendedInformationExtraField) ze.getExtraField(Zip64ExtendedInformationExtraField.HEADER_ID); if (z64 != null) { final boolean hasUncompressedSize = ze.getSize() == ZIP64_MAGIC;