/** * Retrieves the extra data for the central directory. * @return the central directory extra data */ public byte[] getCentralDirectoryExtra() { return ExtraFieldUtils.mergeCentralDirectoryData(getAllExtraFieldsNoCopy()); }
/** * Unfortunately {@link java.util.zip.ZipOutputStream * java.util.zip.ZipOutputStream} seems to access the extra data * directly, so overriding getExtra doesn't help - we need to * modify super's data directly. */ protected void setExtra() { super.setExtra(ExtraFieldUtils.mergeLocalFileDataData(getAllExtraFieldsNoCopy())); }
/** * Split the array into ExtraFields and populate them with the * given data as local file data, throwing an exception if the * data cannot be parsed. * @param data an array of bytes as it appears in local file data * @return an array of ExtraFields * @throws ZipException on error */ public static ZipExtraField[] parse(final byte[] data) throws ZipException { return parse(data, true, UnparseableExtraField.THROW); }
final ZipExtraField ze = createExtraField(headerId); try { if (local) {
final ZipExtraField ze = createExtraField(headerId); if (local) { ze.parseFromLocalFileData(data, start + WORD, length);
/** * Split the array into ExtraFields and populate them with the * given data, throwing an exception if the data cannot be parsed. * @param data an array of bytes * @param local whether data originates from the local file data * or the central directory * @return an array of ExtraFields * @throws ZipException on error */ public static ZipExtraField[] parse(final byte[] data, final boolean local) throws ZipException { return parse(data, local, UnparseableExtraField.THROW); }
try { ex[i] = ExtraFieldUtils .createExtraField(new ZipShort(extra[i] .getHeaderId() .getValue()));
/** * Retrieves the extra data for the central directory. * @return the central directory extra data */ public byte[] getCentralDirectoryExtra() { return ExtraFieldUtils.mergeCentralDirectoryData(getAllExtraFieldsNoCopy()); }
/** * Unfortunately {@link java.util.zip.ZipOutputStream * java.util.zip.ZipOutputStream} seems to access the extra data * directly, so overriding getExtra doesn't help - we need to * modify super's data directly. */ protected void setExtra() { super.setExtra(ExtraFieldUtils.mergeLocalFileDataData(getAllExtraFieldsNoCopy())); }
/** * Sets the central directory part of extra fields. * @param b an array of bytes to be parsed into extra fields */ public void setCentralDirectoryExtra(final byte[] b) { try { final ZipExtraField[] central = ExtraFieldUtils.parse(b, false, ExtraFieldUtils.UnparseableExtraField.READ); mergeExtraFields(central, false); } catch (final ZipException e) { throw new RuntimeException(e.getMessage(), e); //NOSONAR } }
/** * Parses the given bytes as extra field data and consumes any * unparseable data as an {@link UnparseableExtraFieldData} * instance. * @param extra an array of bytes to be parsed into extra fields * @throws RuntimeException if the bytes cannot be parsed * @throws RuntimeException on error */ @Override public void setExtra(final byte[] extra) throws RuntimeException { try { final ZipExtraField[] local = ExtraFieldUtils.parse(extra, true, ExtraFieldUtils.UnparseableExtraField.READ); mergeExtraFields(local, true); } catch (final ZipException e) { // actually this is not possible as of Commons Compress 1.1 throw new RuntimeException("Error parsing extra fields for entry: " //NOSONAR + getName() + " - " + e.getMessage(), e); } }
/** * 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 java.util.zip.ZipEntry entry) throws ZipException { super(entry); setName(entry.getName()); final byte[] extra = entry.getExtra(); if (extra != null) { setExtraFields(ExtraFieldUtils.parse(extra, true, ExtraFieldUtils .UnparseableExtraField.READ)); } else { // initializes extra data to an empty byte array setExtra(); } setMethod(entry.getMethod()); this.size = entry.getSize(); }
/** * Split the array into ExtraFields and populate them with the * given data as local file data, throwing an exception if the * data cannot be parsed. * @param data an array of bytes as it appears in local file data * @return an array of ExtraFields * @throws ZipException on error */ public static ZipExtraField[] parse(final byte[] data) throws ZipException { return parse(data, true, UnparseableExtraField.THROW); }
/** * Split the array into ExtraFields and populate them with the * given data, throwing an exception if the data cannot be parsed. * @param data an array of bytes * @param local whether data originates from the local file data * or the central directory * @return an array of ExtraFields * @throws ZipException on error */ public static ZipExtraField[] parse(final byte[] data, final boolean local) throws ZipException { return parse(data, local, UnparseableExtraField.THROW); }
/** * Sets the central directory part of extra fields. * @param b an array of bytes to be parsed into extra fields */ public void setCentralDirectoryExtra(final byte[] b) { try { final ZipExtraField[] central = ExtraFieldUtils.parse(b, false, ExtraFieldUtils.UnparseableExtraField.READ); mergeExtraFields(central, false); } catch (final ZipException e) { throw new RuntimeException(e.getMessage(), e); //NOSONAR } }
/** * Parses the given bytes as extra field data and consumes any * unparseable data as an {@link UnparseableExtraFieldData} * instance. * @param extra an array of bytes to be parsed into extra fields * @throws RuntimeException if the bytes cannot be parsed * @throws RuntimeException on error */ @Override public void setExtra(final byte[] extra) throws RuntimeException { try { final ZipExtraField[] local = ExtraFieldUtils.parse(extra, true, ExtraFieldUtils.UnparseableExtraField.READ); mergeExtraFields(local, true); } catch (final ZipException e) { // actually this is not possible as of Commons Compress 1.1 throw new RuntimeException("Error parsing extra fields for entry: " //NOSONAR + getName() + " - " + e.getMessage(), e); } }
/** * 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 java.util.zip.ZipEntry entry) throws ZipException { super(entry); setName(entry.getName()); final byte[] extra = entry.getExtra(); if (extra != null) { setExtraFields(ExtraFieldUtils.parse(extra, true, ExtraFieldUtils .UnparseableExtraField.READ)); } else { // initializes extra data to an empty byte array setExtra(); } setMethod(entry.getMethod()); this.size = entry.getSize(); }