commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bode...@apache.org
Subject [1/3] commons-compress git commit: Zip64Mode.Always now impacts central file header same as local file header
Date Sat, 05 Mar 2016 20:58:02 GMT
Repository: commons-compress
Updated Branches:
  refs/heads/master 1d66f1208 -> 687b360f8


Zip64Mode.Always now impacts central file header same as local file header


Project: http://git-wip-us.apache.org/repos/asf/commons-compress/repo
Commit: http://git-wip-us.apache.org/repos/asf/commons-compress/commit/b88dd3ed
Tree: http://git-wip-us.apache.org/repos/asf/commons-compress/tree/b88dd3ed
Diff: http://git-wip-us.apache.org/repos/asf/commons-compress/diff/b88dd3ed

Branch: refs/heads/master
Commit: b88dd3ed853738b8e7fe9652b953db569bf7f79d
Parents: 1d66f12
Author: Matt Hovey <matt@weirdkid.com>
Authored: Tue Mar 1 00:04:26 2016 -0500
Committer: Stefan Bodewig <bodewig@apache.org>
Committed: Sat Mar 5 21:52:56 2016 +0100

----------------------------------------------------------------------
 .../archivers/zip/ZipArchiveOutputStream.java   | 20 ++++++++++++++------
 1 file changed, 14 insertions(+), 6 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/commons-compress/blob/b88dd3ed/src/main/java/org/apache/commons/compress/archivers/zip/ZipArchiveOutputStream.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/compress/archivers/zip/ZipArchiveOutputStream.java
b/src/main/java/org/apache/commons/compress/archivers/zip/ZipArchiveOutputStream.java
index 07ba405..068c97e 100644
--- a/src/main/java/org/apache/commons/compress/archivers/zip/ZipArchiveOutputStream.java
+++ b/src/main/java/org/apache/commons/compress/archivers/zip/ZipArchiveOutputStream.java
@@ -1157,7 +1157,8 @@ public class ZipArchiveOutputStream extends ArchiveOutputStream {
         final boolean needsZip64Extra = hasZip64Extra(ze)
                 || ze.getCompressedSize() >= ZIP64_MAGIC
                 || ze.getSize() >= ZIP64_MAGIC
-                || lfhOffset >= ZIP64_MAGIC;
+                || lfhOffset >= ZIP64_MAGIC
+                || zip64Mode == Zip64Mode.Always;
 
         if (needsZip64Extra && zip64Mode == Zip64Mode.Never) {
             // must be the offset that is too big, otherwise an
@@ -1220,7 +1221,8 @@ public class ZipArchiveOutputStream extends ArchiveOutputStream {
         // uncompressed length
         putLong(ze.getCrc(), buf, CFH_CRC_OFFSET);
         if (ze.getCompressedSize() >= ZIP64_MAGIC
-                || ze.getSize() >= ZIP64_MAGIC) {
+                || ze.getSize() >= ZIP64_MAGIC
+                || zip64Mode == Zip64Mode.Always) {
             ZipLong.ZIP64_MAGIC.putLong(buf, CFH_COMPRESSED_SIZE_OFFSET);
             ZipLong.ZIP64_MAGIC.putLong(buf, CFH_ORIGINAL_SIZE_OFFSET);
         } else {
@@ -1245,8 +1247,13 @@ public class ZipArchiveOutputStream extends ArchiveOutputStream {
         putLong(ze.getExternalAttributes(), buf, CFH_EXTERNAL_ATTRIBUTES_OFFSET);
 
         // relative offset of LFH
-        putLong(Math.min(lfhOffset, ZIP64_MAGIC), buf, CFH_LFH_OFFSET);
-
+        if(lfhOffset >= ZIP64_MAGIC || zip64Mode == Zip64Mode.Always){
+        	putLong(ZIP64_MAGIC, buf, CFH_LFH_OFFSET);
+        }
+        else{
+        	putLong(Math.min(lfhOffset, ZIP64_MAGIC), buf, CFH_LFH_OFFSET);
+        }
+        
         // file name
         System.arraycopy(name.array(), name.arrayOffset(), buf, CFH_FILENAME_OFFSET, nameLen);
 
@@ -1269,7 +1276,8 @@ public class ZipArchiveOutputStream extends ArchiveOutputStream {
         if (needsZip64Extra) {
             Zip64ExtendedInformationExtraField z64 = getZip64Extra(ze);
             if (ze.getCompressedSize() >= ZIP64_MAGIC
-                || ze.getSize() >= ZIP64_MAGIC) {
+                || ze.getSize() >= ZIP64_MAGIC
+                || zip64Mode == Zip64Mode.Always) {
                 z64.setCompressedSize(new ZipEightByteInteger(ze.getCompressedSize()));
                 z64.setSize(new ZipEightByteInteger(ze.getSize()));
             } else {
@@ -1277,7 +1285,7 @@ public class ZipArchiveOutputStream extends ArchiveOutputStream {
                 z64.setCompressedSize(null);
                 z64.setSize(null);
             }
-            if (lfhOffset >= ZIP64_MAGIC) {
+            if (lfhOffset >= ZIP64_MAGIC || zip64Mode == Zip64Mode.Always) {
                 z64.setRelativeHeaderOffset(new ZipEightByteInteger(lfhOffset));
             }
             ze.setExtra();


Mime
View raw message