commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bode...@apache.org
Subject svn commit: r1648164 - /commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/zip/ZipArchiveOutputStream.java
Date Sun, 28 Dec 2014 10:32:25 GMT
Author: bodewig
Date: Sun Dec 28 10:32:25 2014
New Revision: 1648164

URL: http://svn.apache.org/r1648164
Log:
don't duplicate the 'do I need zip64' check when creating central directory headers

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

Modified: commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/zip/ZipArchiveOutputStream.java
URL: http://svn.apache.org/viewvc/commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/zip/ZipArchiveOutputStream.java?rev=1648164&r1=1648163&r2=1648164&view=diff
==============================================================================
--- commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/zip/ZipArchiveOutputStream.java
(original)
+++ commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/zip/ZipArchiveOutputStream.java
Sun Dec 28 10:32:25 2014
@@ -1125,21 +1125,21 @@ public class ZipArchiveOutputStream exte
 
         handleZip64Extra(ze, lfhOffset, needsZip64Extra);
 
-        byte[] centralFileHeader = createCentralFileHeader(ze, getName(ze), lfhOffset);
+        byte[] centralFileHeader = createCentralFileHeader(ze, getName(ze), lfhOffset,
+                                                           needsZip64Extra);
         writeOut(centralFileHeader);
         written += centralFileHeader.length;
     }
+
     /**
      * Writes the central file header entry.
      * @param ze the entry to write
      * @param name The encoded name
      * @param lfhOffset Local file header offset for this file
      * @throws IOException on error
-     * @throws Zip64RequiredException if the archive's size exceeds 4
-     * GByte and {@link Zip64Mode #setUseZip64} is {@link
-     * Zip64Mode#Never}.
      */
-    private byte[] createCentralFileHeader(ZipArchiveEntry ze, ByteBuffer name, long lfhOffset)
throws IOException {
+    private byte[] createCentralFileHeader(ZipArchiveEntry ze, ByteBuffer name, long lfhOffset,
+                                           boolean needsZip64Extra) throws IOException {
         byte[] extra = ze.getCentralDirectoryExtra();
 
         // file comment length
@@ -1154,21 +1154,6 @@ public class ZipArchiveOutputStream exte
 
         System.arraycopy(CFH_SIG,  0, buf, CFH_SIG_OFFSET, WORD);
 
-        final boolean needsZip64Extra = hasZip64Extra(ze)
-                || ze.getCompressedSize() >= ZIP64_MAGIC
-                || ze.getSize() >= ZIP64_MAGIC
-                || lfhOffset >= ZIP64_MAGIC;
-
-        if (needsZip64Extra && zip64Mode == Zip64Mode.Never) {
-            // must be the offset that is too big, otherwise an
-            // exception would have been throw in putArchiveEntry or
-            // closeArchiveEntry
-            throw new Zip64RequiredException(Zip64RequiredException
-                    .ARCHIVE_TOO_BIG_MESSAGE);
-        }
-
-        // todo: Do in caller !  handleZip64Extra(ze, lfhOffset, needsZip64Extra);
-
         // version made by
         // CheckStyle:MagicNumber OFF
         putShort((ze.getPlatform() << 8) | (!hasUsedZip64 ? DATA_DESCRIPTOR_MIN_VERSION
: ZIP64_MIN_VERSION),



Mime
View raw message