Exemplo n.º 1
0
 /**
  * Sets the central directory part of extra fields.
  */
 public void setCentralDirectoryExtra(byte[] b)
 {
     try {
         ZipExtraField[] central =
             ExtraFieldUtils.parse(b, false,
                                   /*ExtraFieldUtils.*/ UnparseableExtraField.READ);
         mergeExtraFields(central, false);
     } catch (java.util.zip.ZipException e) {
         throw new java.lang.RuntimeException(e.getMessage(), e);
     }
 }
Exemplo n.º 2
0
 /**
  * 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
  */
 public override void setExtra(byte[] extra) //throws RuntimeException
 {
     try {
         ZipExtraField[] local =
             ExtraFieldUtils.parse(extra, true,
                                   /*ExtraFieldUtils.*/ UnparseableExtraField.READ);
         mergeExtraFields(local, true);
     } catch (java.util.zip.ZipException e) {
         // actually this is not be possible as of Commons Compress 1.1
         throw new java.lang.RuntimeException("Error parsing extra fields for entry: "
                                              + getName() + " - " + e.getMessage(), e);
     }
 }
Exemplo n.º 3
0
 /**
  * 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 "/".
  *
  * @param entry the entry to get fields from
  * @throws ZipException on error
  */
 public ZipArchiveEntry(java.util.zip.ZipEntry entry) : base(entry)  //throws ZipException
 {
     setName(entry.getName());
     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());
 }
Exemplo n.º 4
0
 /**
  * Retrieves the extra data for the central directory.
  * @return the central directory extra data
  */
 public byte[] getCentralDirectoryExtra()
 {
     return(ExtraFieldUtils.mergeCentralDirectoryData(getExtraFields(true)));
 }
Exemplo n.º 5
0
 /**
  * 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()
 {
     base.setExtra(ExtraFieldUtils.mergeLocalFileDataData(getExtraFields(true)));
 }