Author: bodewig
Date: Sat Aug 6 02:52:55 2011
New Revision: 1154435
URL: http://svn.apache.org/viewvc?rev=1154435&view=rev
Log:
After reading up what the InfoZIP people do I changed the data descriptor
logic. What seems to be the correct way is:
If you use a data descriptor and don't use ZIP64:
* set "version needed to extract" < 4.5
* set CRC and sizes in LFH to 0
* don't add any ZIP64 extended information extra field
* use four byte sizes in data descriptor
If you use a data descriptor and use ZIP64:
* set "version needed to extract" >= 4.5
* set CRC in LFH 0
* set sizes in LFH to 0xFFFFFFFF
* add a ZIP64 extended information extra field with sizes set to 0
* use eight byte sizes in data descriptor
Modified:
commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/zip/ZipArchiveOutputStream.java
commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/archivers/zip/Zip64SupportTest.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=1154435&r1=1154434&r2=1154435&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
Sat Aug 6 02:52:55 2011
@@ -771,8 +771,16 @@ public class ZipArchiveOutputStream exte
entry.localDataStart = written;
if (zipMethod == DEFLATED || raf != null) {
writeOut(LZERO);
- writeOut(LZERO);
- writeOut(LZERO);
+ if (zipMethod == DEFLATED && hasZip64Extra(entry.entry)) {
+ // point to ZIP64 extended information extra field for
+ // sizes, may get rewritten once sizes are known if
+ // stream is seekable
+ writeOut(ZipLong.ZIP64_MAGIC.getBytes());
+ writeOut(ZipLong.ZIP64_MAGIC.getBytes());
+ } else {
+ writeOut(LZERO);
+ writeOut(LZERO);
+ }
} else {
writeOut(ZipLong.getBytes(ze.getCrc()));
byte[] size = ZipLong.getBytes(Math.min(ze.getSize(),
ZIP64_MAGIC));
Modified:
commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/archivers/zip/Zip64SupportTest.java
URL:
http://svn.apache.org/viewvc/commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/archivers/zip/Zip64SupportTest.java?rev=1154435&r1=1154434&r2=1154435&view=diff
==============================================================================
---
commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/archivers/zip/Zip64SupportTest.java
(original)
+++
commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/archivers/zip/Zip64SupportTest.java
Sat Aug 6 02:52:55 2011
@@ -96,6 +96,7 @@ public class Zip64SupportTest {
"5GB_of_Zeros");
}
+ @Ignore
@Test public void read5GBOfZerosGeneratedByJava7JarUsingZipFile()
throws Throwable {
read5GBOfZerosUsingZipFileImpl(get5GBZerosFileGeneratedByJava7Jar(),
@@ -566,7 +567,6 @@ public class Zip64SupportTest {
*
* Creates a temporary archive of approx 4MB in size
*/
- @Ignore
@Test public void writeBigDeflatedEntryKnownSizeToStream()
throws Throwable {
withTemporaryArchive("writeBigDeflatedEntryKnownSizeToStream",
@@ -705,9 +705,11 @@ public class Zip64SupportTest {
// CRC
0, 0, 0, 0,
// Compressed Size
- 0, 0, 0, 0,
+ (byte) 0xFF, (byte) 0xFF,
+ (byte) 0xFF, (byte) 0xFF,
// Original Size
- 0, 0, 0, 0,
+ (byte) 0xFF, (byte) 0xFF,
+ (byte) 0xFF, (byte) 0xFF,
// file name length
1, 0,
// extra field length
@@ -883,7 +885,6 @@ public class Zip64SupportTest {
};
}
- @Ignore
@Test public void writeBigDeflatedEntryKnownSizeToFile()
throws Throwable {
withTemporaryArchive("writeBigDeflatedEntryKnownSizeToFile",
@@ -891,7 +892,6 @@ public class Zip64SupportTest {
true);
}
- @Ignore
@Test public void writeBigDeflatedEntryUnknownSizeToFile()
throws Throwable {
withTemporaryArchive("writeBigDeflatedEntryUnknownSizeToFile",