bodewig 2005/02/18 05:15:28
Modified: . WHATSNEW
src/main/org/apache/tools/zip ZipOutputStream.java
src/testcases/org/apache/tools/zip ZipOutputStreamTest.java
Log:
Allo zip to store files with size between 2GB and 4GB
Revision Changes Path
1.750 +3 -0 ant/WHATSNEW
Index: WHATSNEW
===================================================================
RCS file: /home/cvs/ant/WHATSNEW,v
retrieving revision 1.749
retrieving revision 1.750
diff -u -r1.749 -r1.750
--- WHATSNEW 18 Feb 2005 12:24:15 -0000 1.749
+++ WHATSNEW 18 Feb 2005 13:15:28 -0000 1.750
@@ -325,6 +325,9 @@
* <zip>'s defaultexcludes attribute was ignored when an archive was
updated. Bugzilla Report 33412.
+* <zip> couldn't store files with size between 2GB and 4GB (the
+ upper limit set by the ZIP format itself). Bugzilla Report 33310.
+
Changes from Ant 1.6.1 to Ant 1.6.2
===================================
1.34 +18 -3 ant/src/main/org/apache/tools/zip/ZipOutputStream.java
Index: ZipOutputStream.java
===================================================================
RCS file: /home/cvs/ant/src/main/org/apache/tools/zip/ZipOutputStream.java,v
retrieving revision 1.33
retrieving revision 1.34
diff -u -r1.33 -r1.34
--- ZipOutputStream.java 2 Feb 2005 23:55:51 -0000 1.33
+++ ZipOutputStream.java 18 Feb 2005 13:15:28 -0000 1.34
@@ -336,8 +336,8 @@
deflate();
}
- entry.setSize(def.getTotalIn());
- entry.setComprSize(def.getTotalOut());
+ entry.setSize(adjustToLong(def.getTotalIn()));
+ entry.setComprSize(adjustToLong(def.getTotalOut()));
entry.setCrc(realCrc);
def.reset();
@@ -877,4 +877,19 @@
out.write(data, offset, length);
}
}
+
+ /**
+ * Assumes a negative integer really is a positive integer that
+ * has wrapped around and re-creates the original value.
+ *
+ * @since 1.34
+ */
+ protected static long adjustToLong(int i) {
+ if (i < 0) {
+ return 2 * ((long) Integer.MAX_VALUE) + 2 + i;
+ } else {
+ return i;
+ }
+ }
+
}
1.3 +10 -1
ant/src/testcases/org/apache/tools/zip/ZipOutputStreamTest.java
Index: ZipOutputStreamTest.java
===================================================================
RCS file:
/home/cvs/ant/src/testcases/org/apache/tools/zip/ZipOutputStreamTest.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- ZipOutputStreamTest.java 12 Nov 2004 12:15:13 -0000 1.2
+++ ZipOutputStreamTest.java 18 Feb 2005 13:15:28 -0000 1.3
@@ -1,5 +1,5 @@
/*
- * Copyright 2004 The Apache Software Foundation
+ * Copyright 2004-2005 The Apache Software Foundation
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -66,4 +66,13 @@
assertEquals(test.getValue(), zl.getValue());
}
+ public void testAdjustToLong() {
+ assertEquals((long) Integer.MAX_VALUE,
+ ZipOutputStream.adjustToLong(Integer.MAX_VALUE));
+ assertEquals(((long) Integer.MAX_VALUE) + 1,
+ ZipOutputStream.adjustToLong(Integer.MAX_VALUE + 1));
+ assertEquals(2 * ((long) Integer.MAX_VALUE),
+ ZipOutputStream.adjustToLong(2 * Integer.MAX_VALUE));
+ }
+
}
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]