commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bode...@apache.org
Subject svn commit: r1150985 - /commons/proper/compress/branches/zip64/src/main/java/org/apache/commons/compress/archivers/zip/ZipArchiveInputStream.java
Date Tue, 26 Jul 2011 04:38:35 GMT
Author: bodewig
Date: Tue Jul 26 04:38:35 2011
New Revision: 1150985

URL: http://svn.apache.org/viewvc?rev=1150985&view=rev
Log:
Assume a record is using ZIP64 if and only if the ZIP64 extended information
extra field is present.

http://www.pkware.com/documents/casestudies/APPNOTE.TXT says:

      When extracting, if 
      the zip64 extended information extra field is present for 
      the file the compressed and uncompressed sizes will be 8
      byte values.

when talking about the data descriptor, making the extra field the the
thing to decide upon.  InfoZip's ZIP 3.0 agrees with this interpretation.
I even found this in ZIP 3.0' zipfile.c:

      /* PKZIP does not care of the version set in a CDH: if  */
      /* there is a zip64 extra field assigned to a CDH PKZIP */
      /* uses it, we should do so, too.                       */

so "version made by" is ignored in the central directory.  The comment
is not present when looking at the local file header, I'm not yet decided
whether to ignore the version there as well.


Modified:
    commons/proper/compress/branches/zip64/src/main/java/org/apache/commons/compress/archivers/zip/ZipArchiveInputStream.java

Modified: commons/proper/compress/branches/zip64/src/main/java/org/apache/commons/compress/archivers/zip/ZipArchiveInputStream.java
URL: http://svn.apache.org/viewvc/commons/proper/compress/branches/zip64/src/main/java/org/apache/commons/compress/archivers/zip/ZipArchiveInputStream.java?rev=1150985&r1=1150984&r2=1150985&view=diff
==============================================================================
--- commons/proper/compress/branches/zip64/src/main/java/org/apache/commons/compress/archivers/zip/ZipArchiveInputStream.java
(original)
+++ commons/proper/compress/branches/zip64/src/main/java/org/apache/commons/compress/archivers/zip/ZipArchiveInputStream.java
Tue Jul 26 04:38:35 2011
@@ -210,17 +210,21 @@ public class ZipArchiveInputStream exten
         if (!hasUTF8Flag && useUnicodeExtraFields) {
             ZipUtil.setNameAndCommentFromExtraFields(current, fileName, null);
         }
+
+        Zip64ExtendedInformationExtraField z64 = null;
+        if (usesZip64) {
+            z64 = (Zip64ExtendedInformationExtraField)
+                current.getExtraField(Zip64ExtendedInformationExtraField
+                                      .HEADER_ID);
+            if (z64 == null) {
+                // "version made by" >= 4.5 for some other reason than ZIP64
+                usesZip64 = false;
+            }
+        }
         if (!hasDataDescriptor) {
             if (usesZip64 && (cSize.equals(ZipLong.ZIP64_MAGIC)
                               || size.equals(ZipLong.ZIP64_MAGIC))
                 ) {
-                Zip64ExtendedInformationExtraField z64 =
-                    (Zip64ExtendedInformationExtraField)
-                    current.getExtraField(Zip64ExtendedInformationExtraField
-                                          .HEADER_ID);
-                if (z64 == null) {
-                    throw new ZipException("expected ZIP64 extra field");
-                }
                 current.setCompressedSize(z64.getCompressedSize()
                                           .getLongValue());
                 current.setSize(z64.getSize().getLongValue());



Mime
View raw message