You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@ant.apache.org by bo...@apache.org on 2013/01/27 10:58:16 UTC
svn commit: r1439044 - in /ant/core/trunk: CONTRIBUTORS contributors.xml
src/main/org/apache/tools/zip/ZipFile.java
Author: bodewig
Date: Sun Jan 27 09:58:16 2013
New Revision: 1439044
URL: http://svn.apache.org/viewvc?rev=1439044&view=rev
Log:
improve performance when reading non zip64 zip files, merge from commons compress, based on patch by Robin Power
Modified:
ant/core/trunk/CONTRIBUTORS
ant/core/trunk/contributors.xml
ant/core/trunk/src/main/org/apache/tools/zip/ZipFile.java (contents, props changed)
Modified: ant/core/trunk/CONTRIBUTORS
URL: http://svn.apache.org/viewvc/ant/core/trunk/CONTRIBUTORS?rev=1439044&r1=1439043&r2=1439044&view=diff
==============================================================================
--- ant/core/trunk/CONTRIBUTORS (original)
+++ ant/core/trunk/CONTRIBUTORS Sun Jan 27 09:58:16 2013
@@ -298,6 +298,7 @@ Robert Streich
Robert Watkins
Roberto Scaramuzzi
Robin Green
+Robin Power
Robin Verduijn
Rob Oxspring
Rob van Oostrum
Modified: ant/core/trunk/contributors.xml
URL: http://svn.apache.org/viewvc/ant/core/trunk/contributors.xml?rev=1439044&r1=1439043&r2=1439044&view=diff
==============================================================================
--- ant/core/trunk/contributors.xml (original)
+++ ant/core/trunk/contributors.xml Sun Jan 27 09:58:16 2013
@@ -1203,6 +1203,10 @@
</name>
<name>
<first>Robin</first>
+ <last>Power</last>
+ </name>
+ <name>
+ <first>Robin</first>
<last>Verduijn</last>
</name>
<name>
Modified: ant/core/trunk/src/main/org/apache/tools/zip/ZipFile.java
URL: http://svn.apache.org/viewvc/ant/core/trunk/src/main/org/apache/tools/zip/ZipFile.java?rev=1439044&r1=1439043&r2=1439044&view=diff
==============================================================================
--- ant/core/trunk/src/main/org/apache/tools/zip/ZipFile.java (original)
+++ ant/core/trunk/src/main/org/apache/tools/zip/ZipFile.java Sun Jan 27 09:58:16 2013
@@ -666,12 +666,14 @@ public class ZipFile {
*/
private void positionAtCentralDirectory()
throws IOException {
- boolean found = tryToLocateSignature(MIN_EOCD_SIZE + ZIP64_EOCDL_LENGTH,
- MAX_EOCD_SIZE + ZIP64_EOCDL_LENGTH,
- ZipOutputStream
- .ZIP64_EOCD_LOC_SIG);
+ positionAtEndOfCentralDirectoryRecord();
+ archive.seek(archive.getFilePointer() - ZIP64_EOCDL_LENGTH);
+ archive.readFully(WORD_BUF);
+ boolean found = Arrays.equals(ZipOutputStream.ZIP64_EOCD_LOC_SIG,
+ WORD_BUF);
if (!found) {
// not a ZIP64 archive
+ skipBytes(ZIP64_EOCDL_LENGTH - WORD);
positionAtCentralDirectory32();
} else {
positionAtCentralDirectory64();
@@ -686,7 +688,8 @@ public class ZipFile {
*/
private void positionAtCentralDirectory64()
throws IOException {
- skipBytes(ZIP64_EOCDL_LOCATOR_OFFSET);
+ skipBytes(ZIP64_EOCDL_LOCATOR_OFFSET
+ - WORD /* signature has already been read */);
archive.readFully(DWORD_BUF);
archive.seek(ZipEightByteInteger.getLongValue(DWORD_BUF));
archive.readFully(WORD_BUF);
@@ -707,14 +710,22 @@ public class ZipFile {
*/
private void positionAtCentralDirectory32()
throws IOException {
+ skipBytes(CFD_LOCATOR_OFFSET);
+ archive.readFully(WORD_BUF);
+ archive.seek(ZipLong.getValue(WORD_BUF));
+ }
+
+ /**
+ * Searches for the and positions the stream at the start of the
+ * "End of central dir record".
+ */
+ private void positionAtEndOfCentralDirectoryRecord()
+ throws IOException {
boolean found = tryToLocateSignature(MIN_EOCD_SIZE, MAX_EOCD_SIZE,
ZipOutputStream.EOCD_SIG);
if (!found) {
throw new ZipException("archive is not a ZIP archive");
}
- skipBytes(CFD_LOCATOR_OFFSET);
- archive.readFully(WORD_BUF);
- archive.seek(ZipLong.getValue(WORD_BUF));
}
/**
Propchange: ant/core/trunk/src/main/org/apache/tools/zip/ZipFile.java
------------------------------------------------------------------------------
Merged /commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/zip/ZipFile.java:r1435549