Esempio n. 1
0
 /**
  * If there are no extra fields, use the given fields as new extra data - otherwise merge the
  * fields assuming the existing fields and the new fields stem from different locations inside the
  * archive.
  *
  * @param f the extra fields to merge
  * @param local whether the new fields originate from local data
  */
 private void mergeExtraFields(ZipExtraField[] f, boolean local) throws ZipException {
   if (extraFields == null) {
     setExtraFields(f);
   } else {
     for (int i = 0; i < f.length; i++) {
       ZipExtraField existing;
       if (f[i] instanceof UnparseableExtraFieldData) {
         existing = unparseableExtra;
       } else {
         existing = getExtraField(f[i].getHeaderId());
       }
       if (existing == null) {
         addExtraField(f[i]);
       } else {
         if (local || !(existing instanceof CentralDirectoryParsingZipExtraField)) {
           byte[] b = f[i].getLocalFileDataData();
           existing.parseFromLocalFileData(b, 0, b.length);
         } else {
           byte[] b = f[i].getCentralDirectoryData();
           ((CentralDirectoryParsingZipExtraField) existing)
               .parseFromCentralDirectoryData(b, 0, b.length);
         }
       }
     }
     setExtra();
   }
 }
Esempio n. 2
0
  /**
   * Overwrite clone.
   *
   * @return a cloned copy of this ZipEntry
   * @since 1.1
   */
  public Object clone() {
    ZipEntry e = (ZipEntry) super.clone();

    e.setInternalAttributes(getInternalAttributes());
    e.setExternalAttributes(getExternalAttributes());
    e.setExtraFields(getExtraFields(true));
    return e;
  }
Esempio n. 3
0
 /**
  * Creates a new zip entry with fields taken from the specified zip entry.
  *
  * @param entry the entry to get fields from
  * @since 1.1
  * @throws ZipException on error
  */
 public ZipEntry(java.util.zip.ZipEntry entry) throws ZipException {
   super(entry);
   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();
   }
 }
Esempio n. 4
0
 /**
  * Creates a new zip entry with fields taken from the specified zip entry.
  *
  * @param entry the entry to get fields from
  * @throws ZipException on error
  * @since 1.1
  */
 public ZipEntry(ZipEntry entry) throws ZipException {
   this((java.util.zip.ZipEntry) entry);
   setInternalAttributes(entry.getInternalAttributes());
   setExternalAttributes(entry.getExternalAttributes());
   setExtraFields(entry.getExtraFields(true));
 }