Example usage for org.apache.commons.compress.archivers.zip ExtraFieldUtils mergeLocalFileDataData

List of usage examples for org.apache.commons.compress.archivers.zip ExtraFieldUtils mergeLocalFileDataData

Introduction

In this page you can find the example usage for org.apache.commons.compress.archivers.zip ExtraFieldUtils mergeLocalFileDataData.

Prototype

public static byte[] mergeLocalFileDataData(ZipExtraField[] data) 

Source Link

Document

Merges the local file data fields of the given ZipExtraFields.

Usage

From source file:at.spardat.xma.xdelta.JarDelta.java

/**
 * Entry to new name./*from   ww  w .  j a va2  s.c  om*/
 *
 * @param source the source
 * @param name the name
 * @return the zip archive entry
 * @throws ZipException the zip exception
 */
public static ZipArchiveEntry entryToNewName(ZipArchiveEntry source, String name) throws ZipException {
    if (source.getName().equals(name))
        return new ZipArchiveEntry(source);
    ZipArchiveEntry ret = new ZipArchiveEntry(name);
    byte[] extra = source.getExtra();
    if (extra != null) {
        ret.setExtraFields(ExtraFieldUtils.parse(extra, true, ExtraFieldUtils.UnparseableExtraField.READ));
    } else {
        ret.setExtra(ExtraFieldUtils.mergeLocalFileDataData(source.getExtraFields(true)));
    }
    ret.setInternalAttributes(source.getInternalAttributes());
    ret.setExternalAttributes(source.getExternalAttributes());
    ret.setExtraFields(source.getExtraFields(true));
    ret.setCrc(source.getCrc());
    ret.setMethod(source.getMethod());
    ret.setSize(source.getSize());
    return ret;
}

From source file:at.spardat.xma.xdelta.JarPatcher.java

/**
 * Entry to new name.//ww  w .ja  v  a2s .  c  o m
 *
 * @param source the source
 * @param name the name
 * @return the zip archive entry
 * @throws ZipException the zip exception
 */
private ZipArchiveEntry copyEntry(ZipArchiveEntry source) throws ZipException {
    ZipArchiveEntry ret = new ZipArchiveEntry(source.getName());
    byte[] extra = source.getExtra();
    if (extra != null) {
        ret.setExtraFields(ExtraFieldUtils.parse(extra, true, ExtraFieldUtils.UnparseableExtraField.READ));
    } else {
        ret.setExtra(ExtraFieldUtils.mergeLocalFileDataData(source.getExtraFields(true)));
    }
    ret.setInternalAttributes(source.getInternalAttributes());
    ret.setExternalAttributes(source.getExternalAttributes());
    ret.setExtraFields(source.getExtraFields(true));
    return ret;
}