/** * Looks up an extra field by its header id. * * @param type the header id * @return null if no such field exists. */ public ZipExtraField getExtraField(final ZipShort type) { if (extraFields != null) { for (final ZipExtraField extraField : extraFields) { if (type.equals(extraField.getHeaderId())) { return extraField; } } } return null; }
/** * Remove an extra field. * @param type the type of extra field to remove */ public void removeExtraField(final ZipShort type) { if (extraFields == null) { throw new java.util.NoSuchElementException(); } final List<ZipExtraField> newResult = new ArrayList<>(); for (final ZipExtraField extraField : extraFields) { if (!type.equals(extraField.getHeaderId())){ newResult.add( extraField); } } if (extraFields.length == newResult.size()) { throw new java.util.NoSuchElementException(); } extraFields = newResult.toArray(new ZipExtraField[newResult.size()]); setExtra(); }
private void readTimeAttr(final byte[] data, int offset, final int length) { if (length >= 2 + 3 * 8) { final ZipShort tagValueLength = new ZipShort(data, offset); if (TIME_ATTR_SIZE.equals(tagValueLength)) { offset += 2; modifyTime = new ZipEightByteInteger(data, offset); offset += 8; accessTime = new ZipEightByteInteger(data, offset); offset += 8; createTime = new ZipEightByteInteger(data, offset); } } }
/** * Populate data from this array as if it was in local file data. * * @param data an array of bytes * @param offset the start offset * @param length the number of bytes in the array from offset * @throws java.util.zip.ZipException on error */ @Override public void parseFromLocalFileData( final byte[] data, int offset, final int length ) throws ZipException { final int len = offset + length; // skip reserved offset += 4; while (offset + 4 <= len) { final ZipShort tag = new ZipShort(data, offset); offset += 2; if (tag.equals(TIME_ATTR_TAG)) { readTimeAttr(data, offset, len - offset); break; } final ZipShort size = new ZipShort(data, offset); offset += 2 + size.getValue(); } }
/** * Looks up an extra field by its header id. * * @param type the header id * @return null if no such field exists. */ public ZipExtraField getExtraField(final ZipShort type) { if (extraFields != null) { for (final ZipExtraField extraField : extraFields) { if (type.equals(extraField.getHeaderId())) { return extraField; } } } return null; }
/** * Remove an extra field. * @param type the type of extra field to remove */ public void removeExtraField(final ZipShort type) { if (extraFields == null) { throw new java.util.NoSuchElementException(); } final List<ZipExtraField> newResult = new ArrayList<>(); for (final ZipExtraField extraField : extraFields) { if (!type.equals(extraField.getHeaderId())){ newResult.add( extraField); } } if (extraFields.length == newResult.size()) { throw new java.util.NoSuchElementException(); } extraFields = newResult.toArray(new ZipExtraField[newResult.size()]); setExtra(); }
private void readTimeAttr(final byte[] data, int offset, final int length) { if (length >= 2 + 3 * 8) { final ZipShort tagValueLength = new ZipShort(data, offset); if (TIME_ATTR_SIZE.equals(tagValueLength)) { offset += 2; modifyTime = new ZipEightByteInteger(data, offset); offset += 8; accessTime = new ZipEightByteInteger(data, offset); offset += 8; createTime = new ZipEightByteInteger(data, offset); } } }
/** * Populate data from this array as if it was in local file data. * * @param data an array of bytes * @param offset the start offset * @param length the number of bytes in the array from offset * @throws java.util.zip.ZipException on error */ @Override public void parseFromLocalFileData( final byte[] data, int offset, final int length ) throws ZipException { final int len = offset + length; // skip reserved offset += 4; while (offset + 4 <= len) { final ZipShort tag = new ZipShort(data, offset); offset += 2; if (tag.equals(TIME_ATTR_TAG)) { readTimeAttr(data, offset, len - offset); break; } final ZipShort size = new ZipShort(data, offset); offset += 2 + size.getValue(); } }