Author: bodewig
Date: Thu Jul 21 13:18:36 2011
New Revision: 1149164

URL: http://svn.apache.org/viewvc?rev=1149164&view=rev
Log:
must override ZipEntry#setSize for Zip64 as base method throws an exception on 
entries bigger than 2GB.  COMPRESS-36

Modified:
    
commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/zip/ZipArchiveEntry.java

Modified: 
commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/zip/ZipArchiveEntry.java
URL: 
http://svn.apache.org/viewvc/commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/zip/ZipArchiveEntry.java?rev=1149164&r1=1149163&r2=1149164&view=diff
==============================================================================
--- 
commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/zip/ZipArchiveEntry.java
 (original)
+++ 
commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/zip/ZipArchiveEntry.java
 Thu Jul 21 13:18:36 2011
@@ -68,6 +68,14 @@ public class ZipArchiveEntry extends jav
      */
     private int method = -1;
 
+    /**
+     * The {@link java.util.zip.ZipEntry#setSize} method in the base
+     * class throws an IllegalArgumentException if the size is bigger
+     * than 2GB for Java versions < 7.  Need to keep our own size
+     * information for Zip64 support.
+     */
+    private long size = SIZE_UNKNOWN;
+
     private int internalAttributes = 0;
     private int platform = PLATFORM_FAT;
     private long externalAttributes = 0;
@@ -111,6 +119,7 @@ public class ZipArchiveEntry extends jav
             setExtra();
         }
         setMethod(entry.getMethod());
+        this.size = entry.getSize();
     }
 
     /**
@@ -496,6 +505,27 @@ public class ZipArchiveEntry extends jav
     }
 
     /**
+     * Gets the uncompressed size of the entry data.
+     * @return the entry size
+     */
+    public long getSize() {
+        return size;
+    }
+
+    /**
+     * Sets the uncompressed size of the entry data.
+     * @param size the uncompressed size in bytes
+     * @exception IllegalArgumentException if the specified size is less
+     *            than 0
+     */
+    public void setSize(long size) {
+        if (size < 0) {
+            throw new IllegalArgumentException("invalid entry size");
+        }
+        this.size = size;
+    }
+
+    /**
      * Get the hashCode of the entry.
      * This uses the name as the hashcode.
      * @return a hashcode.


Reply via email to