svn commit: r1188602 - in /commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/utils: CountingInputStream.java CountingOutputStream.java

2011-10-25 Thread bodewig
Author: bodewig
Date: Tue Oct 25 11:00:07 2011
New Revision: 1188602

URL: http://svn.apache.org/viewvc?rev=1188602view=rev
Log:
Unused imports

Modified:

commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/utils/CountingInputStream.java

commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/utils/CountingOutputStream.java

Modified: 
commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/utils/CountingInputStream.java
URL: 
http://svn.apache.org/viewvc/commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/utils/CountingInputStream.java?rev=1188602r1=1188601r2=1188602view=diff
==
--- 
commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/utils/CountingInputStream.java
 (original)
+++ 
commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/utils/CountingInputStream.java
 Tue Oct 25 11:00:07 2011
@@ -21,7 +21,6 @@ package org.apache.commons.compress.util
 import java.io.FilterInputStream;
 import java.io.IOException;
 import java.io.InputStream;
-import java.util.concurrent.atomic.AtomicLong;
 
 /**
  * Stream that tracks the number of bytes read.

Modified: 
commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/utils/CountingOutputStream.java
URL: 
http://svn.apache.org/viewvc/commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/utils/CountingOutputStream.java?rev=1188602r1=1188601r2=1188602view=diff
==
--- 
commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/utils/CountingOutputStream.java
 (original)
+++ 
commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/utils/CountingOutputStream.java
 Tue Oct 25 11:00:07 2011
@@ -21,7 +21,6 @@ package org.apache.commons.compress.util
 import java.io.FilterOutputStream;
 import java.io.IOException;
 import java.io.OutputStream;
-import java.util.concurrent.atomic.AtomicLong;
 
 /**
  * Stream that tracks the number of bytes read.




svn commit: r1188632 - in /commons/proper/compress/trunk: pom.xml src/site/xdoc/index.xml

2011-10-25 Thread bodewig
Author: bodewig
Date: Tue Oct 25 12:36:42 2011
New Revision: 1188632

URL: http://svn.apache.org/viewvc?rev=1188632view=rev
Log:
Tweaks to docs pre-release

Modified:
commons/proper/compress/trunk/pom.xml
commons/proper/compress/trunk/src/site/xdoc/index.xml

Modified: commons/proper/compress/trunk/pom.xml
URL: 
http://svn.apache.org/viewvc/commons/proper/compress/trunk/pom.xml?rev=1188632r1=1188631r2=1188632view=diff
==
--- commons/proper/compress/trunk/pom.xml (original)
+++ commons/proper/compress/trunk/pom.xml Tue Oct 25 12:36:42 2011
@@ -30,7 +30,7 @@
   urlhttp://commons.apache.org/compress//url
   description
   Apache Commons Compress software defines an API for working with compression 
and archive formats.
-  These include: bzip2, gzip and ar, cpio, jar, tar, zip.
+  These include: bzip2, gzip, pack200 and ar, cpio, jar, tar, zip, dump.
   /description
 
   properties
@@ -188,7 +188,7 @@
   /rulesets
 /configuration
   /plugin
-  !-- Override Javadoc config in parent pom to add default manifest 
entries --
+  !-- Override Javadoc config in parent pom to add JCIP tags --
   plugin
 groupIdorg.apache.maven.plugins/groupId
 artifactIdmaven-javadoc-plugin/artifactId

Modified: commons/proper/compress/trunk/src/site/xdoc/index.xml
URL: 
http://svn.apache.org/viewvc/commons/proper/compress/trunk/src/site/xdoc/index.xml?rev=1188632r1=1188631r2=1188632view=diff
==
--- commons/proper/compress/trunk/src/site/xdoc/index.xml (original)
+++ commons/proper/compress/trunk/src/site/xdoc/index.xml Tue Oct 25 12:36:42 
2011
@@ -46,7 +46,7 @@
 /ul
 subsection name=Status
   ul
-liThe code has been released as version 1.2/li
+liThe code has been released as version 1.3/li
   /ul
 /subsection
 /section
@@ -90,7 +90,7 @@
 /section
 section name=Releases
   p
-The latest version v1.2, is JDK 1.4 compatible -
+The latest version v1.3, is Java5 compatible -
 a 
href=http://commons.apache.org/compress/download_compress.cgi;Download 
now!/a
   /p
 /section




svn commit: r1189015 - in /commons/proper/compress/trunk: RELEASE-NOTES.txt pom.xml src/site/xdoc/download_compress.xml

2011-10-25 Thread bodewig
Author: bodewig
Date: Wed Oct 26 03:50:11 2011
New Revision: 1189015

URL: http://svn.apache.org/viewvc?rev=1189015view=rev
Log:
prepare for 1.3RC1

Modified:
commons/proper/compress/trunk/RELEASE-NOTES.txt
commons/proper/compress/trunk/pom.xml
commons/proper/compress/trunk/src/site/xdoc/download_compress.xml

Modified: commons/proper/compress/trunk/RELEASE-NOTES.txt
URL: 
http://svn.apache.org/viewvc/commons/proper/compress/trunk/RELEASE-NOTES.txt?rev=1189015r1=1189014r2=1189015view=diff
==
--- commons/proper/compress/trunk/RELEASE-NOTES.txt (original)
+++ commons/proper/compress/trunk/RELEASE-NOTES.txt Wed Oct 26 03:50:11 2011
@@ -1,51 +1,38 @@
-
+  Apache Commons Compress 1.3 RELEASE NOTES
 
-  Apache Commons Compress 1.2 RELEASE NOTES
+Apache Commons Compress software defines an API for working with
+  compression and archive formats.  These include: bzip2, gzip,
+  pack200 and ar, cpio, jar, tar, zip, dump.
 
-Release 1.2 - a bugfix release,
-
-  The last release expected to be compatible with Java 1.4.
+Commons Compress 1.3 is the first version to require Java5 at runtime.
 
 Changes in this version include:
 
 New features:
-o COMPRESS-123:  ZipArchiveEntry has a new method getRawName that provides the
-original bytes that made up the name.  This may allow user
-code to detect the encoding. 
-o COMPRESS-122:  TarArchiveEntry provides access to the flags that determine
-whether it is an archived symbolic link, pipe or other
-uncommon file system object. 
+o Support for the Pack200 format has been added.  Issue: COMPRESS-142. 
+o Read-only support for the format used by the Unix dump(8) tool
+has been added.  Issue: COMPRESS-132. 
 
 Fixed Bugs:
-o COMPRESS-129:  ZipArchiveInputStream could fail with a Truncated ZIP error
-message for entries between 2 GByte and 4 GByte in size. 
-o COMPRESS-145:  TarArchiveInputStream now detects sparse entries using the
-oldgnu format and properly reports it cannot extract their
-contents. 
-o COMPRESS-130:  The Javadoc for ZipArchiveInputStream#skip now matches the
-implementation, the code has been made more defensive. 
-o COMPRESS-140:  ArArchiveInputStream fails if entries contain only blanks for
-userId or groupId. Thanks to Trejkaz. 
-o COMPRESS-139:  ZipFile may leak resources on some JDKs. 
-o COMPRESS-125:  BZip2CompressorInputStream throws IOException if
-underlying stream returns available() == 0.
-Removed the check. 
-o COMPRESS-127:  Calling close() on inputStream returned by
-CompressorStreamFactory.createCompressorInputStream()
-does not close the underlying input stream. 
-o COMPRESS-119:  TarArchiveOutputStream#finish now writes all buffered
-data to the stream 
+o BZip2CompressorInputStream's getBytesRead method always
+returned 0. 
+o ZipArchiveInputStream and ZipArchiveOutputStream could leak
+resources on some JDKs.  Issue: COMPRESS-152. 
+o TarArchiveOutputStream's getBytesWritten method didn't count
+correctly.  Issue: COMPRESS-160. 
 
 Changes:
-o ZipFile now implements finalize which closes the underlying
-file. 
-o COMPRESS-117:  Certain tar files not recognised by ArchiveStreamFactory. 
+o The ZIP package now supports Zip64 extensions.  Issue: COMPRESS-36. 
+o The AR package now supports the BSD dialect of storing file
+names longer than 16 chars (both reading and writing).
+Issue: COMPRESS-144. 
 
- 
 For complete information on Commons Compress, including instructions
 on how to submit bug reports, patches, or suggestions for improvement,
 see the Apache Commons Compress website:
-
+ 
 http://commons.apache.org/compress/
 
+Have fun!
+-Commons Compress team
 

Modified: commons/proper/compress/trunk/pom.xml
URL: 
http://svn.apache.org/viewvc/commons/proper/compress/trunk/pom.xml?rev=1189015r1=1189014r2=1189015view=diff
==
--- commons/proper/compress/trunk/pom.xml (original)
+++ commons/proper/compress/trunk/pom.xml Wed Oct 26 03:50:11 2011
@@ -25,7 +25,7 @@
 
   groupIdorg.apache.commons/groupId
   artifactIdcommons-compress/artifactId
-  version1.3-SNAPSHOT/version
+  version1.3/version
   nameCommons Compress/name
   urlhttp://commons.apache.org/compress//url
   description
@@ -40,8 +40,8 @@
 commons.jira.idCOMPRESS/commons.jira.id
 commons.jira.pid12310904/commons.jira.pid
 !-- configuration bits for cutting a release candidate --
-commons.release.version1.2/commons.release.version
-commons.rc.versionRC2/commons.rc.version
+commons.release.version1.3/commons.release.version
+commons.rc.versionRC1/commons.rc.version
   /properties
 
   issueManagement

Modified: commons/proper/compress/trunk/src/site/xdoc

svn commit: r1189016 - /commons/proper/compress/tags/COMPRESS_1.3_RC1/

2011-10-25 Thread bodewig
Author: bodewig
Date: Wed Oct 26 03:52:23 2011
New Revision: 1189016

URL: http://svn.apache.org/viewvc?rev=1189016view=rev
Log:
tagging Compress 1.3 RC1

Added:
commons/proper/compress/tags/COMPRESS_1.3_RC1/   (props changed)
  - copied from r1189015, commons/proper/compress/trunk/

Propchange: commons/proper/compress/tags/COMPRESS_1.3_RC1/
--
--- subclipse:tags (added)
+++ subclipse:tags Wed Oct 26 03:52:23 2011
@@ -0,0 +1 @@
+774629,commons-compress-1.0,/commons/proper/compress/tags/commons-compress-1.0,tag

Propchange: commons/proper/compress/tags/COMPRESS_1.3_RC1/
--
--- svn:ignore (added)
+++ svn:ignore Wed Oct 26 03:52:23 2011
@@ -0,0 +1,5 @@
+target
+*.iml
+*.ipr
+*.iws
+.*

Propchange: commons/proper/compress/tags/COMPRESS_1.3_RC1/
--
svn:mergeinfo = /commons/proper/compress/branches/zip64:1149597-1152684




svn commit: r1189085 - /commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/compressors/pack200/Pack200CompressorInputStream.java

2011-10-26 Thread bodewig
Author: bodewig
Date: Wed Oct 26 09:05:48 2011
New Revision: 1189085

URL: http://svn.apache.org/viewvc?rev=1189085view=rev
Log:
Use a constant for the length of the expected signature

Modified:

commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/compressors/pack200/Pack200CompressorInputStream.java

Modified: 
commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/compressors/pack200/Pack200CompressorInputStream.java
URL: 
http://svn.apache.org/viewvc/commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/compressors/pack200/Pack200CompressorInputStream.java?rev=1189085r1=1189084r2=1189085view=diff
==
--- 
commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/compressors/pack200/Pack200CompressorInputStream.java
 (original)
+++ 
commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/compressors/pack200/Pack200CompressorInputStream.java
 Wed Oct 26 09:05:48 2011
@@ -229,6 +229,7 @@ public class Pack200CompressorInputStrea
 private static final byte[] CAFE_DOOD = new byte[] {
 (byte) 0xCA, (byte) 0xFE, (byte) 0xD0, (byte) 0x0D
 };
+private static final int SIG_LENGTH = CAFE_DOOD.length;
 
 /**
  * Checks if the signature matches what is expected for a pack200
@@ -242,11 +243,11 @@ public class Pack200CompressorInputStrea
  * false otherwise
  */
 public static boolean matches(byte[] signature, int length) {
-if (length  4) {
+if (length  SIG_LENGTH) {
 return false;
 }
 
-for (int i = 0; i  4; i++) {
+for (int i = 0; i  SIG_LENGTH; i++) {
 if (signature[i] != CAFE_DOOD[i]) {
 return false;
 }




svn commit: r1189119 - /commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/compressors/Pack200TestCase.java

2011-10-26 Thread bodewig
Author: bodewig
Date: Wed Oct 26 10:35:38 2011
New Revision: 1189119

URL: http://svn.apache.org/viewvc?rev=1189119view=rev
Log:
improve test-coverage of pack200 package

Modified:

commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/compressors/Pack200TestCase.java

Modified: 
commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/compressors/Pack200TestCase.java
URL: 
http://svn.apache.org/viewvc/commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/compressors/Pack200TestCase.java?rev=1189119r1=1189118r2=1189119view=diff
==
--- 
commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/compressors/Pack200TestCase.java
 (original)
+++ 
commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/compressors/Pack200TestCase.java
 Wed Oct 26 10:35:38 2011
@@ -22,9 +22,12 @@ import java.io.File;
 import java.io.FileInputStream;
 import java.io.FileOutputStream;
 import java.io.InputStream;
+import java.io.IOException;
 import java.io.OutputStream;
 import java.util.ArrayList;
+import java.util.HashMap;
 import java.util.List;
+import java.util.Map;
 
 import org.apache.commons.compress.AbstractTestCase;
 import org.apache.commons.compress.archivers.ArchiveEntry;
@@ -156,4 +159,56 @@ public final class Pack200TestCase exten
 is.close();
 }
 }
+
+public void testShortSignature() throws Exception {
+final InputStream is = new FileInputStream(getFile(bla.pack));
+try {
+byte[] sig = new byte[2];
+is.read(sig);
+assertFalse(Pack200CompressorInputStream.matches(sig, 2));
+} finally {
+is.close();
+}
+}
+
+public void testInputStreamMethods() throws Exception {
+MapString, String m = new HashMapString, String();
+m.put(foo, bar);
+final InputStream is =
+new Pack200CompressorInputStream(new 
FileInputStream(getFile(bla.jar)),
+ m);
+try {
+// packed file is a jar, which is a zip so it starts with
+// a local file header
+assertTrue(is.markSupported());
+is.mark(5);
+assertEquals(0x50, is.read());
+byte[] rest = new byte[3];
+assertEquals(3, is.read(rest));
+assertEquals(0x4b, rest[0]);
+assertEquals(3, rest[1]);
+assertEquals(4, rest[2]);
+assertEquals(1, is.skip(1));
+is.reset();
+assertEquals(0x50, is.read());
+assertTrue(is.available()  0);
+} finally {
+is.close();
+}
+}
+
+public void testOutputStreamMethods() throws Exception {
+final File output = new File(dir, bla.pack);
+MapString, String m = new HashMapString, String();
+m.put(foo, bar);
+final OutputStream out = new FileOutputStream(output);
+try {
+final OutputStream os = new Pack200CompressorOutputStream(out, m);
+os.write(1);
+os.write(new byte[] { 2, 3 });
+os.close();
+} finally {
+out.close();
+}
+}
 }




svn commit: r1189127 - in /commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/utils: ./ CountingStreamTest.java

2011-10-26 Thread bodewig
Author: bodewig
Date: Wed Oct 26 10:56:25 2011
New Revision: 1189127

URL: http://svn.apache.org/viewvc?rev=1189127view=rev
Log:
Tests for Counting(In|Out)putStream

Added:

commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/utils/

commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/utils/CountingStreamTest.java
   (with props)

Added: 
commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/utils/CountingStreamTest.java
URL: 
http://svn.apache.org/viewvc/commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/utils/CountingStreamTest.java?rev=1189127view=auto
==
--- 
commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/utils/CountingStreamTest.java
 (added)
+++ 
commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/utils/CountingStreamTest.java
 Wed Oct 26 10:56:25 2011
@@ -0,0 +1,73 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * License); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * AS IS BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.commons.compress.utils;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import org.junit.Test;
+import static org.junit.Assert.assertArrayEquals;
+import static org.junit.Assert.assertEquals;
+
+public class CountingStreamTest {
+
+@Test
+public void output() throws Exception {
+// I don't like test all at once tests either, but the class
+// is soo trivial
+ByteArrayOutputStream bos = new ByteArrayOutputStream();
+CountingOutputStream o = new CountingOutputStream(bos);
+o.write(1);
+assertEquals(1, o.getBytesWritten());
+o.write(new byte[] { 2, 3 });
+assertEquals(3, o.getBytesWritten());
+o.write(new byte[] { 2, 3, 4, 5, }, 2, 1);
+assertEquals(4, o.getBytesWritten());
+o.count(-1);
+assertEquals(4, o.getBytesWritten());
+o.count(-2);
+assertEquals(2, o.getBytesWritten());
+o.close();
+assertArrayEquals(new byte[] { 1, 2, 3, 4 }, bos.toByteArray());
+}
+
+@Test
+public void input() throws Exception {
+// I don't like test all at once tests either, but the class
+// is soo trivial
+ByteArrayInputStream bis =
+new ByteArrayInputStream(new byte[] { 1, 2, 3, 4 });
+CountingInputStream i = new CountingInputStream(bis);
+assertEquals(1, i.read());
+assertEquals(1, i.getBytesRead());
+byte[] b = new byte[2];
+i.read(b);
+assertEquals(3, i.getBytesRead());
+assertArrayEquals(new byte[] { 2, 3 }, b);
+b = new byte[3];
+i.read(b, 1, 1);
+assertArrayEquals(new byte[] { 0, 4, 0 }, b);
+assertEquals(4, i.getBytesRead());
+i.count(-1);
+assertEquals(4, i.getBytesRead());
+i.count(-2);
+assertEquals(2, i.getBytesRead());
+i.close();
+}
+
+}

Propchange: 
commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/utils/CountingStreamTest.java
--
svn:eol-style = native




svn commit: r1189244 - in /commons/proper/compress/trunk: pom.xml src/site/xdoc/index.xml

2011-10-26 Thread bodewig
Author: bodewig
Date: Wed Oct 26 14:39:04 2011
New Revision: 1189244

URL: http://svn.apache.org/viewvc?rev=1189244view=rev
Log:
Give proper credit to Michael (not Markus) Kuss

Modified:
commons/proper/compress/trunk/pom.xml
commons/proper/compress/trunk/src/site/xdoc/index.xml

Modified: commons/proper/compress/trunk/pom.xml
URL: 
http://svn.apache.org/viewvc/commons/proper/compress/trunk/pom.xml?rev=1189244r1=1189243r2=1189244view=diff
==
--- commons/proper/compress/trunk/pom.xml (original)
+++ commons/proper/compress/trunk/pom.xml Wed Oct 26 14:39:04 2011
@@ -93,6 +93,10 @@
   nameBear Giles/name
   emailbgi...@coyotesong.com/email
 /contributor
+contributor
+  nameMichael Kuss/name
+  emailmail at michael minus kuss.de/email
+/contributor
   /contributors
 
   scm

Modified: commons/proper/compress/trunk/src/site/xdoc/index.xml
URL: 
http://svn.apache.org/viewvc/commons/proper/compress/trunk/src/site/xdoc/index.xml?rev=1189244r1=1189243r2=1189244view=diff
==
--- commons/proper/compress/trunk/src/site/xdoc/index.xml (original)
+++ commons/proper/compress/trunk/src/site/xdoc/index.xml Wed Oct 26 14:39:04 
2011
@@ -39,7 +39,7 @@
 the work done by Keiron Liddle.  It has migrated
 via:br/ Ant -gt; Avalon-Excalibur -gt; Commons-IO
 -gt; Commons-Compress./li
-  liThe cpio package has been contributed by Markus Kuss
+  liThe cpio package has been contributed by Michael Kuss
 and
 the a href=http://jrpm.sourceforge.net/;jRPM/a
 project./li




svn commit: r1189269 - /commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/ar/ArArchiveOutputStream.java

2011-10-26 Thread bodewig
Author: bodewig
Date: Wed Oct 26 15:35:05 2011
New Revision: 1189269

URL: http://svn.apache.org/viewvc?rev=1189269view=rev
Log:
unused field

Modified:

commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/ar/ArArchiveOutputStream.java

Modified: 
commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/ar/ArArchiveOutputStream.java
URL: 
http://svn.apache.org/viewvc/commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/ar/ArArchiveOutputStream.java?rev=1189269r1=1189268r2=1189269view=diff
==
--- 
commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/ar/ArArchiveOutputStream.java
 (original)
+++ 
commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/ar/ArArchiveOutputStream.java
 Wed Oct 26 15:35:05 2011
@@ -39,7 +39,6 @@ public class ArArchiveOutputStream exten
 public static final int LONGFILE_BSD = 1;
 
 private final OutputStream out;
-private long archiveOffset = 0;
 private long entryOffset = 0;
 private ArArchiveEntry prevEntry;
 private boolean haveUnclosedEntry = false;
@@ -81,7 +80,6 @@ public class ArArchiveOutputStream exten
 }
 if ((entryOffset % 2) != 0) {
 out.write('\n'); // Pad byte
-archiveOffset++;
 }
 haveUnclosedEntry = false;
 }
@@ -95,7 +93,7 @@ public class ArArchiveOutputStream exten
 
 ArArchiveEntry pArEntry = (ArArchiveEntry)pEntry;
 if (prevEntry == null) {
-archiveOffset += writeArchiveHeader();
+writeArchiveHeader();
 } else {
 if (prevEntry.getLength() != entryOffset) {
 throw new IOException(length does not match entry ( + 
prevEntry.getLength() +  !=  + entryOffset);
@@ -108,7 +106,7 @@ public class ArArchiveOutputStream exten
 
 prevEntry = pArEntry;
 
-archiveOffset += writeEntryHeader(pArEntry);
+writeEntryHeader(pArEntry);
 
 entryOffset = 0;
 haveUnclosedEntry = true;




svn commit: r1189662 - in /commons/proper/compress/trunk/src: main/java/org/apache/commons/compress/archivers/dump/ test/java/org/apache/commons/compress/archivers/dump/

2011-10-27 Thread bodewig
Author: bodewig
Date: Thu Oct 27 08:22:48 2011
New Revision: 1189662

URL: http://svn.apache.org/viewvc?rev=1189662view=rev
Log:
remove unneeded cast to int in bitwise operations, add tests for convert methods

Added:

commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/archivers/dump/

commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/archivers/dump/DumpArchiveUtilTest.java
   (with props)
Modified:

commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/dump/DumpArchiveUtil.java

Modified: 
commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/dump/DumpArchiveUtil.java
URL: 
http://svn.apache.org/viewvc/commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/dump/DumpArchiveUtil.java?rev=1189662r1=1189661r2=1189662view=diff
==
--- 
commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/dump/DumpArchiveUtil.java
 (original)
+++ 
commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/dump/DumpArchiveUtil.java
 Thu Oct 27 08:22:48 2011
@@ -108,10 +108,10 @@ class DumpArchiveUtil {
  */
 public static final int convert32(byte[] buffer, int offset) {
 int i = 0;
-i = ((int) buffer[offset + 3])  24;
-i += (((int) buffer[offset + 2]  16)  0x00FF);
-i += (((int) buffer[offset + 1]  8)  0xFF00);
-i += (((int) buffer[offset])  0x00FF);
+i = buffer[offset + 3]  24;
+i += (buffer[offset + 2]  16)  0x00FF;
+i += (buffer[offset + 1]  8)  0xFF00;
+i += buffer[offset]  0x00FF;
 
 return i;
 }
@@ -125,8 +125,8 @@ class DumpArchiveUtil {
  */
 public static final int convert16(byte[] buffer, int offset) {
 int i = 0;
-i += (((int) buffer[offset + 1]  8)  0xFF00);
-i += (((int) buffer[offset])  0x00FF);
+i += (buffer[offset + 1]  8)  0xFF00;
+i += buffer[offset]  0x00FF;
 
 return i;
 }

Added: 
commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/archivers/dump/DumpArchiveUtilTest.java
URL: 
http://svn.apache.org/viewvc/commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/archivers/dump/DumpArchiveUtilTest.java?rev=1189662view=auto
==
--- 
commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/archivers/dump/DumpArchiveUtilTest.java
 (added)
+++ 
commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/archivers/dump/DumpArchiveUtilTest.java
 Thu Oct 27 08:22:48 2011
@@ -0,0 +1,50 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * License); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * AS IS BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.commons.compress.archivers.dump;
+
+import org.junit.Test;
+import static org.junit.Assert.assertEquals;
+
+public class DumpArchiveUtilTest {
+
+@Test
+public void convert64() {
+assertEquals(0xABCDEF0123456780L,
+ DumpArchiveUtil.convert64(new byte[] {
+ (byte) 0x80, 0x67, 0x45, 0x23, 1, (byte) 0xEF,
+ (byte) 0xCD, (byte) 0xAB
+ }, 0));
+}
+
+@Test
+public void convert32() {
+assertEquals(0xABCDEF01,
+ DumpArchiveUtil.convert32(new byte[] {
+ 1, (byte) 0xEF, (byte) 0xCD, (byte) 0xAB
+ }, 0));
+}
+
+@Test
+public void convert16() {
+assertEquals(0xABCD,
+ DumpArchiveUtil.convert16(new byte[] {
+ (byte) 0xCD, (byte) 0xAB
+ }, 0));
+}
+}
\ No newline at end of file

Propchange: 
commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/archivers/dump/DumpArchiveUtilTest.java
--
svn:eol-style = native




svn commit: r1189680 - in /commons/proper/compress/trunk/src: main/java/org/apache/commons/compress/archivers/dump/DumpArchiveEntry.java test/java/org/apache/commons/compress/archivers/dump/DumpArchiv

2011-10-27 Thread bodewig
Author: bodewig
Date: Thu Oct 27 08:51:20 2011
New Revision: 1189680

URL: http://svn.apache.org/viewvc?rev=1189680view=rev
Log:
Improve test-coverage for DumpArchiveEntry and fix a bug found by doing so

Added:

commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/archivers/dump/DumpArchiveEntryTest.java
   (with props)
Modified:

commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/dump/DumpArchiveEntry.java

Modified: 
commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/dump/DumpArchiveEntry.java
URL: 
http://svn.apache.org/viewvc/commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/dump/DumpArchiveEntry.java?rev=1189680r1=1189679r2=1189680view=diff
==
--- 
commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/dump/DumpArchiveEntry.java
 (original)
+++ 
commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/dump/DumpArchiveEntry.java
 Thu Oct 27 08:51:20 2011
@@ -232,8 +232,9 @@ public class DumpArchiveEntry implements
  */
 protected DumpArchiveEntry(String name, String simpleName, int ino,
TYPE type) {
-this(name, simpleName);
 setType(type);
+setName(name);
+this.simpleName = simpleName;
 this.ino = ino;
 this.offset = 0;
 }

Added: 
commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/archivers/dump/DumpArchiveEntryTest.java
URL: 
http://svn.apache.org/viewvc/commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/archivers/dump/DumpArchiveEntryTest.java?rev=1189680view=auto
==
--- 
commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/archivers/dump/DumpArchiveEntryTest.java
 (added)
+++ 
commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/archivers/dump/DumpArchiveEntryTest.java
 Thu Oct 27 08:51:20 2011
@@ -0,0 +1,43 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * License); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * AS IS BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.commons.compress.archivers.dump;
+
+import org.junit.Test;
+import static org.junit.Assert.assertEquals;
+
+public class DumpArchiveEntryTest {
+@Test
+public void publicNameAddsTrailingSlashForDirectories() {
+DumpArchiveEntry ent = new DumpArchiveEntry(foo, bar, -1,
+DumpArchiveEntry.TYPE
+.DIRECTORY);
+assertEquals(bar, ent.getSimpleName());
+assertEquals(foo, ent.getOriginalName());
+assertEquals(foo/, ent.getName());
+}
+
+@Test
+public void publicNameRemovesLeadingDotSlash() {
+DumpArchiveEntry ent = new DumpArchiveEntry(./foo, bar);
+assertEquals(bar, ent.getSimpleName());
+assertEquals(./foo, ent.getOriginalName());
+assertEquals(foo, ent.getName());
+}
+
+}
\ No newline at end of file

Propchange: 
commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/archivers/dump/DumpArchiveEntryTest.java
--
svn:eol-style = native




svn commit: r1189682 - /commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/dump/DumpArchiveUtil.java

2011-10-27 Thread bodewig
Author: bodewig
Date: Thu Oct 27 08:53:37 2011
New Revision: 1189682

URL: http://svn.apache.org/viewvc?rev=1189682view=rev
Log:
unused code

Modified:

commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/dump/DumpArchiveUtil.java

Modified: 
commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/dump/DumpArchiveUtil.java
URL: 
http://svn.apache.org/viewvc/commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/dump/DumpArchiveUtil.java?rev=1189682r1=1189681r2=1189682view=diff
==
--- 
commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/dump/DumpArchiveUtil.java
 (original)
+++ 
commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/dump/DumpArchiveUtil.java
 Thu Oct 27 08:53:37 2011
@@ -130,28 +130,4 @@ class DumpArchiveUtil {
 
 return i;
 }
-
-/**
- * Dump the start of a block.
- *
- * @param buffer
- */
-public static final void dumpBlock(byte[] buffer) {
-for (int i = 0; i  128; i += 32) {
-System.out.printf(%08x , DumpArchiveUtil.convert32(buffer, i));
-System.out.printf(%08x , DumpArchiveUtil.convert32(buffer, i + 
4));
-System.out.printf(%08x , DumpArchiveUtil.convert32(buffer, i + 
8));
-System.out.printf(%08x - ,
-DumpArchiveUtil.convert32(buffer, i + 12));
-System.out.printf(%08x , DumpArchiveUtil.convert32(buffer, i +
-16));
-System.out.printf(%08x , DumpArchiveUtil.convert32(buffer, i +
-20));
-System.out.printf(%08x , DumpArchiveUtil.convert32(buffer, i +
-24));
-System.out.printf(%08x , DumpArchiveUtil.convert32(buffer, i +
-28));
-System.out.println();
-}
-}
 }




svn commit: r1189720 - in /commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/archivers: cpio/CpioArchiveOutputStreamTest.java cpio/CpioUtilTest.java dump/DumpArchiveInputStreamTe

2011-10-27 Thread bodewig
Author: bodewig
Date: Thu Oct 27 12:32:53 2011
New Revision: 1189720

URL: http://svn.apache.org/viewvc?rev=1189720view=rev
Log:
increase test coverage

Added:

commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/archivers/cpio/CpioArchiveOutputStreamTest.java
   (with props)

commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/archivers/cpio/CpioUtilTest.java
   (with props)

commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/archivers/dump/DumpArchiveInputStreamTest.java
   (with props)
Modified:

commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/archivers/zip/ZipFileTest.java

Added: 
commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/archivers/cpio/CpioArchiveOutputStreamTest.java
URL: 
http://svn.apache.org/viewvc/commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/archivers/cpio/CpioArchiveOutputStreamTest.java?rev=1189720view=auto
==
--- 
commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/archivers/cpio/CpioArchiveOutputStreamTest.java
 (added)
+++ 
commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/archivers/cpio/CpioArchiveOutputStreamTest.java
 Thu Oct 27 12:32:53 2011
@@ -0,0 +1,68 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * License); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * AS IS BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.commons.compress.archivers.cpio;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileOutputStream;
+import java.io.FileOutputStream;
+import java.io.InputStream;
+
+import org.apache.commons.compress.AbstractTestCase;
+import org.apache.commons.compress.utils.IOUtils;
+
+public class CpioArchiveOutputStreamTest extends AbstractTestCase {
+
+public void testWriteOldBinary() throws Exception {
+final File f = getFile(test1.xml);
+final File output = new File(dir, test.cpio);
+final FileOutputStream out = new FileOutputStream(output);
+InputStream in = null;
+try {
+final CpioArchiveOutputStream os =
+new CpioArchiveOutputStream(out, CpioArchiveOutputStream
+.FORMAT_OLD_BINARY);
+os.putArchiveEntry(new CpioArchiveEntry(CpioArchiveOutputStream
+.FORMAT_OLD_BINARY,
+f, test1.xml));
+IOUtils.copy(in = new FileInputStream(f), os);
+in.close();
+in = null;
+os.closeArchiveEntry();
+os.close();
+} finally {
+if (in != null) {
+in.close();
+}
+out.close();
+}
+
+try {
+in = new CpioArchiveInputStream(new FileInputStream(output));
+CpioArchiveEntry e = ((CpioArchiveInputStream) in)
+.getNextCPIOEntry();
+assertEquals(test1.xml, e.getName());
+assertNull(((CpioArchiveInputStream) in).getNextEntry());
+} finally {
+if (in != null) {
+in.close();
+}
+}
+}
+}
\ No newline at end of file

Propchange: 
commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/archivers/cpio/CpioArchiveOutputStreamTest.java
--
svn:eol-style = native

Added: 
commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/archivers/cpio/CpioUtilTest.java
URL: 
http://svn.apache.org/viewvc/commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/archivers/cpio/CpioUtilTest.java?rev=1189720view=auto
==
--- 
commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/archivers/cpio/CpioUtilTest.java
 (added)
+++ 
commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/archivers/cpio/CpioUtilTest.java
 Thu Oct 27 12:32:53 2011
@@ -0,0 +1,55 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements

svn commit: r1190154 - /commons/proper/compress/tags/COMPRESS_1.3_RC2/

2011-10-27 Thread bodewig
Author: bodewig
Date: Fri Oct 28 04:15:42 2011
New Revision: 1190154

URL: http://svn.apache.org/viewvc?rev=1190154view=rev
Log:
Creating a tag for second release candidate of Commons Compress 1.3

Added:
commons/proper/compress/tags/COMPRESS_1.3_RC2/   (props changed)
  - copied from r1190153, commons/proper/compress/trunk/

Propchange: commons/proper/compress/tags/COMPRESS_1.3_RC2/
--
--- subclipse:tags (added)
+++ subclipse:tags Fri Oct 28 04:15:42 2011
@@ -0,0 +1 @@
+774629,commons-compress-1.0,/commons/proper/compress/tags/commons-compress-1.0,tag

Propchange: commons/proper/compress/tags/COMPRESS_1.3_RC2/
--
--- svn:ignore (added)
+++ svn:ignore Fri Oct 28 04:15:42 2011
@@ -0,0 +1,6 @@
+target
+*.iml
+*.ipr
+*.iws
+.*
+maven-eclipse.xml

Propchange: commons/proper/compress/tags/COMPRESS_1.3_RC2/
--
svn:mergeinfo = /commons/proper/compress/branches/zip64:1149597-1152684




svn commit: r1190156 - /commons/proper/compress/tags/COMPRESS_1.3_RC2/pom.xml

2011-10-27 Thread bodewig
Author: bodewig
Date: Fri Oct 28 04:18:39 2011
New Revision: 1190156

URL: http://svn.apache.org/viewvc?rev=1190156view=rev
Log:
fix version numbers for 1.3RC2

Modified:
commons/proper/compress/tags/COMPRESS_1.3_RC2/pom.xml

Modified: commons/proper/compress/tags/COMPRESS_1.3_RC2/pom.xml
URL: 
http://svn.apache.org/viewvc/commons/proper/compress/tags/COMPRESS_1.3_RC2/pom.xml?rev=1190156r1=1190155r2=1190156view=diff
==
--- commons/proper/compress/tags/COMPRESS_1.3_RC2/pom.xml (original)
+++ commons/proper/compress/tags/COMPRESS_1.3_RC2/pom.xml Fri Oct 28 04:18:39 
2011
@@ -25,7 +25,7 @@
 
   groupIdorg.apache.commons/groupId
   artifactIdcommons-compress/artifactId
-  version1.3-SNAPSHOT/version
+  version1.3/version
   nameCommons Compress/name
   urlhttp://commons.apache.org/compress//url
   description
@@ -41,7 +41,7 @@
 commons.jira.pid12310904/commons.jira.pid
 !-- configuration bits for cutting a release candidate --
 commons.release.version1.3/commons.release.version
-commons.rc.versionRC1/commons.rc.version
+commons.rc.versionRC2/commons.rc.version
   /properties
 
   issueManagement




svn commit: r1195840 - in /commons/proper/compress/trunk: doap_compress.rdf pom.xml src/changes/changes.xml

2011-11-01 Thread bodewig
Author: bodewig
Date: Tue Nov  1 06:16:11 2011
New Revision: 1195840

URL: http://svn.apache.org/viewvc?rev=1195840view=rev
Log:
1.3 has been released, open up for 1.4

Modified:
commons/proper/compress/trunk/doap_compress.rdf
commons/proper/compress/trunk/pom.xml
commons/proper/compress/trunk/src/changes/changes.xml

Modified: commons/proper/compress/trunk/doap_compress.rdf
URL: 
http://svn.apache.org/viewvc/commons/proper/compress/trunk/doap_compress.rdf?rev=1195840r1=1195839r2=1195840view=diff
==
--- commons/proper/compress/trunk/doap_compress.rdf (original)
+++ commons/proper/compress/trunk/doap_compress.rdf Tue Nov  1 06:16:11 2011
@@ -36,14 +36,25 @@
 release
   Version
 namecommons-compress/name
+created2011-11-01/created
+revision1.3/revision
+  /Version
+/release
+release
+  Version
+namecommons-compress/name
 created2011-07-31/created
 revision1.2/revision
   /Version
+/release
+release
   Version
 namecommons-compress/name
 created2010-08-13/created
 revision1.1/revision
   /Version
+/release
+release
   Version
 namecommons-compress/name
 created2009-05-21/created

Modified: commons/proper/compress/trunk/pom.xml
URL: 
http://svn.apache.org/viewvc/commons/proper/compress/trunk/pom.xml?rev=1195840r1=1195839r2=1195840view=diff
==
--- commons/proper/compress/trunk/pom.xml (original)
+++ commons/proper/compress/trunk/pom.xml Tue Nov  1 06:16:11 2011
@@ -25,7 +25,7 @@
 
   groupIdorg.apache.commons/groupId
   artifactIdcommons-compress/artifactId
-  version1.3-SNAPSHOT/version
+  version1.4-SNAPSHOT/version
   nameCommons Compress/name
   urlhttp://commons.apache.org/compress//url
   description

Modified: commons/proper/compress/trunk/src/changes/changes.xml
URL: 
http://svn.apache.org/viewvc/commons/proper/compress/trunk/src/changes/changes.xml?rev=1195840r1=1195839r2=1195840view=diff
==
--- commons/proper/compress/trunk/src/changes/changes.xml (original)
+++ commons/proper/compress/trunk/src/changes/changes.xml Tue Nov  1 06:16:11 
2011
@@ -44,7 +44,10 @@ The action type attribute can be add,u
 titlecommons-compress/title
   /properties
   body
-release version=1.3 date=unreleased
+release version=1.4 date=unreleased
+ description=Release 1.4
+/release
+release version=1.3 date=2011-11-01
  description=Release 1.3 - API compatible to 1.2 but requires 
Java5 at runtime
   action issue=COMPRESS-142 type=add date=2011-09-14
 Support for the Pack200 format has been added.




svn commit: r1196226 - /commons/proper/compress/tags/COMPRESS_1.3/

2011-11-01 Thread bodewig
Author: bodewig
Date: Tue Nov  1 19:22:19 2011
New Revision: 1196226

URL: http://svn.apache.org/viewvc?rev=1196226view=rev
Log:
RC2 it is

Added:
commons/proper/compress/tags/COMPRESS_1.3/   (props changed)
  - copied from r1196225, commons/proper/compress/tags/COMPRESS_1.3_RC2/

Propchange: commons/proper/compress/tags/COMPRESS_1.3/
--
--- subclipse:tags (added)
+++ subclipse:tags Tue Nov  1 19:22:19 2011
@@ -0,0 +1 @@
+774629,commons-compress-1.0,/commons/proper/compress/tags/commons-compress-1.0,tag

Propchange: commons/proper/compress/tags/COMPRESS_1.3/
--
--- svn:ignore (added)
+++ svn:ignore Tue Nov  1 19:22:19 2011
@@ -0,0 +1,6 @@
+target
+*.iml
+*.ipr
+*.iws
+.*
+maven-eclipse.xml

Propchange: commons/proper/compress/tags/COMPRESS_1.3/
--
svn:mergeinfo = /commons/proper/compress/branches/zip64:1149597-1152684




svn commit: r1196665 - in /commons/proper/compress/trunk: ./ src/main/java/org/apache/commons/compress/compressors/ src/main/java/org/apache/commons/compress/compressors/xz/

2011-11-02 Thread bodewig
Author: bodewig
Date: Wed Nov  2 16:13:41 2011
New Revision: 1196665

URL: http://svn.apache.org/viewvc?rev=1196665view=rev
Log:
support for XZ compression format submitted by Lasse Collin.  COMPRESS-156

Added:

commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/compressors/xz/

commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/compressors/xz/XZCompressorInputStream.java
   (with props)

commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/compressors/xz/XZCompressorOutputStream.java
   (with props)
Modified:
commons/proper/compress/trunk/pom.xml

commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/compressors/CompressorStreamFactory.java

Modified: commons/proper/compress/trunk/pom.xml
URL: 
http://svn.apache.org/viewvc/commons/proper/compress/trunk/pom.xml?rev=1196665r1=1196664r2=1196665view=diff
==
--- commons/proper/compress/trunk/pom.xml (original)
+++ commons/proper/compress/trunk/pom.xml Wed Nov  2 16:13:41 2011
@@ -56,6 +56,11 @@
   version4.10/version
   scopetest/scope
 /dependency
+dependency
+  groupIdorg.tukaani/groupId
+  artifactIdxz/artifactId
+  version1.0/version
+/dependency
   /dependencies
 
   developers

Modified: 
commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/compressors/CompressorStreamFactory.java
URL: 
http://svn.apache.org/viewvc/commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/compressors/CompressorStreamFactory.java?rev=1196665r1=1196664r2=1196665view=diff
==
--- 
commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/compressors/CompressorStreamFactory.java
 (original)
+++ 
commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/compressors/CompressorStreamFactory.java
 Wed Nov  2 16:13:41 2011
@@ -26,6 +26,8 @@ import org.apache.commons.compress.compr
 import 
org.apache.commons.compress.compressors.bzip2.BZip2CompressorOutputStream;
 import org.apache.commons.compress.compressors.gzip.GzipCompressorInputStream;
 import org.apache.commons.compress.compressors.gzip.GzipCompressorOutputStream;
+import org.apache.commons.compress.compressors.xz.XZCompressorInputStream;
+import org.apache.commons.compress.compressors.xz.XZCompressorOutputStream;
 import 
org.apache.commons.compress.compressors.pack200.Pack200CompressorInputStream;
 import 
org.apache.commons.compress.compressors.pack200.Pack200CompressorOutputStream;
 
@@ -62,6 +64,7 @@ public class CompressorStreamFactory {
  * @since Commons Compress 1.1
  */
 public static final String BZIP2 = bzip2;
+
 /**
  * Constant used to identify the GZIP compression algorithm.
  * @since Commons Compress 1.1
@@ -74,6 +77,12 @@ public class CompressorStreamFactory {
 public static final String PACK200 = pack200;
 
 /**
+ * Constant used to identify the XZ compression method.
+ * @since Commons Compress 1.4
+ */
+public static final String XZ = xz;
+
+/**
  * Create an compressor input stream from an input stream, autodetecting
  * the compressor type from the first few bytes of the stream. The 
InputStream
  * must support marks, like BufferedInputStream.
@@ -108,6 +117,10 @@ public class CompressorStreamFactory {
 return new GzipCompressorInputStream(in);
 }
 
+if (XZCompressorInputStream.matches(signature, signatureLength)) {
+return new XZCompressorInputStream(in);
+}
+
 if (Pack200CompressorInputStream.matches(signature, 
signatureLength)) {
 return new Pack200CompressorInputStream(in);
 }
@@ -122,7 +135,7 @@ public class CompressorStreamFactory {
 /**
  * Create a compressor input stream from a compressor name and an input 
stream.
  * 
- * @param name of the compressor, i.e. gz, bzip2 or pack200
+ * @param name of the compressor, i.e. gz, bzip2, xz, or pack200
  * @param in the input stream
  * @return compressor input stream
  * @throws CompressorException if the compressor name is not known
@@ -145,6 +158,10 @@ public class CompressorStreamFactory {
 return new BZip2CompressorInputStream(in);
 }
 
+if (XZ.equalsIgnoreCase(name)) {
+return new XZCompressorInputStream(in);
+}
+
 if (PACK200.equalsIgnoreCase(name)) {
 return new Pack200CompressorInputStream(in);
 }
@@ -159,7 +176,7 @@ public class CompressorStreamFactory {
 /**
  * Create an compressor output stream from an compressor name and an input 
stream.
  * 
- * @param name the compressor name, i.e. gz, bzip2 or pack200
+ * @param name the compressor name, i.e. gz, bzip2, xz

svn commit: r1196950 - in /commons/proper/compress/trunk/src/test: java/org/apache/commons/compress/compressors/XZTestCase.java resources/bla.tar.xz

2011-11-02 Thread bodewig
Author: bodewig
Date: Thu Nov  3 05:53:31 2011
New Revision: 1196950

URL: http://svn.apache.org/viewvc?rev=1196950view=rev
Log:
Initial test for XZ.  COMPRESS-156

Added:

commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/compressors/XZTestCase.java
  - copied, changed from r1196949, 
commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/compressors/GZipTestCase.java
commons/proper/compress/trunk/src/test/resources/bla.tar.xz   (with props)

Copied: 
commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/compressors/XZTestCase.java
 (from r1196949, 
commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/compressors/GZipTestCase.java)
URL: 
http://svn.apache.org/viewvc/commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/compressors/XZTestCase.java?p2=commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/compressors/XZTestCase.javap1=commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/compressors/GZipTestCase.javar1=1196949r2=1196950rev=1196950view=diff
==
--- 
commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/compressors/GZipTestCase.java
 (original)
+++ 
commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/compressors/XZTestCase.java
 Thu Nov  3 05:53:31 2011
@@ -30,15 +30,15 @@ import java.io.OutputStream;
 import org.apache.commons.compress.AbstractTestCase;
 import org.apache.commons.compress.utils.IOUtils;
 
-public final class GZipTestCase extends AbstractTestCase {
+public final class XZTestCase extends AbstractTestCase {
 
-public void testGzipCreation()  throws Exception {
+public void testXZCreation()  throws Exception {
 final File input = getFile(test1.xml);
-final File output = new File(dir, test1.xml.gz);
+final File output = new File(dir, test1.xml.xz);
 final OutputStream out = new FileOutputStream(output);
 try {
 final CompressorOutputStream cos = new CompressorStreamFactory()
-.createCompressorOutputStream(gz, out);
+.createCompressorOutputStream(xz, out);
 try {
 IOUtils.copy(new FileInputStream(input), cos);
 } finally {
@@ -49,13 +49,13 @@ public final class GZipTestCase extends 
 }
 }
 
-public void testGzipUnarchive() throws Exception {
-final File input = getFile(bla.tgz);
+public void testXZUnarchive() throws Exception {
+final File input = getFile(bla.tar.xz);
 final File output = new File(dir, bla.tar);
 final InputStream is = new FileInputStream(input);
 try {
 final CompressorInputStream in = new CompressorStreamFactory()
-.createCompressorInputStream(gz, is);
+.createCompressorInputStream(xz, is);
 FileOutputStream out = null;
 try {
 out = new FileOutputStream(output);
@@ -71,43 +71,4 @@ public final class GZipTestCase extends 
 }
 }
 
-/**
- * @see https://issues.apache.org/jira/browse/COMPRESS-84;
- */
-public void testCorruptedInput() throws Exception {
-InputStream in = null;
-OutputStream out = null;
-CompressorInputStream cin = null;
-try {
-in = new FileInputStream(getFile(bla.tgz));
-out = new ByteArrayOutputStream();
-IOUtils.copy(in, out);
-in.close();
-out.close();
-
-byte[] data = ((ByteArrayOutputStream) out).toByteArray();
-in = new ByteArrayInputStream(data, 0, data.length - 1);
-cin = new CompressorStreamFactory()
-.createCompressorInputStream(gz, in);
-out = new ByteArrayOutputStream();
-
-try {
-IOUtils.copy(cin, out);
-fail(Expected an exception);
-} catch (IOException ioex) {
-// the whole point of the test
-}
-
-} finally {
-if (out != null) {
-out.close();
-}
-if (cin != null) {
-cin.close();
-}
-if (in != null) {
-in.close();
-}
-}
-}
 }

Added: commons/proper/compress/trunk/src/test/resources/bla.tar.xz
URL: 
http://svn.apache.org/viewvc/commons/proper/compress/trunk/src/test/resources/bla.tar.xz?rev=1196950view=auto
==
Binary file - no diff available.

Propchange: commons/proper/compress/trunk/src/test/resources/bla.tar.xz
--
svn:mime-type = application/octet-stream




svn commit: r1196953 - in /commons/proper/compress/trunk/src: main/java/org/apache/commons/compress/compressors/xz/XZUtils.java test/java/org/apache/commons/compress/compressors/XZUtilsTestCase.java

2011-11-03 Thread bodewig
Author: bodewig
Date: Thu Nov  3 06:06:26 2011
New Revision: 1196953

URL: http://svn.apache.org/viewvc?rev=1196953view=rev
Log:
XZUtils modelled after GzipUtils

Added:

commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/compressors/xz/XZUtils.java
  - copied, changed from r1196949, 
commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/compressors/gzip/GzipUtils.java

commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/compressors/XZUtilsTestCase.java
  - copied, changed from r1196949, 
commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/compressors/GzipUtilsTestCase.java

Copied: 
commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/compressors/xz/XZUtils.java
 (from r1196949, 
commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/compressors/gzip/GzipUtils.java)
URL: 
http://svn.apache.org/viewvc/commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/compressors/xz/XZUtils.java?p2=commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/compressors/xz/XZUtils.javap1=commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/compressors/gzip/GzipUtils.javar1=1196949r2=1196953rev=1196953view=diff
==
--- 
commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/compressors/gzip/GzipUtils.java
 (original)
+++ 
commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/compressors/xz/XZUtils.java
 Thu Nov  3 06:06:26 2011
@@ -16,30 +16,31 @@
  * specific language governing permissions and limitations
  * under the License.
  */
-package org.apache.commons.compress.compressors.gzip;
+package org.apache.commons.compress.compressors.xz;
 
 import java.util.HashMap;
 import java.util.Locale;
 import java.util.Map;
 
 /**
- * Utility code for the gzip compression format.
+ * Utility code for the xz compression format.
  * @ThreadSafe
+ * @since Commons Compress 1.4
  */
-public class GzipUtils {
+public class XZUtils {
 
 /**
- * Map from common filename suffixes to the suffixes that identify gzipped
- * versions of those file types. For example: from .tar to .tgz.
+ * Map from common filename suffixes to the suffixes that identify xzped
+ * versions of those file types. For example: from .tar to .txz.
  */
 private static final MapString, String compressSuffix =
 new HashMapString, String();
 
 /**
- * Map from common filename suffixes of gzipped files to the corresponding
+ * Map from common filename suffixes of xzped files to the corresponding
  * suffixes of uncompressed files. For example: from .tgz to .tar.
  * p
- * This map also contains gzip-specific suffixes like .gz and -z.
+ * This map also contains xz-specific suffixes like .gz and -z.
  * These suffixes are mapped to the empty string, as they should simply
  * be removed from the filename when the file is uncompressed.
  */
@@ -47,42 +48,30 @@ public class GzipUtils {
 new HashMapString, String();
 
 static {
-compressSuffix.put(.tar, .tgz);
-compressSuffix.put(.svg, .svgz);
-compressSuffix.put(.cpio, .cpgz);
-compressSuffix.put(.wmf, .wmz);
-compressSuffix.put(.emf, .emz);
-
-uncompressSuffix.put(.tgz, .tar);
-uncompressSuffix.put(.taz, .tar);
-uncompressSuffix.put(.svgz, .svg);
-uncompressSuffix.put(.cpgz, .cpio);
-uncompressSuffix.put(.wmz, .wmf);
-uncompressSuffix.put(.emz, .emf);
-uncompressSuffix.put(.gz, );
-uncompressSuffix.put(.z, );
-uncompressSuffix.put(-gz, );
-uncompressSuffix.put(-z, );
-uncompressSuffix.put(_z, );
+compressSuffix.put(.tar, .txz);
+
+uncompressSuffix.put(.txz, .tar);
+uncompressSuffix.put(.xz, );
+uncompressSuffix.put(-xz, );
 }
 // N.B. if any shorter or longer keys are added, ensure the for loop 
limits are changed
 
 /** Private constructor to prevent instantiation of this utility class. */
-private GzipUtils() {
+private XZUtils() {
 }
 
 /**
- * Detects common gzip suffixes in the given filename.
+ * Detects common xz suffixes in the given filename.
  *
  * @param filename name of a file
- * @return codetrue/code if the filename has a common gzip suffix,
+ * @return codetrue/code if the filename has a common xz suffix,
  * codefalse/code otherwise
  */
 public static boolean isCompressedFilename(String filename) {
 String lower = filename.toLowerCase(Locale.ENGLISH);
 int n = lower.length();
-// Shortest suffix is two letters (_z), longest is five (.svgz)
-for (int i = 2; i = 5  i  n; i++) {
+// Shortest suffix is three letters (.xz), longest is four (.txz)
+for (int i = 3; i

svn commit: r1196969 - in /commons/proper/compress/trunk: pom.xml src/changes/changes.xml src/main/java/org/apache/commons/compress/compressors/xz/package.html src/site/xdoc/examples.xml src/site/xdoc

2011-11-03 Thread bodewig
Author: bodewig
Date: Thu Nov  3 06:32:25 2011
New Revision: 1196969

URL: http://svn.apache.org/viewvc?rev=1196969view=rev
Log:
documentation for XZ

Added:

commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/compressors/xz/package.html
  - copied, changed from r1196949, 
commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/compressors/gzip/package.html
Modified:
commons/proper/compress/trunk/pom.xml
commons/proper/compress/trunk/src/changes/changes.xml
commons/proper/compress/trunk/src/site/xdoc/examples.xml
commons/proper/compress/trunk/src/site/xdoc/index.xml

Modified: commons/proper/compress/trunk/pom.xml
URL: 
http://svn.apache.org/viewvc/commons/proper/compress/trunk/pom.xml?rev=1196969r1=1196968r2=1196969view=diff
==
--- commons/proper/compress/trunk/pom.xml (original)
+++ commons/proper/compress/trunk/pom.xml Thu Nov  3 06:32:25 2011
@@ -102,6 +102,10 @@
   nameMichael Kuss/name
   emailmail at michael minus kuss.de/email
 /contributor
+contributor
+  nameLasse Collin/name
+  emaillasse.col...@tukaani.org/email
+/contributor
   /contributors
 
   scm

Modified: commons/proper/compress/trunk/src/changes/changes.xml
URL: 
http://svn.apache.org/viewvc/commons/proper/compress/trunk/src/changes/changes.xml?rev=1196969r1=1196968r2=1196969view=diff
==
--- commons/proper/compress/trunk/src/changes/changes.xml (original)
+++ commons/proper/compress/trunk/src/changes/changes.xml Thu Nov  3 06:32:25 
2011
@@ -46,6 +46,9 @@ The action type attribute can be add,u
   body
 release version=1.4 date=unreleased
  description=Release 1.4
+  action issue=COMPRESS-156 type=add date=2011-11-02
+Support for the XZ format has been added.
+  /action 
 /release
 release version=1.3 date=2011-11-01
  description=Release 1.3 - API compatible to 1.2 but requires 
Java5 at runtime

Copied: 
commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/compressors/xz/package.html
 (from r1196949, 
commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/compressors/gzip/package.html)
URL: 
http://svn.apache.org/viewvc/commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/compressors/xz/package.html?p2=commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/compressors/xz/package.htmlp1=commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/compressors/gzip/package.htmlr1=1196949r2=1196969rev=1196969view=diff
==
--- 
commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/compressors/gzip/package.html
 (original)
+++ 
commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/compressors/xz/package.html
 Thu Nov  3 06:32:25 2011
@@ -19,11 +19,13 @@
 --
   body
 pProvides stream classes for compressing and decompressing
-  streams using the GZip algorithm./p
+  streams using the XZ algorithm./p
 
 pThe classes in this package are wrappers around {@link
-  java.util.zip.GZIPInputStream java.util.zip.GZIPInputStream} and
-  {@link java.util.zip.GZIPOutputStream
-  java.util.zip.GZIPOutputStream}./p
+  org.tukaani.xz.XZInputStream org.tukaani.xz.XZInputStream} and
+  {@link org.tukaani.xz.XZOutputStream
+  org.tukaani.xz.XZOutputStream} provided by the public
+  domain a href=http://tukaani.org/xz/java.html;XZ for Java/a
+  library./p
   /body
 /html

Modified: commons/proper/compress/trunk/src/site/xdoc/examples.xml
URL: 
http://svn.apache.org/viewvc/commons/proper/compress/trunk/src/site/xdoc/examples.xml?rev=1196969r1=1196968r2=1196969view=diff
==
--- commons/proper/compress/trunk/src/site/xdoc/examples.xml (original)
+++ commons/proper/compress/trunk/src/site/xdoc/examples.xml Thu Nov  3 
06:32:25 2011
@@ -380,6 +380,30 @@ pIn.close();
 ]]/source
   /subsection
 
+  subsection name=XZ
+
+pThe implementation of this package is provided by the
+  public domain a href=http://tukaani.org/xz/java.html;XZ
+  for Java/a library./p
+
+pUncompressing a given XZ compressed file (you would
+  certainly add exception handling and make sure all streams
+  get closed properly):/p
+source![CDATA[
+FileInputStream fin = new FileInputStream(archive.tar.xz);
+BufferedInputStream in = new BufferedInputStream(fin);
+FileOutputStream out = new FileOutputStream(archive.tar);
+XZCompressorInputStream xzIn = new XZCompressorInputStream(in);
+final byte[] buffer = new byte[buffersize];
+int n = 0;
+while (-1 != (n = xzIn.read(buffer))) {
+out.write(buffer, 0, n);
+}
+out.close();
+xzIn.close

svn commit: r1196970 - /commons/proper/compress/trunk/pom.xml

2011-11-03 Thread bodewig
Author: bodewig
Date: Thu Nov  3 06:33:06 2011
New Revision: 1196970

URL: http://svn.apache.org/viewvc?rev=1196970view=rev
Log:
Christian has an ASF id

Modified:
commons/proper/compress/trunk/pom.xml

Modified: commons/proper/compress/trunk/pom.xml
URL: 
http://svn.apache.org/viewvc/commons/proper/compress/trunk/pom.xml?rev=1196970r1=1196969r2=1196970view=diff
==
--- commons/proper/compress/trunk/pom.xml (original)
+++ commons/proper/compress/trunk/pom.xml Thu Nov  3 06:33:06 2011
@@ -81,6 +81,7 @@
 /developer
 developer
   nameChristian Grobmeier/name
+  idgrobmeier/id
   emailgrobmeier at apache.org/email
 /developer
   /developers




svn commit: r1197165 - in /commons/proper/compress/trunk/src: main/java/org/apache/commons/compress/compressors/ main/java/org/apache/commons/compress/compressors/bzip2/ main/java/org/apache/commons/c

2011-11-03 Thread bodewig
Author: bodewig
Date: Thu Nov  3 14:48:04 2011
New Revision: 1197165

URL: http://svn.apache.org/viewvc?rev=1197165view=rev
Log:
extract common file name munging code from the *Utils classes

Added:

commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/compressors/FileNameUtil.java
  - copied, changed from r1197084, 
commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/compressors/gzip/GzipUtils.java
Modified:

commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/compressors/bzip2/BZip2Utils.java

commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/compressors/gzip/GzipUtils.java

commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/compressors/xz/XZUtils.java

commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/compressors/BZip2UtilsTestCase.java

Copied: 
commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/compressors/FileNameUtil.java
 (from r1197084, 
commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/compressors/gzip/GzipUtils.java)
URL: 
http://svn.apache.org/viewvc/commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/compressors/FileNameUtil.java?p2=commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/compressors/FileNameUtil.javap1=commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/compressors/gzip/GzipUtils.javar1=1197084r2=1197165rev=1197165view=diff
==
--- 
commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/compressors/gzip/GzipUtils.java
 (original)
+++ 
commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/compressors/FileNameUtil.java
 Thu Nov  3 14:48:04 2011
@@ -16,73 +16,125 @@
  * specific language governing permissions and limitations
  * under the License.
  */
-package org.apache.commons.compress.compressors.gzip;
+package org.apache.commons.compress.compressors;
 
+import java.util.Collections;
 import java.util.HashMap;
 import java.util.Locale;
 import java.util.Map;
 
 /**
- * Utility code for the gzip compression format.
+ * File name mapping code for the compression formats.
  * @ThreadSafe
+ * @since Apache Commons Compress 1.4
  */
-public class GzipUtils {
+public class FileNameUtil {
 
 /**
- * Map from common filename suffixes to the suffixes that identify gzipped
+ * Map from common filename suffixes to the suffixes that identify 
compressed
  * versions of those file types. For example: from .tar to .tgz.
  */
-private static final MapString, String compressSuffix =
-new HashMapString, String();
+private final MapString, String compressSuffix =
+new HashMapString, String();
 
 /**
- * Map from common filename suffixes of gzipped files to the corresponding
- * suffixes of uncompressed files. For example: from .tgz to .tar.
+ * Map from common filename suffixes of compressed files to the
+ * corresponding suffixes of uncompressed files. For example: from
+ * .tgz to .tar.
  * p
- * This map also contains gzip-specific suffixes like .gz and -z.
+ * This map also contains format-specific suffixes like .gz and -z.
  * These suffixes are mapped to the empty string, as they should simply
  * be removed from the filename when the file is uncompressed.
  */
-private static final MapString, String uncompressSuffix =
-new HashMapString, String();
+private final MapString, String uncompressSuffix;
 
-static {
-compressSuffix.put(.tar, .tgz);
-compressSuffix.put(.svg, .svgz);
-compressSuffix.put(.cpio, .cpgz);
-compressSuffix.put(.wmf, .wmz);
-compressSuffix.put(.emf, .emz);
-
-uncompressSuffix.put(.tgz, .tar);
-uncompressSuffix.put(.taz, .tar);
-uncompressSuffix.put(.svgz, .svg);
-uncompressSuffix.put(.cpgz, .cpio);
-uncompressSuffix.put(.wmz, .wmf);
-uncompressSuffix.put(.emz, .emf);
-uncompressSuffix.put(.gz, );
-uncompressSuffix.put(.z, );
-uncompressSuffix.put(-gz, );
-uncompressSuffix.put(-z, );
-uncompressSuffix.put(_z, );
-}
-// N.B. if any shorter or longer keys are added, ensure the for loop 
limits are changed
+/**
+ * Length of the longest compressed suffix.
+ */
+private final int longestCompressedSuffix;
 
-/** Private constructor to prevent instantiation of this utility class. */
-private GzipUtils() {
+/**
+ * Length of the shortest compressed suffix.
+ */
+private final int shortestCompressedSuffix;
+
+/**
+ * Length of the longest uncompressed suffix.
+ */
+private final int longestUncompressedSuffix;
+
+/**
+ * Length of the shortest uncompressed suffix longer than the
+ * empty string

svn commit: r1198806 - in /commons/proper/compress/trunk/src: changes/changes.xml main/java/org/apache/commons/compress/compressors/bzip2/BZip2CompressorInputStream.java

2011-11-07 Thread bodewig
Author: bodewig
Date: Mon Nov  7 16:36:51 2011
New Revision: 1198806

URL: http://svn.apache.org/viewvc?rev=1198806view=rev
Log:
support uncompressing concatenated .bz2 files.  COMPRESS-146.  Submitted by 
Lasse Collin

Modified:
commons/proper/compress/trunk/src/changes/changes.xml

commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/compressors/bzip2/BZip2CompressorInputStream.java

Modified: commons/proper/compress/trunk/src/changes/changes.xml
URL: 
http://svn.apache.org/viewvc/commons/proper/compress/trunk/src/changes/changes.xml?rev=1198806r1=1198805r2=1198806view=diff
==
--- commons/proper/compress/trunk/src/changes/changes.xml (original)
+++ commons/proper/compress/trunk/src/changes/changes.xml Mon Nov  7 16:36:51 
2011
@@ -49,6 +49,10 @@ The action type attribute can be add,u
   action issue=COMPRESS-156 type=add date=2011-11-02
 Support for the XZ format has been added.
   /action 
+  action issue=COMPRESS-146 type=update date=2011-11-07
+BZip2CompressorInputStream now optionally supports reading of
+concatenated .bz2 files.
+  /action
 /release
 release version=1.3 date=2011-11-01
  description=Release 1.3 - API compatible to 1.2 but requires 
Java5 at runtime

Modified: 
commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/compressors/bzip2/BZip2CompressorInputStream.java
URL: 
http://svn.apache.org/viewvc/commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/compressors/bzip2/BZip2CompressorInputStream.java?rev=1198806r1=1198805r2=1198806view=diff
==
--- 
commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/compressors/bzip2/BZip2CompressorInputStream.java
 (original)
+++ 
commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/compressors/bzip2/BZip2CompressorInputStream.java
 Mon Nov  7 16:36:51 2011
@@ -62,6 +62,7 @@ public class BZip2CompressorInputStream 
 private int nInUse;
 
 private InputStream in;
+private final boolean decompressConcatenated;
 
 private int currentChar = -1;
 
@@ -97,8 +98,9 @@ public class BZip2CompressorInputStream 
 private BZip2CompressorInputStream.Data data;
 
 /**
- * Constructs a new BZip2CompressorInputStream which decompresses bytes 
read from the
- * specified stream.
+ * Constructs a new BZip2CompressorInputStream which decompresses bytes
+ * read from the specified stream. This doesn't suppprt decompressing
+ * concatenated .bz2 files.
  * 
  * @throws IOException
  * if the stream content is malformed or an I/O error occurs.
@@ -106,10 +108,37 @@ public class BZip2CompressorInputStream 
  * if ttin == null/tt
  */
 public BZip2CompressorInputStream(final InputStream in) throws IOException 
{
+this(in, false);
+}
+
+/**
+ * Constructs a new BZip2CompressorInputStream which decompresses bytes
+ * read from the specified stream.
+ *
+ * @param inputStream  the InputStream from which this object should
+ * be created of
+ * @param decompressConcatenated
+ * if true, decompress until the end of the input;
+ * if false, stop after the first .bz2 stream and
+ * leave the input position to point to the next
+ * byte after the .bz2 stream
+ *
+ * @throws IOException
+ * if the stream content is malformed or an I/O error occurs.
+ * @throws NullPointerException
+ * if ttin == null/tt
+ */
+public BZip2CompressorInputStream(final InputStream in,
+  final boolean decompressConcatenated)
+throws IOException {
 super();
 
 this.in = in;
-init();
+this.decompressConcatenated = decompressConcatenated;
+
+init(true);
+initBlock();
+setupBlock();
 }
 
 /** {@inheritDoc} */
@@ -210,54 +239,71 @@ public class BZip2CompressorInputStream 
 return retChar;
 }
 
-private void init() throws IOException {
+private boolean init(boolean isFirstStream) throws IOException {
 if (null == in) {
 throw new IOException(No InputStream);
 }
-checkMagicChar('B', first);
-checkMagicChar('Z', second);
-checkMagicChar('h', third);
+
+int magic0 = this.in.read();
+int magic1 = this.in.read();
+int magic2 = this.in.read();
+if (magic0 == -1  !isFirstStream)
+return false;
+
+if (magic0 != 'B' || magic1 != 'Z' || magic2 != 'h')
+throw new IOException(isFirstStream
+? Stream is not in the BZip2 format
+: Garbage

svn commit: r1199812 - /commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/compressors/gzip/GzipCompressorInputStream.java

2011-11-09 Thread bodewig
Author: bodewig
Date: Wed Nov  9 15:55:10 2011
New Revision: 1199812

URL: http://svn.apache.org/viewvc?rev=1199812view=rev
Log:
support for concatenated streams in Gzip input.  COMPRESS-154.  Submitted by 
Lasse Collin

Modified:

commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/compressors/gzip/GzipCompressorInputStream.java

Modified: 
commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/compressors/gzip/GzipCompressorInputStream.java
URL: 
http://svn.apache.org/viewvc/commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/compressors/gzip/GzipCompressorInputStream.java?rev=1199812r1=1199811r2=1199812view=diff
==
--- 
commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/compressors/gzip/GzipCompressorInputStream.java
 (original)
+++ 
commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/compressors/gzip/GzipCompressorInputStream.java
 Wed Nov  9 15:55:10 2011
@@ -19,71 +19,282 @@
 package org.apache.commons.compress.compressors.gzip;
 
 import java.io.IOException;
+import java.io.EOFException;
 import java.io.InputStream;
-import java.util.zip.GZIPInputStream;
+import java.io.DataInputStream;
+import java.io.BufferedInputStream;
+import java.util.zip.DataFormatException;
+import java.util.zip.Inflater;
+import java.util.zip.CRC32;
 
 import org.apache.commons.compress.compressors.CompressorInputStream;
 
 /**
- * Implements the gz compression format as an input stream.
- * This classes wraps the standard java classes for working with gz. 
+ * Input stream that decompresses .gz files.
+ * This supports decompressing concatenated .gz files which is important
+ * when decompressing standalone .gz files.
+ * p
+ * {@link java.util.zip.GZIPInputStream} doesn't decompress concatenated .gz
+ * files: it stops after the first member and silently ignores the rest.
+ * It doesn't leave the read position to point to the beginning of the next
+ * member, which makes it difficult workaround the lack of concatenation
+ * support.
+ * p
+ * Instead of using codeGZIPInputStream/code, this class has its own .gz
+ * container format decoder. The actual decompression is done with
+ * {@link java.util.zip.Inflater}.
  */
 public class GzipCompressorInputStream extends CompressorInputStream {
-/* reference to the compressed stream */
-private final GZIPInputStream in; 
+// Header flags
+// private static final int FTEXT = 0x01; // Uninteresting for us
+private static final int FHCRC = 0x02;
+private static final int FEXTRA = 0x04;
+private static final int FNAME = 0x08;
+private static final int FCOMMENT = 0x10;
+private static final int FRESERVED = 0xE0;
+
+// Compressed input stream, possibly wrapped in a BufferedInputStream
+private final InputStream in;
+
+// True if decompressing multimember streams.
+private final boolean decompressConcatenated;
+
+// Buffer to hold the input data
+private final byte[] buf = new byte[8192];
+
+// Amount of data in buf.
+private int bufUsed = 0;
+
+// Decompressor
+private Inflater inf = new Inflater(true);
+
+// CRC32 from uncompressed data
+private CRC32 crc = new CRC32();
+
+private int memberSize;
+
+// True once everything has been decompressed
+private boolean endReached = false;
 
 /**
- * Constructs a new GZip compressed input stream by the referenced
- * InputStream.
- * 
- * @param inputStream the InputStream from which this object should be 
created of
+ * Constructs a new input stream that decompresses gzip-compressed data
+ * from the specified input stream.
+ * p
+ * This is equivalent to
+ * codeGzipCompressorInputStream(inputStream, false)/code and thus
+ * will not decompress concatenated .gz files.
+ *
+ * @param inputStream  the InputStream from which this object should
+ * be created of
+ *
  * @throws IOException if the stream could not be created
  */
-public GzipCompressorInputStream(InputStream inputStream) throws 
IOException {
-in = new GZIPInputStream(inputStream);
+public GzipCompressorInputStream(InputStream inputStream)
+throws IOException {
+this(inputStream, false);
+}
+
+/**
+ * Constructs a new input stream that decompresses gzip-compressed data
+ * from the specified input stream.
+ * p
+ * If codedecompressConcatenated/code is codefalse/code:
+ * This decompressor might read more input than it will actually use.
+ * If codeinputStream/code supports codemark/code and
+ * codereset/code, then the input position will be adjusted
+ * so that it is right after the last byte of the compressed stream.
+ * If codemark/code isn't supported, the input position will be
+ * undefined.
+ *
+ * @param inputStream

svn commit: r1199814 - /commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/compressors/gzip/GzipCompressorInputStream.java

2011-11-09 Thread bodewig
Author: bodewig
Date: Wed Nov  9 16:05:11 2011
New Revision: 1199814

URL: http://svn.apache.org/viewvc?rev=1199814view=rev
Log:
some '@Override's that have been removed by accident

Modified:

commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/compressors/gzip/GzipCompressorInputStream.java

Modified: 
commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/compressors/gzip/GzipCompressorInputStream.java
URL: 
http://svn.apache.org/viewvc/commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/compressors/gzip/GzipCompressorInputStream.java?rev=1199814r1=1199813r2=1199814view=diff
==
--- 
commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/compressors/gzip/GzipCompressorInputStream.java
 (original)
+++ 
commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/compressors/gzip/GzipCompressorInputStream.java
 Wed Nov  9 16:05:11 2011
@@ -198,6 +198,7 @@ public class GzipCompressorInputStream e
 }
 
 /** {@inheritDoc} */
+@Override
 public int read() throws IOException {
 byte[] buf = new byte[1];
 return read(buf, 0, 1) == -1 ? -1 : (buf[0]  0xFF);
@@ -208,6 +209,7 @@ public class GzipCompressorInputStream e
  *
  * @since Apache Commons Compress 1.1
  */
+@Override
 public int read(byte[] b, int off, int len) throws IOException {
 if (endReached)
 return -1;
@@ -319,6 +321,7 @@ public class GzipCompressorInputStream e
  *
  * @since 1.2
  */
+@Override
 public void close() throws IOException {
 if (inf != null) {
 inf.end();




svn commit: r1199823 - in /commons/proper/compress/trunk/src: changes/changes.xml site/xdoc/examples.xml site/xdoc/index.xml

2011-11-09 Thread bodewig
Author: bodewig
Date: Wed Nov  9 16:18:05 2011
New Revision: 1199823

URL: http://svn.apache.org/viewvc?rev=1199823view=rev
Log:
document support for concatenated streams

Modified:
commons/proper/compress/trunk/src/changes/changes.xml
commons/proper/compress/trunk/src/site/xdoc/examples.xml
commons/proper/compress/trunk/src/site/xdoc/index.xml

Modified: commons/proper/compress/trunk/src/changes/changes.xml
URL: 
http://svn.apache.org/viewvc/commons/proper/compress/trunk/src/changes/changes.xml?rev=1199823r1=1199822r2=1199823view=diff
==
--- commons/proper/compress/trunk/src/changes/changes.xml (original)
+++ commons/proper/compress/trunk/src/changes/changes.xml Wed Nov  9 16:18:05 
2011
@@ -53,6 +53,10 @@ The action type attribute can be add,u
 BZip2CompressorInputStream now optionally supports reading of
 concatenated .bz2 files.
   /action
+  action issue=COMPRESS-154 type=update date=2011-11-09
+GZipCompressorInputStream now optionally supports reading of
+concatenated .gz files.
+  /action
 /release
 release version=1.3 date=2011-11-01
  description=Release 1.3 - API compatible to 1.2 but requires 
Java5 at runtime

Modified: commons/proper/compress/trunk/src/site/xdoc/examples.xml
URL: 
http://svn.apache.org/viewvc/commons/proper/compress/trunk/src/site/xdoc/examples.xml?rev=1199823r1=1199822r2=1199823view=diff
==
--- commons/proper/compress/trunk/src/site/xdoc/examples.xml (original)
+++ commons/proper/compress/trunk/src/site/xdoc/examples.xml Wed Nov  9 
16:18:05 2011
@@ -71,6 +71,17 @@ ArchiveInputStream input = new ArchiveSt
 
   /subsection
 
+  subsection name=Concatenated Streams
+pFor the bzip2, gzip and xz formats a single compressed file
+may actually consist of several streams that will be
+concatenated by the commnd line utilities when decompressing
+them.  Starting with Commons Compress 1.4 the
+code*CompressorInputStream/codes for these formats support
+concatenating streams as well, but they won't do so by
+default.  You must use the two-arg constructor and explicitly
+enable the support./p
+  /subsection
+
   subsection name=ar
 
 pIn addition to the information stored

Modified: commons/proper/compress/trunk/src/site/xdoc/index.xml
URL: 
http://svn.apache.org/viewvc/commons/proper/compress/trunk/src/site/xdoc/index.xml?rev=1199823r1=1199822r2=1199823view=diff
==
--- commons/proper/compress/trunk/src/site/xdoc/index.xml (original)
+++ commons/proper/compress/trunk/src/site/xdoc/index.xml Wed Nov  9 16:18:05 
2011
@@ -62,7 +62,7 @@
 usually correspond to single files or directories./p
 
   pCurrently the bzip2, Pack200, XZ and gzip formats are
-supported as compressors where gzip support is provided by
+supported as compressors where gzip support is mostly provided by
 the codejava.util.zip/code package and Pack200 support
 by the codejava.util.jar/code package of the Java
 class library.  XZ support is provided by the public




svn commit: r1203621 - in /commons/proper/compress/trunk/src/test: java/org/apache/commons/compress/compressors/ resources/

2011-11-18 Thread bodewig
Author: bodewig
Date: Fri Nov 18 12:20:05 2011
New Revision: 1203621

URL: http://svn.apache.org/viewvc?rev=1203621view=rev
Log:
testcases for compressors with concatenated streams.  COMPRESS-146 COMPRESS-154 
COMPRESS156

Added:
commons/proper/compress/trunk/src/test/resources/multiple.bz2   (with props)
commons/proper/compress/trunk/src/test/resources/multiple.gz   (with props)
commons/proper/compress/trunk/src/test/resources/multiple.xz   (with props)
Modified:

commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/compressors/BZip2TestCase.java

commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/compressors/GZipTestCase.java

commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/compressors/XZTestCase.java

Modified: 
commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/compressors/BZip2TestCase.java
URL: 
http://svn.apache.org/viewvc/commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/compressors/BZip2TestCase.java?rev=1203621r1=1203620r2=1203621view=diff
==
--- 
commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/compressors/BZip2TestCase.java
 (original)
+++ 
commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/compressors/BZip2TestCase.java
 Fri Nov 18 12:20:05 2011
@@ -25,6 +25,7 @@ import java.io.InputStream;
 import java.io.OutputStream;
 
 import org.apache.commons.compress.AbstractTestCase;
+import 
org.apache.commons.compress.compressors.bzip2.BZip2CompressorInputStream;
 import org.apache.commons.compress.utils.IOUtils;
 
 public final class BZip2TestCase extends AbstractTestCase {
@@ -68,4 +69,39 @@ public final class BZip2TestCase extends
 os.close();
 }
 
+public void testConcatenatedStreamsReadFirstOnly() throws Exception {
+final File input = getFile(multiple.bz2);
+final InputStream is = new FileInputStream(input);
+try {
+final CompressorInputStream in = new CompressorStreamFactory()
+.createCompressorInputStream(bzip2, is);
+try {
+assertEquals('a', in.read());
+assertEquals(-1, in.read());
+} finally {
+in.close();
+}
+} finally {
+is.close();
+}
+}
+
+public void testConcatenatedStreamsReadFully() throws Exception {
+final File input = getFile(multiple.bz2);
+final InputStream is = new FileInputStream(input);
+try {
+final CompressorInputStream in =
+new BZip2CompressorInputStream(is, true);
+try {
+assertEquals('a', in.read());
+assertEquals('b', in.read());
+assertEquals(0, in.available());
+assertEquals(-1, in.read());
+} finally {
+in.close();
+}
+} finally {
+is.close();
+}
+}
 }

Modified: 
commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/compressors/GZipTestCase.java
URL: 
http://svn.apache.org/viewvc/commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/compressors/GZipTestCase.java?rev=1203621r1=1203620r2=1203621view=diff
==
--- 
commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/compressors/GZipTestCase.java
 (original)
+++ 
commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/compressors/GZipTestCase.java
 Fri Nov 18 12:20:05 2011
@@ -28,6 +28,7 @@ import java.io.InputStream;
 import java.io.OutputStream;
 
 import org.apache.commons.compress.AbstractTestCase;
+import org.apache.commons.compress.compressors.gzip.GzipCompressorInputStream;
 import org.apache.commons.compress.utils.IOUtils;
 
 public final class GZipTestCase extends AbstractTestCase {
@@ -71,6 +72,42 @@ public final class GZipTestCase extends 
 }
 }
 
+public void testConcatenatedStreamsReadFirstOnly() throws Exception {
+final File input = getFile(multiple.gz);
+final InputStream is = new FileInputStream(input);
+try {
+final CompressorInputStream in = new CompressorStreamFactory()
+.createCompressorInputStream(gz, is);
+try {
+assertEquals('a', in.read());
+assertEquals(-1, in.read());
+} finally {
+in.close();
+}
+} finally {
+is.close();
+}
+}
+
+public void testConcatenatedStreamsReadFully() throws Exception {
+final File input = getFile(multiple.gz);
+final InputStream is = new FileInputStream(input);
+try {
+final CompressorInputStream in =
+new GzipCompressorInputStream(is, true);
+try

svn commit: r1210386 - in /commons/proper/compress/trunk: pom.xml src/changes/changes.xml src/main/java/org/apache/commons/compress/archivers/tar/TarArchiveEntry.java src/main/java/org/apache/commons/

2011-12-05 Thread bodewig
Author: bodewig
Date: Mon Dec  5 09:58:04 2011
New Revision: 1210386

URL: http://svn.apache.org/viewvc?rev=1210386view=rev
Log:
Add read-support for big files using GNU tar extensions.  write support will be 
added later.  Based on patch by John Kodis.  COMPRESS-16

Modified:
commons/proper/compress/trunk/pom.xml
commons/proper/compress/trunk/src/changes/changes.xml

commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/tar/TarArchiveEntry.java

commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/tar/TarUtils.java

Modified: commons/proper/compress/trunk/pom.xml
URL: 
http://svn.apache.org/viewvc/commons/proper/compress/trunk/pom.xml?rev=1210386r1=1210385r2=1210386view=diff
==
--- commons/proper/compress/trunk/pom.xml (original)
+++ commons/proper/compress/trunk/pom.xml Mon Dec  5 09:58:04 2011
@@ -107,6 +107,9 @@
   nameLasse Collin/name
   emaillasse.col...@tukaani.org/email
 /contributor
+contributor
+  nameJohn Kodis/name
+/contributor
   /contributors
 
   scm

Modified: commons/proper/compress/trunk/src/changes/changes.xml
URL: 
http://svn.apache.org/viewvc/commons/proper/compress/trunk/src/changes/changes.xml?rev=1210386r1=1210385r2=1210386view=diff
==
--- commons/proper/compress/trunk/src/changes/changes.xml (original)
+++ commons/proper/compress/trunk/src/changes/changes.xml Mon Dec  5 09:58:04 
2011
@@ -57,6 +57,10 @@ The action type attribute can be add,u
 GZipCompressorInputStream now optionally supports reading of
 concatenated .gz files.
   /action
+  action issue=COMPRESS-16 type=update date=2011-12-05
+The tar package can now read archives that use GNU extensions
+for files that are longer than 8 GByte.
+  /action
 /release
 release version=1.3 date=2011-11-01
  description=Release 1.3 - API compatible to 1.2 but requires 
Java5 at runtime

Modified: 
commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/tar/TarArchiveEntry.java
URL: 
http://svn.apache.org/viewvc/commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/tar/TarArchiveEntry.java?rev=1210386r1=1210385r2=1210386view=diff
==
--- 
commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/tar/TarArchiveEntry.java
 (original)
+++ 
commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/tar/TarArchiveEntry.java
 Mon Dec  5 09:58:04 2011
@@ -789,7 +789,7 @@ public class TarArchiveEntry implements 
 offset += UIDLEN;
 groupId = (int) TarUtils.parseOctal(header, offset, GIDLEN);
 offset += GIDLEN;
-size = TarUtils.parseOctal(header, offset, SIZELEN);
+size = TarUtils.parseOctalOrBinary(header, offset, SIZELEN);
 offset += SIZELEN;
 modTime = TarUtils.parseOctal(header, offset, MODTIMELEN);
 offset += MODTIMELEN;

Modified: 
commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/tar/TarUtils.java
URL: 
http://svn.apache.org/viewvc/commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/tar/TarUtils.java?rev=1210386r1=1210385r2=1210386view=diff
==
--- 
commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/tar/TarUtils.java
 (original)
+++ 
commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/tar/TarUtils.java
 Mon Dec  5 09:58:04 2011
@@ -106,6 +106,41 @@ public class TarUtils {
 return result;
 }
 
+/** 
+ * Compute the value contained in a byte buffer.  If the most
+ * significant bit of the first byte in the buffer is set, this
+ * bit is ignored and the rest of the buffer is interpreted as a
+ * binary number.  Otherwise, the buffer is interpreted as an
+ * octal number as per the parseOctal function above.
+ *
+ * @param buffer The buffer from which to parse.
+ * @param offset The offset into the buffer from which to parse.
+ * @param length The maximum number of bytes to parse.
+ * @return The long value of the octal or binary string.
+ * @throws IllegalArgumentException if the trailing space/NUL is
+ * missing or an invalid byte is detected in an octal number, or
+ * if a binary number would exceed the size of a signed long
+ * 64-bit integer.
+ */
+public static long parseOctalOrBinary(final byte[] buffer, final int 
offset,
+  final int length) {
+
+if ((buffer[offset]  0x80) == 0) {
+return parseOctal(buffer, offset, length);
+}
+
+long val

svn commit: r1210395 - /commons/proper/compress/trunk/pom.xml

2011-12-05 Thread bodewig
Author: bodewig
Date: Mon Dec  5 10:22:59 2011
New Revision: 1210395

URL: http://svn.apache.org/viewvc?rev=1210395view=rev
Log:
rename run-it profile to run-zipit so ITs for other formats can be added 
individually

Modified:
commons/proper/compress/trunk/pom.xml

Modified: commons/proper/compress/trunk/pom.xml
URL: 
http://svn.apache.org/viewvc/commons/proper/compress/trunk/pom.xml?rev=1210395r1=1210394r2=1210395view=diff
==
--- commons/proper/compress/trunk/pom.xml (original)
+++ commons/proper/compress/trunk/pom.xml Mon Dec  5 10:22:59 2011
@@ -294,7 +294,7 @@
   /build
 /profile
 profile
-  idrun-it/id
+  idrun-zipit/id
   !-- Add long running tests as **/*IT.java --
   build
 plugins
@@ -321,8 +321,7 @@
 artifactIdmaven-surefire-plugin/artifactId
 configuration
   includes
-include**/*Test.java/include
-include**/*IT.java/include
+include**/zip/*IT.java/include
   /includes
 /configuration
   /plugin




svn commit: r1210417 - in /commons/proper/compress/trunk: pom.xml src/test/java/org/apache/commons/compress/archivers/tar/BigFilesIT.java src/test/resources/8.tar.gz

2011-12-05 Thread bodewig
Author: bodewig
Date: Mon Dec  5 11:49:03 2011
New Revision: 1210417

URL: http://svn.apache.org/viewvc?rev=1210417view=rev
Log:
Test for reading GNU tar archive with file bigger than 8 GiB.  COMPRESS-16

Added:

commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/archivers/tar/BigFilesIT.java
   (with props)
commons/proper/compress/trunk/src/test/resources/8.tar.gz   (with props)
Modified:
commons/proper/compress/trunk/pom.xml

Modified: commons/proper/compress/trunk/pom.xml
URL: 
http://svn.apache.org/viewvc/commons/proper/compress/trunk/pom.xml?rev=1210417r1=1210416r2=1210417view=diff
==
--- commons/proper/compress/trunk/pom.xml (original)
+++ commons/proper/compress/trunk/pom.xml Mon Dec  5 11:49:03 2011
@@ -293,9 +293,9 @@
 /plugins
   /build
 /profile
+!-- Add long running tests as **/*IT.java --
 profile
   idrun-zipit/id
-  !-- Add long running tests as **/*IT.java --
   build
 plugins
   plugin
@@ -328,6 +328,21 @@
 /plugins
   /build
 /profile
+profile
+  idrun-tarit/id
+  build
+plugins
+  plugin
+artifactIdmaven-surefire-plugin/artifactId
+configuration
+  includes
+include**/tar/*IT.java/include
+  /includes
+/configuration
+  /plugin
+/plugins
+  /build
+/profile
   /profiles
 
 /project

Added: 
commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/archivers/tar/BigFilesIT.java
URL: 
http://svn.apache.org/viewvc/commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/archivers/tar/BigFilesIT.java?rev=1210417view=auto
==
--- 
commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/archivers/tar/BigFilesIT.java
 (added)
+++ 
commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/archivers/tar/BigFilesIT.java
 Mon Dec  5 11:49:03 2011
@@ -0,0 +1,70 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one or more
+ *  contributor license agreements.  See the NOTICE file distributed with
+ *  this work for additional information regarding copyright ownership.
+ *  The ASF licenses this file to You under the Apache License, Version 2.0
+ *  (the License); you may not use this file except in compliance with
+ *  the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an AS IS BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ *
+ */
+
+package org.apache.commons.compress.archivers.tar;
+
+import java.util.Random;
+
+import org.junit.Test;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
+
+import org.apache.commons.compress.compressors.gzip.GzipCompressorInputStream;
+
+public class BigFilesIT {
+
+@Test
+public void readFileBiggerThan8GByte() throws Exception {
+GzipCompressorInputStream in = null;
+TarArchiveInputStream tin = null;
+try {
+in =
+new GzipCompressorInputStream(BigFilesIT.class
+  
.getResourceAsStream(/8.tar.gz));
+tin = new TarArchiveInputStream(in);
+TarArchiveEntry e = tin.getNextTarEntry();
+assertNotNull(e);
+assertEquals(8200l * 1024 * 1024, e.getSize());
+
+long read = 0;
+Random r = new Random(System.currentTimeMillis());
+int readNow;
+byte[] buf = new byte[1024 * 1024];
+while ((readNow = tin.read(buf, 0, buf.length))  0) {
+// testing all bytes for a value of 0 is going to take
+// too long, just pick a few ones randomly
+for (int i = 0; i  100; i++) {
+int idx = r.nextInt(readNow);
+assertEquals(testing byte  + (read + idx), 0, buf[idx]);
+}
+read += readNow;
+}
+assertEquals(8200l * 1024 * 1024, read);
+assertNull(tin.getNextTarEntry());
+} finally {
+if (tin != null) {
+tin.close();
+}
+if (in != null) {
+in.close();
+}
+}
+}
+
+}

Propchange: 
commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/archivers/tar/BigFilesIT.java
--
svn:eol-style

svn commit: r1210501 - in /commons/proper/compress/trunk/src: changes/changes.xml main/java/org/apache/commons/compress/archivers/zip/ZipFile.java test/java/org/apache/commons/compress/archivers/zip/U

2011-12-05 Thread bodewig
Author: bodewig
Date: Mon Dec  5 15:39:52 2011
New Revision: 1210501

URL: http://svn.apache.org/viewvc?rev=1210501view=rev
Log:
ZipFile doesn't work properly for unicode extra fields.  Based on patch by 
Volker Leidl.  COMPRESS-164

Modified:
commons/proper/compress/trunk/src/changes/changes.xml

commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/zip/ZipFile.java

commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/archivers/zip/UTF8ZipFilesTest.java

Modified: commons/proper/compress/trunk/src/changes/changes.xml
URL: 
http://svn.apache.org/viewvc/commons/proper/compress/trunk/src/changes/changes.xml?rev=1210501r1=1210500r2=1210501view=diff
==
--- commons/proper/compress/trunk/src/changes/changes.xml (original)
+++ commons/proper/compress/trunk/src/changes/changes.xml Mon Dec  5 15:39:52 
2011
@@ -61,6 +61,10 @@ The action type attribute can be add,u
 The tar package can now read archives that use GNU extensions
 for files that are longer than 8 GByte.
   /action
+  action issue=COMPRESS-164 type=fix date=2011-12-05
+ZipFile didn't work properly for archives using unicode extra
+fields rather than UTF-8 filenames and the EFS-Flag.
+  /action
 /release
 release version=1.3 date=2011-11-01
  description=Release 1.3 - API compatible to 1.2 but requires 
Java5 at runtime

Modified: 
commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/zip/ZipFile.java
URL: 
http://svn.apache.org/viewvc/commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/zip/ZipFile.java?rev=1210501r1=1210500r2=1210501view=diff
==
--- 
commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/zip/ZipFile.java
 (original)
+++ 
commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/zip/ZipFile.java
 Mon Dec  5 15:39:52 2011
@@ -801,8 +801,15 @@ public class ZipFile {
 private void resolveLocalFileHeaderData(MapZipArchiveEntry, 
NameAndComment
 entriesWithoutUTF8Flag)
 throws IOException {
-for (ZipArchiveEntry ze : entries.keySet()) {
-OffsetEntry offsetEntry = entries.get(ze);
+// changing the name of a ZipArchiveEntry is going to change
+// the hashcode - see COMPRESS-164
+// Map needs to be reconstructed in order to keep central
+// directory order
+MapZipArchiveEntry, OffsetEntry origMap =
+new LinkedHashMapZipArchiveEntry, OffsetEntry(entries);
+entries.clear();
+for (ZipArchiveEntry ze : origMap.keySet()) {
+OffsetEntry offsetEntry = origMap.get(ze);
 long offset = offsetEntry.headerOffset;
 archive.seek(offset + LFH_OFFSET_FOR_FILENAME_LENGTH);
 byte[] b = new byte[SHORT];
@@ -835,6 +842,7 @@ public class ZipFile {
 nameMap.put(ze.getName(), ze);
 }
 }
+entries.put(ze, offsetEntry);
 }
 }
 

Modified: 
commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/archivers/zip/UTF8ZipFilesTest.java
URL: 
http://svn.apache.org/viewvc/commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/archivers/zip/UTF8ZipFilesTest.java?rev=1210501r1=1210500r2=1210501view=diff
==
--- 
commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/archivers/zip/UTF8ZipFilesTest.java
 (original)
+++ 
commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/archivers/zip/UTF8ZipFilesTest.java
 Mon Dec  5 15:39:52 2011
@@ -21,6 +21,7 @@ package org.apache.commons.compress.arch
 import java.io.File;
 import java.io.FileInputStream;
 import java.io.IOException;
+import java.io.InputStream;
 import java.io.UnsupportedEncodingException;
 import java.net.URI;
 import java.net.URISyntaxException;
@@ -128,14 +129,26 @@ public class UTF8ZipFilesTest extends Ab
 ZipFile zf = null;
 try {
 zf = new ZipFile(archive, null, true);
-assertNotNull(zf.getEntry(ASCII_TXT));
-assertNotNull(zf.getEntry(EURO_FOR_DOLLAR_TXT));
-assertNotNull(zf.getEntry(OIL_BARREL_TXT));
+assertCanRead(zf, ASCII_TXT);
+assertCanRead(zf, EURO_FOR_DOLLAR_TXT);
+assertCanRead(zf, OIL_BARREL_TXT);
 } finally {
 ZipFile.closeQuietly(zf);
 }
 }
 
+private void assertCanRead(ZipFile zf, String fileName) throws IOException 
{
+ZipArchiveEntry entry = zf.getEntry(fileName);
+assertNotNull(Entry doesn't exist, entry);
+InputStream is = zf.getInputStream(entry

svn commit: r1211393 - in /commons/proper/compress/trunk/src: main/java/org/apache/commons/compress/archivers/tar/ test/java/org/apache/commons/compress/archivers/tar/

2011-12-07 Thread bodewig
Author: bodewig
Date: Wed Dec  7 11:34:34 2011
New Revision: 1211393

URL: http://svn.apache.org/viewvc?rev=1211393view=rev
Log:
Allow PAX headers to set sizes bigger than 8GiB.  COMPRESS-163.  Based on patch 
by John Kodis

Modified:

commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/tar/TarArchiveEntry.java

commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/tar/TarArchiveInputStream.java

commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/archivers/tar/TarArchiveEntryTest.java

Modified: 
commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/tar/TarArchiveEntry.java
URL: 
http://svn.apache.org/viewvc/commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/tar/TarArchiveEntry.java?rev=1211393r1=1211392r2=1211393view=diff
==
--- 
commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/tar/TarArchiveEntry.java
 (original)
+++ 
commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/tar/TarArchiveEntry.java
 Wed Dec  7 11:34:34 2011
@@ -572,6 +572,20 @@ public class TarArchiveEntry implements 
 }
 
 /**
+ * Set this entry's file size.
+ *
+ * pInvoked by input stream when reading a PAX header./p
+ * @throws IllegalArgumentException if the size is lt; 0
+ * @since Apache Commons Compress 1.4
+ */
+void adjustSize(long size) {
+if (size  0){
+throw new IllegalArgumentException(Size is out of range:  + 
size);
+}
+this.size = size;
+}
+
+/**
  * Indicates in case of a sparse file if an extension sparse header
  * follows.
  *

Modified: 
commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/tar/TarArchiveInputStream.java
URL: 
http://svn.apache.org/viewvc/commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/tar/TarArchiveInputStream.java?rev=1211393r1=1211392r2=1211393view=diff
==
--- 
commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/tar/TarArchiveInputStream.java
 (original)
+++ 
commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/tar/TarArchiveInputStream.java
 Wed Dec  7 11:34:34 2011
@@ -229,6 +229,11 @@ public class TarArchiveInputStream exten
 readGNUSparse();
 }
 
+// If the size of the next element in the archive has changed
+// due to a new size being reported in the posix header
+// information, we update entrySize here so that it contains
+// the correct value.
+entrySize = currEntry.getSize();
 return currEntry;
 }
 
@@ -341,7 +346,7 @@ public class TarArchiveInputStream exten
 } else if (uname.equals(key)){
 currEntry.setUserName(val);
 } else if (size.equals(key)){
-currEntry.setSize(Long.parseLong(val));
+currEntry.adjustSize(Long.parseLong(val));
 }
 }
 }

Modified: 
commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/archivers/tar/TarArchiveEntryTest.java
URL: 
http://svn.apache.org/viewvc/commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/archivers/tar/TarArchiveEntryTest.java?rev=1211393r1=1211392r2=1211393view=diff
==
--- 
commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/archivers/tar/TarArchiveEntryTest.java
 (original)
+++ 
commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/archivers/tar/TarArchiveEntryTest.java
 Wed Dec  7 11:34:34 2011
@@ -115,4 +115,17 @@ public class TarArchiveEntryTest extends
 } catch (IllegalArgumentException expected) {
 }
 }
+
+public void testAdjustFileSize(){
+TarArchiveEntry t = new TarArchiveEntry();
+t.adjustSize(0);
+t.adjustSize(1);
+try {
+t.adjustSize(-1);
+fail(Should have generated IllegalArgumentException);
+} catch (IllegalArgumentException expected) {
+}
+t.adjustSize(0777L);
+t.adjustSize(01000L);
+}
 }




svn commit: r1211405 - in /commons/proper/compress/trunk/src: changes/changes.xml test/java/org/apache/commons/compress/archivers/tar/BigFilesIT.java test/resources/8.posix.tar.gz test/resources/8.sta

2011-12-07 Thread bodewig
Author: bodewig
Date: Wed Dec  7 12:14:59 2011
New Revision: 1211405

URL: http://svn.apache.org/viewvc?rev=1211405view=rev
Log:
test that proves PAX archives with big entries are read correctly.  COMPRESS-16

Added:
commons/proper/compress/trunk/src/test/resources/8.posix.tar.gz   (with 
props)
commons/proper/compress/trunk/src/test/resources/8.star.tar.gz
  - copied unchanged from r1211389, 
commons/proper/compress/trunk/src/test/resources/8.tar.gz
Removed:
commons/proper/compress/trunk/src/test/resources/8.tar.gz
Modified:
commons/proper/compress/trunk/src/changes/changes.xml

commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/archivers/tar/BigFilesIT.java

Modified: commons/proper/compress/trunk/src/changes/changes.xml
URL: 
http://svn.apache.org/viewvc/commons/proper/compress/trunk/src/changes/changes.xml?rev=1211405r1=1211404r2=1211405view=diff
==
--- commons/proper/compress/trunk/src/changes/changes.xml (original)
+++ commons/proper/compress/trunk/src/changes/changes.xml Wed Dec  7 12:14:59 
2011
@@ -57,14 +57,15 @@ The action type attribute can be add,u
 GZipCompressorInputStream now optionally supports reading of
 concatenated .gz files.
   /action
-  action issue=COMPRESS-16 type=update date=2011-12-05
-The tar package can now read archives that use GNU extensions
-for files that are longer than 8 GByte.
-  /action
   action issue=COMPRESS-164 type=fix date=2011-12-05
 ZipFile didn't work properly for archives using unicode extra
 fields rather than UTF-8 filenames and the EFS-Flag.
   /action
+  action issue=COMPRESS-16 type=update date=2011-12-07
+The tar package can now read archives that use star/GNU/BSD
+extensions for files that are longer than 8 GByte as well as
+archives that use the POSIX/PAX variant.
+  /action
 /release
 release version=1.3 date=2011-11-01
  description=Release 1.3 - API compatible to 1.2 but requires 
Java5 at runtime

Modified: 
commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/archivers/tar/BigFilesIT.java
URL: 
http://svn.apache.org/viewvc/commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/archivers/tar/BigFilesIT.java?rev=1211405r1=1211404r2=1211405view=diff
==
--- 
commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/archivers/tar/BigFilesIT.java
 (original)
+++ 
commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/archivers/tar/BigFilesIT.java
 Wed Dec  7 12:14:59 2011
@@ -30,13 +30,22 @@ import org.apache.commons.compress.compr
 public class BigFilesIT {
 
 @Test
-public void readFileBiggerThan8GByte() throws Exception {
+public void readFileBiggerThan8GByteStar() throws Exception {
+readFileBiggerThan8GByte(/8.star.tar.gz);
+}
+
+@Test
+public void readFileBiggerThan8GBytePosix() throws Exception {
+readFileBiggerThan8GByte(/8.posix.tar.gz);
+}
+
+private void readFileBiggerThan8GByte(String name) throws Exception {
 GzipCompressorInputStream in = null;
 TarArchiveInputStream tin = null;
 try {
 in =
 new GzipCompressorInputStream(BigFilesIT.class
-  
.getResourceAsStream(/8.tar.gz));
+  .getResourceAsStream(name));
 tin = new TarArchiveInputStream(in);
 TarArchiveEntry e = tin.getNextTarEntry();
 assertNotNull(e);

Added: commons/proper/compress/trunk/src/test/resources/8.posix.tar.gz
URL: 
http://svn.apache.org/viewvc/commons/proper/compress/trunk/src/test/resources/8.posix.tar.gz?rev=1211405view=auto
==
Binary file - no diff available.

Propchange: commons/proper/compress/trunk/src/test/resources/8.posix.tar.gz
--
svn:mime-type = application/octet-stream




svn commit: r1211465 - in /commons/proper/compress/trunk/src: main/java/org/apache/commons/compress/archivers/tar/TarArchiveInputStream.java test/java/org/apache/commons/compress/archivers/tar/TarArch

2011-12-07 Thread bodewig
Author: bodewig
Date: Wed Dec  7 15:01:27 2011
New Revision: 1211465

URL: http://svn.apache.org/viewvc?rev=1211465view=rev
Log:
prove parsing of PAX headers works correctly.  COMPRESS-167

Added:

commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/archivers/tar/TarArchiveInputStreamTest.java
   (with props)
Modified:

commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/tar/TarArchiveInputStream.java

Modified: 
commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/tar/TarArchiveInputStream.java
URL: 
http://svn.apache.org/viewvc/commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/tar/TarArchiveInputStream.java?rev=1211465r1=1211464r2=1211465view=diff
==
--- 
commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/tar/TarArchiveInputStream.java
 (original)
+++ 
commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/tar/TarArchiveInputStream.java
 Wed Dec  7 15:01:27 2011
@@ -272,9 +272,21 @@ public class TarArchiveInputStream exten
 // make sure GC doesn't close this before we are done
 }
 };
+MapString, String headers = null;
+try {
+headers = parsePaxHeaders(br);
+} finally {
+// NO-OP but makes FindBugs happy
+br.close();
+}
+
+getNextEntry(); // Get the actual file entry
+applyPaxHeadersToCurrentEntry(headers);
+}
+
+MapString, String parsePaxHeaders(Reader br) throws IOException {
 MapString, String headers = new HashMapString, String();
 // Format is length keyword=value\n;
-try {
 while(true){ // get length
 int ch;
 int len = 0;
@@ -315,12 +327,10 @@ public class TarArchiveInputStream exten
 break;
 }
 }
-} finally {
-// NO-OP but makes FindBugs happy
-br.close();
-}
+return headers;
+}
 
-getNextEntry(); // Get the actual file entry
+private void applyPaxHeadersToCurrentEntry(MapString, String headers) {
 /*
  * The following headers are defined for Pax.
  * atime, ctime, mtime, charset: cannot use these without changing 
TarArchiveEntry fields

Added: 
commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/archivers/tar/TarArchiveInputStreamTest.java
URL: 
http://svn.apache.org/viewvc/commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/archivers/tar/TarArchiveInputStreamTest.java?rev=1211465view=auto
==
--- 
commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/archivers/tar/TarArchiveInputStreamTest.java
 (added)
+++ 
commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/archivers/tar/TarArchiveInputStreamTest.java
 Wed Dec  7 15:01:27 2011
@@ -0,0 +1,43 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one or more
+ *  contributor license agreements.  See the NOTICE file distributed with
+ *  this work for additional information regarding copyright ownership.
+ *  The ASF licenses this file to You under the Apache License, Version 2.0
+ *  (the License); you may not use this file except in compliance with
+ *  the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an AS IS BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ *
+ */
+
+package org.apache.commons.compress.archivers.tar;
+
+import java.io.StringReader;
+import java.util.Map;
+import org.junit.Test;
+import static org.junit.Assert.assertEquals;
+
+public class TarArchiveInputStreamTest {
+
+@Test
+public void readSimplePaxHeader() throws Exception {
+MapString, String headers = new TarArchiveInputStream(null)
+.parsePaxHeaders(new StringReader(30 
atime=1321711775.972059463\n));
+assertEquals(1, headers.size());
+assertEquals(1321711775.972059463, headers.get(atime));
+}
+
+@Test
+public void readPaxHeaderWithEmbeddedNewline() throws Exception {
+MapString, String headers = new TarArchiveInputStream(null)
+.parsePaxHeaders(new StringReader(28 
comment=line1\nline2\nand3\n));
+assertEquals(1, headers.size());
+assertEquals(line1\nline2\nand3, headers.get(comment));
+}
+}
\ No newline at end of file

Propchange: 
commons/proper/compress/trunk/src/test/java/org/apache/commons

svn commit: r1211466 - /commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/tar/TarArchiveInputStream.java

2011-12-07 Thread bodewig
Author: bodewig
Date: Wed Dec  7 15:02:45 2011
New Revision: 1211466

URL: http://svn.apache.org/viewvc?rev=1211466view=rev
Log:
whitespace

Modified:

commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/tar/TarArchiveInputStream.java

Modified: 
commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/tar/TarArchiveInputStream.java
URL: 
http://svn.apache.org/viewvc/commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/tar/TarArchiveInputStream.java?rev=1211466r1=1211465r2=1211466view=diff
==
--- 
commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/tar/TarArchiveInputStream.java
 (original)
+++ 
commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/tar/TarArchiveInputStream.java
 Wed Dec  7 15:02:45 2011
@@ -287,46 +287,46 @@ public class TarArchiveInputStream exten
 MapString, String parsePaxHeaders(Reader br) throws IOException {
 MapString, String headers = new HashMapString, String();
 // Format is length keyword=value\n;
-while(true){ // get length
-int ch;
-int len = 0;
-int read = 0;
-while((ch = br.read()) != -1){
-read++;
-if (ch == ' '){ // End of length string
-// Get keyword
-StringBuffer sb = new StringBuffer();
-while((ch = br.read()) != -1){
-read++;
-if (ch == '='){ // end of keyword
-String keyword = sb.toString();
-// Get rest of entry
-char[] cbuf = new char[len-read];
-int got = br.read(cbuf);
-if (got != len - read){
-throw new IOException(Failed to read 
-  + Paxheader. 
Expected 
-  + (len - read)
-  +  chars, read 
-  + got);
-}
-// Drop trailing NL
-String value = new String(cbuf, 0,
-  len - read - 1);
-headers.put(keyword, value);
-break;
+while(true){ // get length
+int ch;
+int len = 0;
+int read = 0;
+while((ch = br.read()) != -1){
+read++;
+if (ch == ' '){ // End of length string
+// Get keyword
+StringBuffer sb = new StringBuffer();
+while((ch = br.read()) != -1){
+read++;
+if (ch == '='){ // end of keyword
+String keyword = sb.toString();
+// Get rest of entry
+char[] cbuf = new char[len-read];
+int got = br.read(cbuf);
+if (got != len - read){
+throw new IOException(Failed to read 
+  + Paxheader. Expected 
+  + (len - read)
+  +  chars, read 
+  + got);
 }
-sb.append((char) ch);
+// Drop trailing NL
+String value = new String(cbuf, 0,
+  len - read - 1);
+headers.put(keyword, value);
+break;
 }
-break; // Processed single header
+sb.append((char) ch);
 }
-len *= 10;
-len += ch - '0';
-}
-if (ch == -1){ // EOF
-break;
+break; // Processed single header
 }
+len *= 10;
+len += ch - '0';
 }
+if (ch == -1){ // EOF
+break;
+}
+}
 return headers;
 }
 




svn commit: r1211892 - in /commons/proper/compress/trunk/src: main/java/org/apache/commons/compress/archivers/tar/ test/java/org/apache/commons/compress/archivers/tar/

2011-12-08 Thread bodewig
Author: bodewig
Date: Thu Dec  8 14:03:57 2011
New Revision: 1211892

URL: http://svn.apache.org/viewvc?rev=1211892view=rev
Log:
support writing big files using star extensions.  COMPRESS-165.  Patch by John 
Kodis.

Modified:

commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/tar/TarArchiveEntry.java

commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/tar/TarArchiveInputStream.java

commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/tar/TarArchiveOutputStream.java

commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/tar/TarUtils.java

commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/archivers/tar/TarArchiveEntryTest.java

commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/archivers/tar/TarArchiveOutputStreamTest.java

Modified: 
commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/tar/TarArchiveEntry.java
URL: 
http://svn.apache.org/viewvc/commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/tar/TarArchiveEntry.java?rev=1211892r1=1211891r2=1211892view=diff
==
--- 
commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/tar/TarArchiveEntry.java
 (original)
+++ 
commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/tar/TarArchiveEntry.java
 Thu Dec  8 14:03:57 2011
@@ -561,26 +561,11 @@ public class TarArchiveEntry implements 
  * Set this entry's file size.
  *
  * @param size This entry's new file size.
- * @throws IllegalArgumentException if the size is  0
- * or  {@link TarConstants#MAXSIZE} (0777L).
+ * @throws IllegalArgumentException if the size is lt; 0.
  */
 public void setSize(long size) {
-if (size  MAXSIZE || size  0){
-throw new IllegalArgumentException(Size is out of range: +size);
-}
-this.size = size;
-}
-
-/**
- * Set this entry's file size.
- *
- * pInvoked by input stream when reading a PAX header./p
- * @throws IllegalArgumentException if the size is lt; 0
- * @since Apache Commons Compress 1.4
- */
-void adjustSize(long size) {
 if (size  0){
-throw new IllegalArgumentException(Size is out of range:  + 
size);
+throw new IllegalArgumentException(Size is out of range: +size);
 }
 this.size = size;
 }
@@ -751,16 +736,35 @@ public class TarArchiveEntry implements 
 /**
  * Write an entry's header information to a header buffer.
  *
+ * pThis method does not use the star/GNU tar/BSD tar extensions./p
+ *
  * @param outbuf The tar entry header buffer to fill in.
  */
 public void writeEntryHeader(byte[] outbuf) {
+writeEntryHeader(outbuf, false);
+}
+
+/**
+ * Write an entry's header information to a header buffer.
+ *
+ * @param outbuf The tar entry header buffer to fill in.
+ * @param starMode whether to use the star/GNU tar/BSD tar
+ * extension for the size field if the size is bigger than 8GiB
+ * @since Apache Commons Compress 1.4
+ */
+public void writeEntryHeader(byte[] outbuf, boolean starMode) {
 int offset = 0;
 
 offset = TarUtils.formatNameBytes(name, outbuf, offset, NAMELEN);
 offset = TarUtils.formatOctalBytes(mode, outbuf, offset, MODELEN);
 offset = TarUtils.formatOctalBytes(userId, outbuf, offset, UIDLEN);
 offset = TarUtils.formatOctalBytes(groupId, outbuf, offset, GIDLEN);
-offset = TarUtils.formatLongOctalBytes(size, outbuf, offset, SIZELEN);
+if (size  TarConstants.MAXSIZE  !starMode) {
+// size is in PAX header
+offset = TarUtils.formatLongOctalBytes(0, outbuf, offset, SIZELEN);
+} else {
+offset = TarUtils.formatLongOctalOrBinaryBytes(size, outbuf, 
offset, SIZELEN);
+}
 offset = TarUtils.formatLongOctalBytes(modTime, outbuf, offset, 
MODTIMELEN);
 
 int csOffset = offset;

Modified: 
commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/tar/TarArchiveInputStream.java
URL: 
http://svn.apache.org/viewvc/commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/tar/TarArchiveInputStream.java?rev=1211892r1=1211891r2=1211892view=diff
==
--- 
commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/tar/TarArchiveInputStream.java
 (original)
+++ 
commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/tar/TarArchiveInputStream.java
 Thu Dec  8 14:03:57 2011
@@ -356,7 +356,7 @@ public class TarArchiveInputStream exten
 } else if (uname.equals(key

svn commit: r1211931 - in /commons/proper/compress/trunk/src: main/java/org/apache/commons/compress/archivers/tar/TarArchiveOutputStream.java test/java/org/apache/commons/compress/archivers/tar/TarArc

2011-12-08 Thread bodewig
Author: bodewig
Date: Thu Dec  8 15:22:16 2011
New Revision: 1211931

URL: http://svn.apache.org/viewvc?rev=1211931view=rev
Log:
Write big files in PAX/POSIX mode.  COMPRESS-165

Modified:

commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/tar/TarArchiveOutputStream.java

commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/archivers/tar/TarArchiveOutputStreamTest.java

Modified: 
commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/tar/TarArchiveOutputStream.java
URL: 
http://svn.apache.org/viewvc/commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/tar/TarArchiveOutputStream.java?rev=1211931r1=1211930r2=1211931view=diff
==
--- 
commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/tar/TarArchiveOutputStream.java
 (original)
+++ 
commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/tar/TarArchiveOutputStream.java
 Thu Dec  8 15:22:16 2011
@@ -21,6 +21,9 @@ package org.apache.commons.compress.arch
 import java.io.File;
 import java.io.IOException;
 import java.io.OutputStream;
+import java.io.StringWriter;
+import java.util.HashMap;
+import java.util.Map;
 import org.apache.commons.compress.archivers.ArchiveEntry;
 import org.apache.commons.compress.archivers.ArchiveOutputStream;
 import org.apache.commons.compress.utils.ArchiveUtils;
@@ -207,6 +210,7 @@ public class TarArchiveOutputStream exte
 throw new IOException(Stream has already been finished);
 }
 TarArchiveEntry entry = (TarArchiveEntry) archiveEntry;
+MapString, String paxHeaders = new HashMapString, String();
 if (entry.getName().length() = TarConstants.NAMELEN) {
 
 if (longFileMode == LONGFILE_GNU) {
@@ -227,14 +231,21 @@ public class TarArchiveOutputStream exte
+ TarConstants.NAMELEN +  bytes));
 }
 }
+
 if (entry.getSize()  TarConstants.MAXSIZE) {
-if (bigFileMode != BIGFILE_STAR) {
+if (bigFileMode == BIGFILE_POSIX) {
+paxHeaders.put(size, String.valueOf(entry.getSize()));
+} else if (bigFileMode != BIGFILE_STAR) {
 throw new RuntimeException(file size ' + entry.getSize()
+ ' is too big (  
+ TarConstants.MAXSIZE +  bytes));
 }
 }
 
+if (paxHeaders.size()  0) {
+writePaxHeaders(entry.getName(), paxHeaders);
+}
+
 entry.writeEntryHeader(recordBuf, bigFileMode == BIGFILE_STAR);
 buffer.writeRecord(recordBuf);
 
@@ -368,6 +379,47 @@ public class TarArchiveOutputStream exte
 }
 
 /**
+ * Writes a PAX extended header with the given map as contents.
+ * @since Apache Commons Compress 1.4
+ */
+void writePaxHeaders(String entryName,
+ MapString, String headers) throws IOException {
+String name = ./PaxHeaders.X/ + entryName;
+if (name.length()  TarConstants.NAMELEN) {
+name = name.substring(0, TarConstants.NAMELEN);
+}
+TarArchiveEntry pex = new TarArchiveEntry(name,
+  
TarConstants.LF_PAX_EXTENDED_HEADER_LC);
+
+StringWriter w = new StringWriter();
+for (Map.EntryString, String h : headers.entrySet()) {
+String key = h.getKey();
+String value = h.getValue();
+int len = key.length() + value.length()
++ 3 /* blank, equals and newline */
++ 2 /* guess 9  actual length  100 */;
+String line = len +   + key + = + value + \n;
+int actualLength = line.getBytes(UTF-8).length;
+while (len != actualLength) {
+// Adjust for cases where length  10 or  100
+// or where UTF-8 encoding isn't a single octet
+// per character.
+// Must be in loop as size may go from 99 to 100 in
+// first pass so we'd need a second.
+len = actualLength;
+line = len +   + key + = + value + \n;
+actualLength = line.getBytes(UTF-8).length;
+}
+w.write(line);
+}
+byte[] data = w.toString().getBytes(UTF-8);
+pex.setSize(data.length);
+putArchiveEntry(pex);
+write(data);
+closeArchiveEntry();
+}
+
+/**
  * Write an EOF (end of archive) record to the tar archive.
  * An EOF record consists of a record of all zeros.
  */

Modified: 
commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/archivers/tar/TarArchiveOutputStreamTest.java
URL: 
http://svn.apache.org/viewvc/commons/proper/compress/trunk/src/test/java

svn commit: r1211943 - in /commons/proper/compress/trunk/src: main/java/org/apache/commons/compress/archivers/tar/TarArchiveOutputStream.java test/java/org/apache/commons/compress/archivers/tar/TarArc

2011-12-08 Thread bodewig
Author: bodewig
Date: Thu Dec  8 16:12:52 2011
New Revision: 1211943

URL: http://svn.apache.org/viewvc?rev=1211943view=rev
Log:
Support the POSIX way of writing tar entries with names longer than 100 chars.  
COMPRESS-166

Modified:

commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/tar/TarArchiveOutputStream.java

commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/archivers/tar/TarArchiveOutputStreamTest.java

Modified: 
commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/tar/TarArchiveOutputStream.java
URL: 
http://svn.apache.org/viewvc/commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/tar/TarArchiveOutputStream.java?rev=1211943r1=1211942r2=1211943view=diff
==
--- 
commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/tar/TarArchiveOutputStream.java
 (original)
+++ 
commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/tar/TarArchiveOutputStream.java
 Thu Dec  8 16:12:52 2011
@@ -45,6 +45,9 @@ public class TarArchiveOutputStream exte
 /** GNU tar extensions are used to store long file names in the archive. */
 public static final int LONGFILE_GNU = 2;
 
+/** POSIX/PAX extensions are used to store long file names in the archive. 
*/
+public static final int LONGFILE_POSIX = 3;
+
 /** Fail if a big file (gt; 8GiB) is required in the archive. */
 public static final int BIGFILE_ERROR = 0;
 
@@ -213,7 +216,9 @@ public class TarArchiveOutputStream exte
 MapString, String paxHeaders = new HashMapString, String();
 if (entry.getName().length() = TarConstants.NAMELEN) {
 
-if (longFileMode == LONGFILE_GNU) {
+if (longFileMode == LONGFILE_POSIX) {
+paxHeaders.put(path, entry.getName());
+} else if (longFileMode == LONGFILE_GNU) {
 // create a TarEntry for the LongLink, the contents
 // of which are the entry's name
 TarArchiveEntry longLinkEntry = new 
TarArchiveEntry(TarConstants.GNU_LONGLINK,
@@ -385,8 +390,8 @@ public class TarArchiveOutputStream exte
 void writePaxHeaders(String entryName,
  MapString, String headers) throws IOException {
 String name = ./PaxHeaders.X/ + entryName;
-if (name.length()  TarConstants.NAMELEN) {
-name = name.substring(0, TarConstants.NAMELEN);
+if (name.length() = TarConstants.NAMELEN) {
+name = name.substring(0, TarConstants.NAMELEN - 1);
 }
 TarArchiveEntry pex = new TarArchiveEntry(name,
   
TarConstants.LF_PAX_EXTENDED_HEADER_LC);

Modified: 
commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/archivers/tar/TarArchiveOutputStreamTest.java
URL: 
http://svn.apache.org/viewvc/commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/archivers/tar/TarArchiveOutputStreamTest.java?rev=1211943r1=1211942r2=1211943view=diff
==
--- 
commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/archivers/tar/TarArchiveOutputStreamTest.java
 (original)
+++ 
commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/archivers/tar/TarArchiveOutputStreamTest.java
 Thu Dec  8 16:12:52 2011
@@ -182,4 +182,26 @@ public class TarArchiveOutputStreamTest 
 
 return bos.toByteArray();
 }
+
+public void testWriteLongFileNamePosixMode() throws Exception {
+String n = 01234567890123456789012345678901234567890123456789
++ 01234567890123456789012345678901234567890123456789
++ 01234567890123456789012345678901234567890123456789;
+TarArchiveEntry t =
+new TarArchiveEntry(n);
+t.setSize(10 * 1024);
+ByteArrayOutputStream bos = new ByteArrayOutputStream();
+TarArchiveOutputStream tos = new TarArchiveOutputStream(bos);
+tos.setLongFileMode(TarArchiveOutputStream.LONGFILE_POSIX);
+tos.putArchiveEntry(t);
+tos.write(new byte[10 * 1024]);
+tos.closeArchiveEntry();
+byte[] data = bos.toByteArray();
+assertEquals(160 path= + n + \n,
+ new String(data, 512, 160, UTF-8));
+TarArchiveInputStream tin =
+new TarArchiveInputStream(new ByteArrayInputStream(data));
+TarArchiveEntry e = tin.getNextTarEntry();
+assertEquals(n, e.getName());
+}
 }
\ No newline at end of file




svn commit: r1211969 - in /commons/proper/compress/trunk/src: changes/changes.xml site/xdoc/examples.xml site/xdoc/tar.xml

2011-12-08 Thread bodewig
Author: bodewig
Date: Thu Dec  8 16:43:50 2011
New Revision: 1211969

URL: http://svn.apache.org/viewvc?rev=1211969view=rev
Log:
documenation for big file support and PAX support fro writing long file names 
in tar.  COMPRESS-165 and COMPRESS-166

Added:
commons/proper/compress/trunk/src/site/xdoc/tar.xml   (with props)
Modified:
commons/proper/compress/trunk/src/changes/changes.xml
commons/proper/compress/trunk/src/site/xdoc/examples.xml

Modified: commons/proper/compress/trunk/src/changes/changes.xml
URL: 
http://svn.apache.org/viewvc/commons/proper/compress/trunk/src/changes/changes.xml?rev=1211969r1=1211968r2=1211969view=diff
==
--- commons/proper/compress/trunk/src/changes/changes.xml (original)
+++ commons/proper/compress/trunk/src/changes/changes.xml Thu Dec  8 16:43:50 
2011
@@ -66,6 +66,15 @@ The action type attribute can be add,u
 extensions for files that are longer than 8 GByte as well as
 archives that use the POSIX/PAX variant.
   /action
+  action issue=COMPRESS-165 type=update date=2011-12-08
+The tar package can now write archives that use star/GNU/BSD
+extensions for files that are longer than 8 GByte as well as
+archives that use the POSIX/PAX variant.
+  /action
+  action issue=COMPRESS-166 type=update date=2011-12-08
+The tar package can now use the POSIX/PAX variant for writing
+entries with names longer than 100 characters.
+  /action
 /release
 release version=1.3 date=2011-11-01
  description=Release 1.3 - API compatible to 1.2 but requires 
Java5 at runtime

Modified: commons/proper/compress/trunk/src/site/xdoc/examples.xml
URL: 
http://svn.apache.org/viewvc/commons/proper/compress/trunk/src/site/xdoc/examples.xml?rev=1211969r1=1211968r2=1211969view=diff
==
--- commons/proper/compress/trunk/src/site/xdoc/examples.xml (original)
+++ commons/proper/compress/trunk/src/site/xdoc/examples.xml Thu Dec  8 
16:43:50 2011
@@ -174,39 +174,8 @@ LOOP UNTIL entry.getSize() HAS BEEN READ
 
   subsection name=tar
 
-pIn addition to the information stored
-  in codeArchiveEntry/code a codeTarArchiveEntry/code
-  stores various attributes including information about the
-  original owner and permissions./p
-
-pThere are several different tar formats and the TAR package
-  of Compress 1.0 only provides the common functionality of
-  the existing variants./p
-pThe original format (often called ustar) didn't support
-  file names longer than 100 characters and the tar package
-  will fail if you try to add an entry longer than that.
-  The codelongFileMode/code option
-  of codeTarArchiveOutputStream/code can be used to make
-  the archive truncate such names or use a GNU tar variant now
-  refered to as oldgnu of storing such names.  If you choose
-  the GNU tar option, the archive can not be extracted using
-  many other tar implementations like the ones of OpenBSD,
-  Solaris or MacOS X./p
-pThe tar package does not support the full POSIX tar
-  standard nor more modern GNU extension of said standard.  It
-  cannot deal with entries larger than 2 GByte either./p
-
-pcodeTarArchiveInputStream/code will recognize the GNU
-  tar extension for long file names and read the longer names
-  accordingly./p
-
-pcodeTarArchiveInputStream/code will recognize sparse
-  file entries stored using the oldgnu format
-  (code-#x2d;sparse-version=0.0/code in GNU tar) but is
-  not able to extract them correctly.
-  a href=#Unsupported FeaturescodecanReadEntryData/code/a
-  will return false on such entries.  The other variants of
-  sparse files can currently not be detected at all./p
+pThe TAR package has a a href=tar.htmldedicated
+documentation page/a./p
 
 pAdding an entry to a tar archive:/p
 source![CDATA[

Added: commons/proper/compress/trunk/src/site/xdoc/tar.xml
URL: 
http://svn.apache.org/viewvc/commons/proper/compress/trunk/src/site/xdoc/tar.xml?rev=1211969view=auto
==
--- commons/proper/compress/trunk/src/site/xdoc/tar.xml (added)
+++ commons/proper/compress/trunk/src/site/xdoc/tar.xml Thu Dec  8 16:43:50 2011
@@ -0,0 +1,113 @@
+?xml version=1.0?
+!--
+
+   Licensed to the Apache Software Foundation (ASF) under one or more
+   contributor license agreements.  See the NOTICE file distributed with
+   this work for additional information regarding copyright ownership.
+   The ASF licenses this file to You under the Apache License, Version 2.0
+   (the License); you may not use this file except in compliance

svn commit: r1222360 - in /commons/proper/compress/trunk/src: changes/changes.xml main/java/org/apache/commons/compress/archivers/zip/ZipFile.java

2011-12-22 Thread bodewig
Author: bodewig
Date: Thu Dec 22 17:22:19 2011
New Revision: 1222360

URL: http://svn.apache.org/viewvc?rev=1222360view=rev
Log:
throw an IOException rather than a RuntimeException for a certain type of 
corrupted ZIPs.  COMPRESS-169

Modified:
commons/proper/compress/trunk/src/changes/changes.xml

commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/zip/ZipFile.java

Modified: commons/proper/compress/trunk/src/changes/changes.xml
URL: 
http://svn.apache.org/viewvc/commons/proper/compress/trunk/src/changes/changes.xml?rev=1222360r1=1222359r2=1222360view=diff
==
--- commons/proper/compress/trunk/src/changes/changes.xml (original)
+++ commons/proper/compress/trunk/src/changes/changes.xml Thu Dec 22 17:22:19 
2011
@@ -75,6 +75,11 @@ The action type attribute can be add,u
 The tar package can now use the POSIX/PAX variant for writing
 entries with names longer than 100 characters.
   /action
+  action issue=COMPRESS-169 type=fix date=2011-12-22
+For corrupt archives ZipFile would throw a RuntimeException in
+some cases and an IOException in others.  It will now
+consistently throw an IOException.
+  /action
 /release
 release version=1.3 date=2011-11-01
  description=Release 1.3 - API compatible to 1.2 but requires 
Java5 at runtime

Modified: 
commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/zip/ZipFile.java
URL: 
http://svn.apache.org/viewvc/commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/zip/ZipFile.java?rev=1222360r1=1222359r2=1222360view=diff
==
--- 
commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/zip/ZipFile.java
 (original)
+++ 
commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/zip/ZipFile.java
 Thu Dec 22 17:22:19 2011
@@ -821,8 +821,8 @@ public class ZipFile {
 while (lenToSkip  0) {
 int skipped = archive.skipBytes(lenToSkip);
 if (skipped = 0) {
-throw new RuntimeException(failed to skip file name in
-   +  local file header);
+throw new IOException(failed to skip file name in
+  +  local file header);
 }
 lenToSkip -= skipped;
 }




svn commit: r1465272 - /commons/cms-site/trunk/content/xdoc/releases/prepare.xml

2013-04-06 Thread bodewig
Author: bodewig
Date: Sat Apr  6 16:49:01 2013
New Revision: 1465272

URL: http://svn.apache.org/r1465272
Log:
gpg plugin may fail when the passphrase has to be specified interactively

Modified:
commons/cms-site/trunk/content/xdoc/releases/prepare.xml

Modified: commons/cms-site/trunk/content/xdoc/releases/prepare.xml
URL: 
http://svn.apache.org/viewvc/commons/cms-site/trunk/content/xdoc/releases/prepare.xml?rev=1465272r1=1465271r2=1465272view=diff
==
--- commons/cms-site/trunk/content/xdoc/releases/prepare.xml (original)
+++ commons/cms-site/trunk/content/xdoc/releases/prepare.xml Sat Apr  6 
16:49:01 2013
@@ -501,6 +501,9 @@
   /p
   pThis will PGP-sign all artifacts and upload them to a new staging 
repository, Nexus itself will create MD5
 and SHA1 checksums for all files that have been uploaded./p
+  pA known problem is that gpg signing may fail if the gpg plugin tries 
to read the passphrase interactively.
+It works if you specify the passphrase when invoking mvn 
(code-Dgpg.passprase=***/code) or run
+codegpg-agent/code before starting mvn./p
   pUnfortunately this uploads more than should be part of the Maven 
repository, in particular the binary and source
 distribution code.tar.gz/code and code.zip/code files are 
there as well.  Before you
 a 
href=http://www.apache.org/dev/publishing-maven-artifacts.html#close-stage;close/a
 the staging




svn commit: r857522 - in /websites/production/commons/content: ./ dormant/ proper/ sandbox/

2013-04-06 Thread bodewig
Author: bodewig
Date: Sat Apr  6 16:49:59 2013
New Revision: 857522

Log:
Publishing svnmucc operation to commons site by bodewig

Added:
websites/production/commons/content/
  - copied from r857521, websites/staging/commons/trunk/content/
websites/production/commons/content/dormant/
  - copied from r857521, websites/production/commons/content/dormant/
websites/production/commons/content/proper/
  - copied from r857521, websites/production/commons/content/proper/
websites/production/commons/content/sandbox/
  - copied from r857521, websites/production/commons/content/sandbox/



svn commit: r1475758 - in /commons/proper/compress/trunk/src: changes/changes.xml main/java/org/apache/commons/compress/archivers/tar/TarArchiveInputStream.java main/java/org/apache/commons/compress/a

2013-04-25 Thread bodewig
Author: bodewig
Date: Thu Apr 25 13:36:09 2013
New Revision: 1475758

URL: http://svn.apache.org/r1475758
Log:
COMPRESS-223 fix NPE in TarBuffer.tryToConsumeSecondEOFRecord - patch by Jeremy 
Gustie

Modified:
commons/proper/compress/trunk/src/changes/changes.xml

commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/tar/TarArchiveInputStream.java

commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/tar/TarBuffer.java

Modified: commons/proper/compress/trunk/src/changes/changes.xml
URL: 
http://svn.apache.org/viewvc/commons/proper/compress/trunk/src/changes/changes.xml?rev=1475758r1=1475757r2=1475758view=diff
==
--- commons/proper/compress/trunk/src/changes/changes.xml (original)
+++ commons/proper/compress/trunk/src/changes/changes.xml Thu Apr 25 13:36:09 
2013
@@ -44,6 +44,11 @@ The action type attribute can be add,u
   body
 release version=1.6 date=not released, yet
  description=Release 1.6
+  action type=fix date=2013-04-25 issue=COMPRESS-223
+  due-to=Jeremy Gustie
+TarBuffer.tryToConsumeSecondEOFRecord could throw a
+NullPointerException
+  /action
 /release
 release version=1.5 date=2013-03-14
  description=Release 1.5

Modified: 
commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/tar/TarArchiveInputStream.java
URL: 
http://svn.apache.org/viewvc/commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/tar/TarArchiveInputStream.java?rev=1475758r1=1475757r2=1475758view=diff
==
--- 
commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/tar/TarArchiveInputStream.java
 (original)
+++ 
commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/tar/TarArchiveInputStream.java
 Thu Apr 25 13:36:09 2013
@@ -311,11 +311,11 @@ public class TarArchiveInputStream exten
 
 byte[] headerBuf = buffer.readRecord();
 
-if (headerBuf == null) {
+if (buffer.isEOFRecord(headerBuf)) {
 hasHitEOF = true;
-} else if (buffer.isEOFRecord(headerBuf)) {
-hasHitEOF = true;
-buffer.tryToConsumeSecondEOFRecord();
+if (headerBuf != null) {
+buffer.tryToConsumeSecondEOFRecord();
+}
 }
 
 return hasHitEOF ? null : headerBuf;

Modified: 
commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/tar/TarBuffer.java
URL: 
http://svn.apache.org/viewvc/commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/tar/TarBuffer.java?rev=1475758r1=1475757r2=1475758view=diff
==
--- 
commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/tar/TarBuffer.java
 (original)
+++ 
commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/tar/TarBuffer.java
 Thu Apr 25 13:36:09 2013
@@ -153,12 +153,13 @@ class TarBuffer { // Not public, because
  * @return true if the record data is an End of Archive
  */
 public boolean isEOFRecord(byte[] record) {
-for (int i = 0, sz = getRecordSize(); i  sz; ++i) {
-if (record[i] != 0) {
-return false;
+if (record != null) {
+for (int i = 0, sz = getRecordSize(); i  sz; ++i) {
+if (record[i] != 0) {
+return false;
+}
 }
 }
-
 return true;
 }
 
@@ -181,7 +182,7 @@ class TarBuffer { // Not public, because
 /**
  * Read a record from the input stream and return the data.
  *
- * @return The record data.
+ * @return The record data or null if EOF has been hit.
  * @throws IOException on error
  */
 public byte[] readRecord() throws IOException {
@@ -407,12 +408,12 @@ class TarBuffer { // Not public, because
 }
 
 /**
- * Tries to read the next record rewinding the stream if if is not a EOF 
record.
+ * Tries to read the next record rewinding the stream if it is not a EOF 
record.
  *
  * pThis is meant to protect against cases where a tar
  * implemenation has written only one EOF record when two are
  * expected.  Actually this won't help since a non-conforming
- * implementation likely won't fill full blocks consisting of - be
+ * implementation likely won't fill full blocks consisting of - by
  * default - ten records either so we probably have already read
  * beyond the archive anyway./p
  */




svn commit: r1475790 - /commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/archivers/ArchiveStreamFactoryTest.java

2013-04-25 Thread bodewig
Author: bodewig
Date: Thu Apr 25 14:18:18 2013
New Revision: 1475790

URL: http://svn.apache.org/r1475790
Log:
properly close stream, submitted by Andreas Krüger

Modified:

commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/archivers/ArchiveStreamFactoryTest.java

Modified: 
commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/archivers/ArchiveStreamFactoryTest.java
URL: 
http://svn.apache.org/viewvc/commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/archivers/ArchiveStreamFactoryTest.java?rev=1475790r1=1475789r2=1475790view=diff
==
--- 
commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/archivers/ArchiveStreamFactoryTest.java
 (original)
+++ 
commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/archivers/ArchiveStreamFactoryTest.java
 Thu Apr 25 14:18:18 2013
@@ -50,34 +50,38 @@ public class ArchiveStreamFactoryTest {
  */
 @Test
 public void aiffFilesAreNoTARs() throws Exception {
-InputStream is = null;
-try {
-is = new BufferedInputStream(new 
FileInputStream(src/test/resources/testAIFF.aif));
-new ArchiveStreamFactory().createArchiveInputStream(is);
-fail(created an input stream for a non-archive);
-} catch (ArchiveException ae) {
-assertTrue(ae.getMessage().startsWith(No Archiver found));
-} finally {
-if (is != null) {
+   FileInputStream fis = new 
FileInputStream(src/test/resources/testAIFF.aif);
+   try {
+InputStream is = new BufferedInputStream(fis);
+try {
+new ArchiveStreamFactory().createArchiveInputStream(is);
+fail(created an input stream for a non-archive);
+} catch (ArchiveException ae) {
+assertTrue(ae.getMessage().startsWith(No Archiver found));
+} finally {
 is.close();
 }
-}
+   } finally {
+fis.close();
+   }
 }
 
 @Test
 public void testCOMPRESS209() throws Exception {
-InputStream is = null;
-try {
-is = new BufferedInputStream(new 
FileInputStream(src/test/resources/testCompress209.doc));
-new ArchiveStreamFactory().createArchiveInputStream(is);
-fail(created an input stream for a non-archive);
-} catch (ArchiveException ae) {
-assertTrue(ae.getMessage().startsWith(No Archiver found));
-} finally {
-if (is != null) {
-is.close();
+   FileInputStream fis = new 
FileInputStream(src/test/resources/testCompress209.doc);
+   try {
+InputStream bis = new BufferedInputStream(fis);
+try {
+new ArchiveStreamFactory().createArchiveInputStream(bis);
+fail(created an input stream for a non-archive);
+} catch (ArchiveException ae) {
+assertTrue(ae.getMessage().startsWith(No Archiver found));
+} finally {
+bis.close();
 }
-}
+   } finally {
+fis.close();
+   }
 }
 
 /**
@@ -87,15 +91,21 @@ public class ArchiveStreamFactoryTest {
  */
 @Test
 public void skipsPK00Prefix() throws Exception {
-InputStream is = null;
-try {
-is = new BufferedInputStream(new 
FileInputStream(src/test/resources/COMPRESS-208.zip));
-ArchiveInputStream ais = new 
ArchiveStreamFactory().createArchiveInputStream(is);
-assertTrue(ais instanceof ZipArchiveInputStream);
-} finally {
-if (is != null) {
-is.close();
+   FileInputStream fis = new 
FileInputStream(src/test/resources/COMPRESS-208.zip);
+   try {
+InputStream bis = new BufferedInputStream(fis);
+try {
+ArchiveInputStream ais = new 
ArchiveStreamFactory().createArchiveInputStream(bis);
+try {
+assertTrue(ais instanceof ZipArchiveInputStream);
+} finally {
+ais.close();
+}
+} finally {
+bis.close();
 }
-}
+   } finally {
+fis.close();
+   }
 }
 }




svn commit: r1475824 - in /commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers: ArchiveOutputStream.java ArchiveStreamFactory.java

2013-04-25 Thread bodewig
Author: bodewig
Date: Thu Apr 25 15:25:04 2013
New Revision: 1475824

URL: http://svn.apache.org/r1475824
Log:
Some Javadoc fixes submitted by Andreas Krüger

Modified:

commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/ArchiveOutputStream.java

commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/ArchiveStreamFactory.java

Modified: 
commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/ArchiveOutputStream.java
URL: 
http://svn.apache.org/viewvc/commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/ArchiveOutputStream.java?rev=1475824r1=1475823r2=1475824view=diff
==
--- 
commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/ArchiveOutputStream.java
 (original)
+++ 
commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/ArchiveOutputStream.java
 Thu Apr 25 15:25:04 2013
@@ -28,18 +28,21 @@ import java.io.OutputStream;
  * They should also override {@link #close()} to ensure that any necessary
  * trailers are added.
  * 
- * p
- * The normal sequence of calls for working with ArchiveOutputStreams is:
- * + create ArchiveOutputStream object
- * + write SFX header (optional, Zip only)
- * + repeat as needed:
- *  - putArchiveEntry() (writes entry header)
- *  - write() (writes entry data)
- *  - closeArchiveEntry() (closes entry)
- * + finish() (ends the addition of entries)
- * + write additional data if format supports it (optional)
- * + close()
- * /p
+ * pThe normal sequence of calls when working with ArchiveOutputStreams 
is:/p
+ * ul
+ *   liCreate ArchiveOutputStream object,/li
+ *   lioptionally write SFX header (Zip only),/li
+ *   lirepeat as needed:
+ * ul
+ *   li{@link #putArchiveEntry(ArchiveEntry)} (writes entry header),
+ *   li{@link #write(byte[])} (writes entry data, as often as needed),
+ *   li{@link #closeArchiveEntry()} (closes entry),
+ * /ul
+ *   /li
+ *   li {@link #finish()} (ends the addition of entries),/li
+ *   li optionally write additional data, provided format supports it,/li
+ *   li{@link #close()}./li
+ * /ul
  * 
  * p
  * Example usage:br/
@@ -77,9 +80,7 @@ public abstract class ArchiveOutputStrea
  * Finishes the addition of entries to this stream, without closing it.
  * Additional data can be written, if the format supports it.
  * 
- * The finish() method throws an Exception if the user forgets to close 
the entry
- * .
- * @throws IOException
+ * @throws IOException if the user forgets to close the entry.
  */
 public abstract void finish() throws IOException;
 
@@ -99,9 +100,9 @@ public abstract class ArchiveOutputStrea
 /**
  * Writes a byte to the current archive entry.
  *
- * This method simply calls write( byte[], 0, 1 ).
+ * pThis method simply calls {@code write( byte[], 0, 1 )}.
  *
- * MUST be overridden if the {@link #write(byte[], int, int)} method
+ * pMUST be overridden if the {@link #write(byte[], int, int)} method
  * is not overridden; may be overridden otherwise.
  * 
  * @param b The byte to be written.
@@ -115,7 +116,7 @@ public abstract class ArchiveOutputStrea
 
 /**
  * Increments the counter of already written bytes.
- * Doesn't increment if the EOF has been hit ({@code written} == -1)
+ * Doesn't increment if EOF has been hit ({@code written == -1}).
  * 
  * @param written the number of bytes written
  */
@@ -125,7 +126,7 @@ public abstract class ArchiveOutputStrea
 
 /**
  * Increments the counter of already written bytes.
- * Doesn't increment if the EOF has been hit ({@code written} == -1)
+ * Doesn't increment if EOF has been hit ({@code written == -1}).
  * 
  * @param written the number of bytes written
  * @since 1.1

Modified: 
commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/ArchiveStreamFactory.java
URL: 
http://svn.apache.org/viewvc/commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/ArchiveStreamFactory.java?rev=1475824r1=1475823r2=1475824view=diff
==
--- 
commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/ArchiveStreamFactory.java
 (original)
+++ 
commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/ArchiveStreamFactory.java
 Thu Apr 25 15:25:04 2013
@@ -36,10 +36,10 @@ import org.apache.commons.compress.archi
 import org.apache.commons.compress.archivers.zip.ZipArchiveOutputStream;
 
 /**
- * pFactory to create Archive[In|Out]putStreams from names or the first 
bytes of
- * the InputStream. In order add other implementations you should extend
+ * Factory to create Archive[In|Out]putStreams from names

svn commit: r1484499 - in /commons/proper/compress/trunk/src: main/java/org/apache/commons/compress/archivers/zip/ZipFile.java test/java/org/apache/commons/compress/archivers/zip/ZipFileTest.java

2013-05-20 Thread bodewig
Author: bodewig
Date: Mon May 20 15:33:57 2013
New Revision: 1484499

URL: http://svn.apache.org/r1484499
Log:
COMPRESS-227 ensure ZipFile#getEntry only returns entries that will
return non-null InputStreams in getInputStream.

nameMap isn't used before all local file headers are parsed so it is
easier to only populate it then.  This not only ensure it only
contains ZipArchiveEntries that are known to the entries map, it also
simplifies the case where an entry's name changes due to extra fields.

Modified:

commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/zip/ZipFile.java

commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/archivers/zip/ZipFileTest.java

Modified: 
commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/zip/ZipFile.java
URL: 
http://svn.apache.org/viewvc/commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/zip/ZipFile.java?rev=1484499r1=1484498r2=1484499view=diff
==
--- 
commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/zip/ZipFile.java
 (original)
+++ 
commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/zip/ZipFile.java
 Mon May 20 15:33:57 2013
@@ -534,8 +534,6 @@ public class ZipFile {
 // data offset will be filled later
 entries.put(ze, offset);
 
-nameMap.put(ze.getName(), ze);
-
 byte[] cdExtraData = new byte[extraLen];
 archive.readFully(cdExtraData);
 ze.setCentralDirectoryExtra(cdExtraData);
@@ -889,12 +887,9 @@ public class ZipFile {
 NameAndComment nc = entriesWithoutUTF8Flag.get(ze);
 ZipUtil.setNameAndCommentFromExtraFields(ze, nc.name,
  nc.comment);
-if (!orig.equals(ze.getName())) {
-nameMap.remove(orig);
-nameMap.put(ze.getName(), ze);
-}
 }
 entries.put(ze, offsetEntry);
+nameMap.put(ze.getName(), ze);
 }
 }
 

Modified: 
commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/archivers/zip/ZipFileTest.java
URL: 
http://svn.apache.org/viewvc/commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/archivers/zip/ZipFileTest.java?rev=1484499r1=1484498r2=1484499view=diff
==
--- 
commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/archivers/zip/ZipFileTest.java
 (original)
+++ 
commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/archivers/zip/ZipFileTest.java
 Mon May 20 15:33:57 2013
@@ -204,6 +204,48 @@ public class ZipFileTest extends TestCas
 }
 }
 
+public void XtestDuplicateEntry() throws Exception {
+File f = File.createTempFile(commons-compress-zipfiletest, .zip);
+f.deleteOnExit();
+File f2 = File.createTempFile(commons-compress-zipfiletest, .txt);
+f2.deleteOnExit();
+
+OutputStream o = null;
+try {
+o = new FileOutputStream(f);
+ZipArchiveOutputStream zo = new ZipArchiveOutputStream(o);
+// simple way to ensure entries have extra data
+zo.setUseZip64(Zip64Mode.Always);
+
+// add the same file twice
+ZipArchiveEntry ze = new ZipArchiveEntry(f2, foo);
+zo.putArchiveEntry(ze);
+zo.write(new byte[0]);
+zo.closeArchiveEntry();
+ze = new ZipArchiveEntry(f2, foo);
+zo.putArchiveEntry(ze);
+zo.write(new byte[0]);
+zo.closeArchiveEntry();
+zo.close();
+
+o.close();
+o = null;
+
+
System.err.println(---vvv---);
+zf = new ZipFile(f);
+ze = zf.getEntry(foo);
+assertNotNull(ze);
+assertNotNull(zf.getInputStream(ze));
+} finally {
+
System.err.println(---^^^---);
+if (o != null) {
+o.close();
+}
+f.delete();
+f2.delete();
+}
+}
+
 /*
  * ordertest.zip has been handcrafted.
  *




svn commit: r1484710 - /commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/archivers/zip/ZipFileTest.java

2013-05-21 Thread bodewig
Author: bodewig
Date: Tue May 21 09:22:04 2013
New Revision: 1484710

URL: http://svn.apache.org/r1484710
Log:
COMPRESS-227 forgot to enable now-passing test

Modified:

commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/archivers/zip/ZipFileTest.java

Modified: 
commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/archivers/zip/ZipFileTest.java
URL: 
http://svn.apache.org/viewvc/commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/archivers/zip/ZipFileTest.java?rev=1484710r1=1484709r2=1484710view=diff
==
--- 
commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/archivers/zip/ZipFileTest.java
 (original)
+++ 
commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/archivers/zip/ZipFileTest.java
 Tue May 21 09:22:04 2013
@@ -204,7 +204,7 @@ public class ZipFileTest extends TestCas
 }
 }
 
-public void XtestDuplicateEntry() throws Exception {
+public void testDuplicateEntry() throws Exception {
 File f = File.createTempFile(commons-compress-zipfiletest, .zip);
 f.deleteOnExit();
 File f2 = File.createTempFile(commons-compress-zipfiletest, .txt);




svn commit: r1486333 - in /commons/proper/compress/trunk/src/test: java/org/apache/commons/compress/archivers/zip/ZipFileTest.java resources/COMPRESS-227.zip

2013-05-25 Thread bodewig
Author: bodewig
Date: Sat May 25 14:52:38 2013
New Revision: 1486333

URL: http://svn.apache.org/r1486333
Log:
Use example archive from COMPRESS-227 in test rather than creating a new one

Added:
commons/proper/compress/trunk/src/test/resources/COMPRESS-227.zip   (with 
props)
Modified:

commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/archivers/zip/ZipFileTest.java

Modified: 
commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/archivers/zip/ZipFileTest.java
URL: 
http://svn.apache.org/viewvc/commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/archivers/zip/ZipFileTest.java?rev=1486333r1=1486332r2=1486333view=diff
==
--- 
commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/archivers/zip/ZipFileTest.java
 (original)
+++ 
commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/archivers/zip/ZipFileTest.java
 Sat May 25 14:52:38 2013
@@ -204,46 +204,16 @@ public class ZipFileTest extends TestCas
 }
 }
 
+/**
+ * @see https://issues.apache.org/jira/browse/COMPRESS-227
+ */
 public void testDuplicateEntry() throws Exception {
-File f = File.createTempFile(commons-compress-zipfiletest, .zip);
-f.deleteOnExit();
-File f2 = File.createTempFile(commons-compress-zipfiletest, .txt);
-f2.deleteOnExit();
-
-OutputStream o = null;
-try {
-o = new FileOutputStream(f);
-ZipArchiveOutputStream zo = new ZipArchiveOutputStream(o);
-// simple way to ensure entries have extra data
-zo.setUseZip64(Zip64Mode.Always);
-
-// add the same file twice
-ZipArchiveEntry ze = new ZipArchiveEntry(f2, foo);
-zo.putArchiveEntry(ze);
-zo.write(new byte[0]);
-zo.closeArchiveEntry();
-ze = new ZipArchiveEntry(f2, foo);
-zo.putArchiveEntry(ze);
-zo.write(new byte[0]);
-zo.closeArchiveEntry();
-zo.close();
-
-o.close();
-o = null;
+File archive = getFile(COMPRESS-227.zip);
+zf = new ZipFile(archive);
 
-
System.err.println(---vvv---);
-zf = new ZipFile(f);
-ze = zf.getEntry(foo);
-assertNotNull(ze);
-assertNotNull(zf.getInputStream(ze));
-} finally {
-
System.err.println(---^^^---);
-if (o != null) {
-o.close();
-}
-f.delete();
-f2.delete();
-}
+ZipArchiveEntry ze = zf.getEntry(test1.txt);
+assertNotNull(ze);
+assertNotNull(zf.getInputStream(ze));
 }
 
 /*

Added: commons/proper/compress/trunk/src/test/resources/COMPRESS-227.zip
URL: 
http://svn.apache.org/viewvc/commons/proper/compress/trunk/src/test/resources/COMPRESS-227.zip?rev=1486333view=auto
==
Binary file - no diff available.

Propchange: commons/proper/compress/trunk/src/test/resources/COMPRESS-227.zip
--
svn:mime-type = application/octet-stream




svn commit: r1486348 - in /commons/proper/compress/trunk/src: main/java/org/apache/commons/compress/archivers/zip/ZipFile.java test/java/org/apache/commons/compress/archivers/zip/ZipFileTest.java

2013-05-25 Thread bodewig
Author: bodewig
Date: Sat May 25 17:47:00 2013
New Revision: 1486348

URL: http://svn.apache.org/r1486348
Log:
provide access to all entries of a given name in ZipFile, COMPRESS-227

Modified:

commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/zip/ZipFile.java

commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/archivers/zip/ZipFileTest.java

Modified: 
commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/zip/ZipFile.java
URL: 
http://svn.apache.org/viewvc/commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/zip/ZipFile.java?rev=1486348r1=1486347r2=1486348view=diff
==
--- 
commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/zip/ZipFile.java
 (original)
+++ 
commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/zip/ZipFile.java
 Sat May 25 17:47:00 2013
@@ -25,9 +25,12 @@ import java.io.RandomAccessFile;
 import java.util.Arrays;
 import java.util.Collections;
 import java.util.Comparator;
+import java.util.Deque;
 import java.util.Enumeration;
 import java.util.HashMap;
-import java.util.LinkedHashMap;
+import java.util.Iterator;
+import java.util.LinkedList;
+import java.util.List;
 import java.util.Map;
 import java.util.zip.Inflater;
 import java.util.zip.InflaterInputStream;
@@ -83,17 +86,17 @@ public class ZipFile {
 private static final int POS_3 = 3;
 
 /**
- * Maps ZipArchiveEntrys to two longs, recording the offsets of
- * the local file headers and the start of entry data.
+ * List of entries in the order they appear inside the central
+ * directory.
  */
-private final MapZipArchiveEntry, OffsetEntry entries =
-new LinkedHashMapZipArchiveEntry, OffsetEntry(HASH_SIZE);
+private final ListZipArchiveEntry entries =
+new LinkedListZipArchiveEntry();
 
 /**
- * Maps String to ZipArchiveEntrys, name - actual entry.
+ * Maps String to list of ZipArchiveEntrys, name - actual entries.
  */
-private final MapString, ZipArchiveEntry nameMap =
-new HashMapString, ZipArchiveEntry(HASH_SIZE);
+private final MapString, DequeZipArchiveEntry nameMap =
+new HashMapString, DequeZipArchiveEntry(HASH_SIZE);
 
 private static final class OffsetEntry {
 private long headerOffset = -1;
@@ -273,7 +276,7 @@ public class ZipFile {
  * @return all entries as {@link ZipArchiveEntry} instances
  */
 public EnumerationZipArchiveEntry getEntries() {
-return Collections.enumeration(entries.keySet());
+return Collections.enumeration(entries);
 }
 
 /**
@@ -287,8 +290,7 @@ public class ZipFile {
  * @since 1.1
  */
 public EnumerationZipArchiveEntry getEntriesInPhysicalOrder() {
-ZipArchiveEntry[] allEntries =
-entries.keySet().toArray(new ZipArchiveEntry[0]);
+ZipArchiveEntry[] allEntries = entries.toArray(new ZipArchiveEntry[0]);
 Arrays.sort(allEntries, OFFSET_COMPARATOR);
 return Collections.enumeration(Arrays.asList(allEntries));
 }
@@ -296,12 +298,51 @@ public class ZipFile {
 /**
  * Returns a named entry - or {@code null} if no entry by
  * that name exists.
+ *
+ * pIf multiple entries with the same name exist the first entry
+ * in the archive's central directory by that name is
+ * returned./p
+ *
  * @param name name of the entry.
  * @return the ZipArchiveEntry corresponding to the given name - or
  * {@code null} if not present.
  */
 public ZipArchiveEntry getEntry(String name) {
-return nameMap.get(name);
+DequeZipArchiveEntry entriesOfThatName = nameMap.get(name);
+return entriesOfThatName != null ? entriesOfThatName.getFirst() : null;
+}
+
+/**
+ * Returns all named entries in the same order they appear within
+ * the archive's central directory.
+ *
+ * @param name name of the entry.
+ * @return the IteratorZipArchiveEntry corresponding to the
+ * given name
+ * @since 1.6
+ */
+public IteratorZipArchiveEntry getEntries(String name) {
+DequeZipArchiveEntry entriesOfThatName = nameMap.get(name);
+return entriesOfThatName != null ? entriesOfThatName.iterator()
+: Collections.ZipArchiveEntryemptyList().iterator();
+}
+
+/**
+ * Returns all named entries in the same order their contents
+ * appear within the archive.
+ *
+ * @param name name of the entry.
+ * @return the IteratorZipArchiveEntry corresponding to the
+ * given name
+ * @since 1.6
+ */
+public IteratorZipArchiveEntry getEntriesInPhysicalOrder(String name) {
+ZipArchiveEntry[] entriesOfThatName = new ZipArchiveEntry[0];
+if (nameMap.containsKey(name)) {
+entriesOfThatName = nameMap.get(name

svn commit: r1486436 - /commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/archivers/zip/ZipFileTest.java

2013-05-26 Thread bodewig
Author: bodewig
Date: Sun May 26 17:28:17 2013
New Revision: 1486436

URL: http://svn.apache.org/r1486436
Log:
COMPRESS-227 make test more complete

Modified:

commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/archivers/zip/ZipFileTest.java

Modified: 
commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/archivers/zip/ZipFileTest.java
URL: 
http://svn.apache.org/viewvc/commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/archivers/zip/ZipFileTest.java?rev=1486436r1=1486435r2=1486436view=diff
==
--- 
commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/archivers/zip/ZipFileTest.java
 (original)
+++ 
commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/archivers/zip/ZipFileTest.java
 Sun May 26 17:28:17 2013
@@ -217,8 +217,11 @@ public class ZipFileTest extends TestCas
 assertNotNull(zf.getInputStream(ze));
 
 int numberOfEntries = 0;
-for (Iterator it = zf.getEntries(test1.txt); it.hasNext(); 
it.next()) {
+for (IteratorZipArchiveEntry it = zf.getEntries(test1.txt);
+ it.hasNext(); ) {
 numberOfEntries++;
+ze = it.next();
+assertNotNull(zf.getInputStream(ze));
 }
 assertEquals(2, numberOfEntries);
 }




svn commit: r1486437 - in /commons/proper/compress/trunk/src: changes/ main/java/org/apache/commons/compress/archivers/zip/ test/java/org/apache/commons/compress/archivers/zip/ test/resources/

2013-05-26 Thread bodewig
Author: bodewig
Date: Sun May 26 17:36:35 2013
New Revision: 1486437

URL: http://svn.apache.org/r1486437
Log:
COMPRESS-228 be more lenient when parsing zip64 extra field

Added:
commons/proper/compress/trunk/src/test/resources/COMPRESS-228.zip   (with 
props)
Modified:
commons/proper/compress/trunk/src/changes/changes.xml

commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/zip/Zip64ExtendedInformationExtraField.java

commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/archivers/zip/ZipFileTest.java

Modified: commons/proper/compress/trunk/src/changes/changes.xml
URL: 
http://svn.apache.org/viewvc/commons/proper/compress/trunk/src/changes/changes.xml?rev=1486437r1=1486436r2=1486437view=diff
==
--- commons/proper/compress/trunk/src/changes/changes.xml (original)
+++ commons/proper/compress/trunk/src/changes/changes.xml Sun May 26 17:36:35 
2013
@@ -49,6 +49,11 @@ The action type attribute can be add,u
 TarBuffer.tryToConsumeSecondEOFRecord could throw a
 NullPointerException
   /action
+  action type=fix date=2013-05-26 issue=COMPRESS-228
+Parsing of zip64 extra fields has become more lenient in order
+to be able to read archives created by DotNetZip and maybe
+other archivers as well.
+  /action
 /release
 release version=1.5 date=2013-03-14
  description=Release 1.5

Modified: 
commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/zip/Zip64ExtendedInformationExtraField.java
URL: 
http://svn.apache.org/viewvc/commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/zip/Zip64ExtendedInformationExtraField.java?rev=1486437r1=1486436r2=1486437view=diff
==
--- 
commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/zip/Zip64ExtendedInformationExtraField.java
 (original)
+++ 
commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/zip/Zip64ExtendedInformationExtraField.java
 Sun May 26 17:36:35 2013
@@ -242,7 +242,7 @@ public class Zip64ExtendedInformationExt
  * field with knowledge which fields are expected to be there.
  *
  * pAll four fields inside the zip64 extended information extra
- * field are optional and only present if their corresponding
+ * field are optional and must only be present if their corresponding
  * entry inside the central directory contains the correct magic
  * value./p
  */
@@ -256,7 +256,7 @@ public class Zip64ExtendedInformationExt
 + (hasCompressedSize ? DWORD : 0)
 + (hasRelativeHeaderOffset ? DWORD : 0)
 + (hasDiskStart ? WORD : 0);
-if (rawCentralDirectoryData.length != expectedLength) {
+if (rawCentralDirectoryData.length  expectedLength) {
 throw new ZipException(central directory zip64 extended
+  information extra field's length
+  doesn't match central directory

Modified: 
commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/archivers/zip/ZipFileTest.java
URL: 
http://svn.apache.org/viewvc/commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/archivers/zip/ZipFileTest.java?rev=1486437r1=1486436r2=1486437view=diff
==
--- 
commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/archivers/zip/ZipFileTest.java
 (original)
+++ 
commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/archivers/zip/ZipFileTest.java
 Sun May 26 17:36:35 2013
@@ -226,6 +226,18 @@ public class ZipFileTest extends TestCas
 assertEquals(2, numberOfEntries);
 }
 
+/**
+ * @see https://issues.apache.org/jira/browse/COMPRESS-228
+ */
+public void testExcessDataInZip64ExtraField() throws Exception {
+File archive = getFile(COMPRESS-228.zip);
+zf = new ZipFile(archive);
+// actually, if we get here, the test already has passed
+
+ZipArchiveEntry ze = 
zf.getEntry(src/main/java/org/apache/commons/compress/archivers/zip/ZipFile.java);
+assertEquals(26101, ze.getSize());
+}
+
 /*
  * ordertest.zip has been handcrafted.
  *

Added: commons/proper/compress/trunk/src/test/resources/COMPRESS-228.zip
URL: 
http://svn.apache.org/viewvc/commons/proper/compress/trunk/src/test/resources/COMPRESS-228.zip?rev=1486437view=auto
==
Binary file - no diff available.

Propchange: commons/proper/compress/trunk/src/test/resources/COMPRESS-228.zip
--
svn:mime

svn commit: r1486874 - /commons/proper/compress/trunk/src/site/xdoc/zip.xml

2013-05-28 Thread bodewig
Author: bodewig
Date: Tue May 28 11:24:47 2013
New Revision: 1486874

URL: http://svn.apache.org/r1486874
Log:
Java5 doesn't like Zip64 extra fields at all

Modified:
commons/proper/compress/trunk/src/site/xdoc/zip.xml

Modified: commons/proper/compress/trunk/src/site/xdoc/zip.xml
URL: 
http://svn.apache.org/viewvc/commons/proper/compress/trunk/src/site/xdoc/zip.xml?rev=1486874r1=1486873r2=1486874view=diff
==
--- commons/proper/compress/trunk/src/site/xdoc/zip.xml (original)
+++ commons/proper/compress/trunk/src/site/xdoc/zip.xml Tue May 28 11:24:47 2013
@@ -329,9 +329,14 @@
   (see a href=#ZipArchiveOutputStreamabove/a).  If only
   the uncompressed size is
   known codeZipArchiveOutputStream/code will assume the
-  compressed size will not be bigger that the compressed
+  compressed size will not be bigger than the uncompressed
   size./p
 
+pcodeZipArchiveOutputStream/code's
+  codesetUseZip64/code can be used to control the behavior.
+  codeZip64Mode.AsNeeded/code is the default behavior
+  described in the previous paragraph./p
+
 pIf codeZipArchiveOutputStream/code is writing to a
   non-seekable stream it has to decide whether to use Zip64
   extensions or not before it starts wrtiting the entry data.
@@ -350,11 +355,6 @@
   of them to be too big to fit into the traditional
   limits./p
 
-pcodeZipArchiveOutputStream/code's codesetUseZip64/code
-  can be used to control the change the default
-  behavior.  codeZip64Mode.AsNeeded/code is the default
-  behavior described in the previous paragraph./p
-
 pcodeZip64Mode.Always/code creates archives that use
   Zip64 extensions for all entries, even those that don't
   require them.  Such archives will be slightly bigger than
@@ -373,6 +373,12 @@
   in codeZip64Mode.AsNeeded/code mode if some of the
   entries had unknown sizes./p
 
+pThe codejava.util.zip/code package and the
+  codejar/code command of Java5 and earlier can not read
+  Zip64 extensions and will fail if the archive contains any.
+  So if you intend to create archives that Java5 can consume
+  you must set the mode to codeZip64Mode.Never/code/p
+
 h4Known Limitations/h4
 
 pSome of the theoretical limits of the format are not




svn commit: r863617 - in /websites/production/commons/content/proper/commons-compress: ./ apidocs/ apidocs/org/apache/commons/compress/archivers/ apidocs/org/apache/commons/compress/archivers/ar/ apid

2013-05-29 Thread bodewig
Author: bodewig
Date: Wed May 29 12:52:57 2013
New Revision: 863617

Log:
Republish  compress' site


[This commit notification would consist of 58 parts, 
which exceeds the limit of 50 ones, so it was shortened to the summary.]


svn commit: r1487468 - /commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/zip/ZipFile.java

2013-05-29 Thread bodewig
Author: bodewig
Date: Wed May 29 12:59:44 2013
New Revision: 1487468

URL: http://svn.apache.org/r1487468
Log:
use LinkedList explicitly for the tiny gain getFirst() provides over get(0)

Modified:

commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/zip/ZipFile.java

Modified: 
commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/zip/ZipFile.java
URL: 
http://svn.apache.org/viewvc/commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/zip/ZipFile.java?rev=1487468r1=1487467r2=1487468view=diff
==
--- 
commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/zip/ZipFile.java
 (original)
+++ 
commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/zip/ZipFile.java
 Wed May 29 12:59:44 2013
@@ -94,8 +94,8 @@ public class ZipFile {
 /**
  * Maps String to list of ZipArchiveEntrys, name - actual entries.
  */
-private final MapString, ListZipArchiveEntry nameMap =
-new HashMapString, ListZipArchiveEntry(HASH_SIZE);
+private final MapString, LinkedListZipArchiveEntry nameMap =
+new HashMapString, LinkedListZipArchiveEntry(HASH_SIZE);
 
 private static final class OffsetEntry {
 private long headerOffset = -1;
@@ -307,8 +307,8 @@ public class ZipFile {
  * {@code null} if not present.
  */
 public ZipArchiveEntry getEntry(String name) {
-ListZipArchiveEntry entriesOfThatName = nameMap.get(name);
-return entriesOfThatName != null ? entriesOfThatName.get(0) : null;
+LinkedListZipArchiveEntry entriesOfThatName = nameMap.get(name);
+return entriesOfThatName != null ? entriesOfThatName.getFirst() : null;
 }
 
 /**
@@ -925,12 +925,12 @@ public class ZipFile {
 }
 
 String name = ze.getName();
-ListZipArchiveEntry entriesOfThatName = nameMap.get(name);
+LinkedListZipArchiveEntry entriesOfThatName = nameMap.get(name);
 if (entriesOfThatName == null) {
 entriesOfThatName = new LinkedListZipArchiveEntry();
 nameMap.put(name, entriesOfThatName);
 }
-entriesOfThatName.add(ze);
+entriesOfThatName.addLast(ze);
 }
 }
 




svn commit: r1488935 - in /commons/proper/compress/trunk/src: changes/ main/java/org/apache/commons/compress/archivers/tar/ test/java/org/apache/commons/compress/archivers/ test/resources/longsymlink/

2013-06-03 Thread bodewig
Author: bodewig
Date: Mon Jun  3 09:20:30 2013
New Revision: 1488935

URL: http://svn.apache.org/r1488935
Log:
COMPRESS-229 properly parse GNU_LONGLNK entries, patch by Christoph Gysin

Added:
commons/proper/compress/trunk/src/test/resources/longsymlink/
commons/proper/compress/trunk/src/test/resources/longsymlink/files.txt   
(with props)
commons/proper/compress/trunk/src/test/resources/longsymlink/gnu.tar   
(with props)
Modified:
commons/proper/compress/trunk/src/changes/changes.xml

commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/tar/TarArchiveEntry.java

commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/tar/TarArchiveInputStream.java

commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/tar/TarConstants.java

commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/archivers/LongPathTest.java

Modified: commons/proper/compress/trunk/src/changes/changes.xml
URL: 
http://svn.apache.org/viewvc/commons/proper/compress/trunk/src/changes/changes.xml?rev=1488935r1=1488934r2=1488935view=diff
==
--- commons/proper/compress/trunk/src/changes/changes.xml (original)
+++ commons/proper/compress/trunk/src/changes/changes.xml Mon Jun  3 09:20:30 
2013
@@ -54,6 +54,12 @@ The action type attribute can be add,u
 to be able to read archives created by DotNetZip and maybe
 other archivers as well.
   /action
+  action type=fix date=2013-06-03 issue=COMPRESS-229
+  due-to=Christoph Gysin
+TAR will now properly read the names of symbolic links with
+long names that use the GNU variant to specify the long file
+name.
+  /action
 /release
 release version=1.5 date=2013-03-14
  description=Release 1.5

Modified: 
commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/tar/TarArchiveEntry.java
URL: 
http://svn.apache.org/viewvc/commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/tar/TarArchiveEntry.java?rev=1488935r1=1488934r2=1488935view=diff
==
--- 
commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/tar/TarArchiveEntry.java
 (original)
+++ 
commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/tar/TarArchiveEntry.java
 Mon Jun  3 09:20:30 2013
@@ -676,6 +676,16 @@ public class TarArchiveEntry implements 
 }
 
 /**
+ * Indicate if this entry is a GNU long linkname block
+ *
+ * @return true if this is a long name extension provided by GNU tar
+ */
+public boolean isGNULongLinkEntry() {
+return linkFlag == LF_GNUTYPE_LONGLINK
+ name.equals(GNU_LONGLINK);
+}
+
+/**
  * Indicate if this entry is a GNU long name block
  *
  * @return true if this is a long name extension provided by GNU tar

Modified: 
commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/tar/TarArchiveInputStream.java
URL: 
http://svn.apache.org/viewvc/commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/tar/TarArchiveInputStream.java?rev=1488935r1=1488934r2=1488935view=diff
==
--- 
commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/tar/TarArchiveInputStream.java
 (original)
+++ 
commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/tar/TarArchiveInputStream.java
 Mon Jun  3 09:20:30 2013
@@ -248,31 +248,13 @@ public class TarArchiveInputStream exten
 entryOffset = 0;
 entrySize = currEntry.getSize();
 
-if (currEntry.isGNULongNameEntry()) {
-// read in the name
-ByteArrayOutputStream longName = new ByteArrayOutputStream();
-int length = 0;
-while ((length = read(SMALL_BUF)) = 0) {
-longName.write(SMALL_BUF, 0, length);
-}
-getNextEntry();
-if (currEntry == null) {
-// Bugzilla: 40334
-// Malformed tar file - long entry name not followed by entry
-return null;
-}
-byte[] longNameData = longName.toByteArray();
-// remove trailing null terminator(s)
-length = longNameData.length;
-while (length  0  longNameData[length - 1] == 0) {
---length;
-}
-if (length != longNameData.length) {
-byte[] l = new byte[length];
-System.arraycopy(longNameData, 0, l, 0, length);
-longNameData = l;
-}
+if (currEntry.isGNULongLinkEntry()) {
+byte[] longLinkData = getLongNameData

svn commit: r1488947 - /commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/tar/TarArchiveInputStream.java

2013-06-03 Thread bodewig
Author: bodewig
Date: Mon Jun  3 09:58:27 2013
New Revision: 1488947

URL: http://svn.apache.org/r1488947
Log:
COMPRESS-229 aftermaths, properly deal with broken archives that end with an 
incomplete entry.  Unfortunately we don't have a test for this

Modified:

commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/tar/TarArchiveInputStream.java

Modified: 
commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/tar/TarArchiveInputStream.java
URL: 
http://svn.apache.org/viewvc/commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/tar/TarArchiveInputStream.java?rev=1488947r1=1488946r2=1488947view=diff
==
--- 
commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/tar/TarArchiveInputStream.java
 (original)
+++ 
commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/tar/TarArchiveInputStream.java
 Mon Jun  3 09:58:27 2013
@@ -250,11 +250,23 @@ public class TarArchiveInputStream exten
 
 if (currEntry.isGNULongLinkEntry()) {
 byte[] longLinkData = getLongNameData();
+if (longLinkData == null) {
+// Bugzilla: 40334
+// Malformed tar file - long link entry name not followed by
+// entry
+return null;
+}
 currEntry.setLinkName(encoding.decode(longLinkData));
 }
 
 if (currEntry.isGNULongNameEntry()) {
 byte[] longNameData = getLongNameData();
+if (longNameData == null) {
+// Bugzilla: 40334
+// Malformed tar file - long entry name not followed by
+// entry
+return null;
+}
 currEntry.setName(encoding.decode(longNameData));
 }
 




svn commit: r1489284 - in /commons/proper/compress/trunk/src: main/java/org/apache/commons/compress/archivers/zip/ZipFile.java test/java/org/apache/commons/compress/archivers/zip/ZipFileTest.java

2013-06-03 Thread bodewig
Author: bodewig
Date: Tue Jun  4 04:22:05 2013
New Revision: 1489284

URL: http://svn.apache.org/r1489284
Log:
COMPRESS-227 return Iterable rather than Iterator in new methods

Modified:

commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/zip/ZipFile.java

commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/archivers/zip/ZipFileTest.java

Modified: 
commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/zip/ZipFile.java
URL: 
http://svn.apache.org/viewvc/commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/zip/ZipFile.java?rev=1489284r1=1489283r2=1489284view=diff
==
--- 
commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/zip/ZipFile.java
 (original)
+++ 
commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/zip/ZipFile.java
 Tue Jun  4 04:22:05 2013
@@ -316,14 +316,14 @@ public class ZipFile {
  * the archive's central directory.
  *
  * @param name name of the entry.
- * @return the IteratorZipArchiveEntry corresponding to the
+ * @return the IterableZipArchiveEntry corresponding to the
  * given name
  * @since 1.6
  */
-public IteratorZipArchiveEntry getEntries(String name) {
+public IterableZipArchiveEntry getEntries(String name) {
 ListZipArchiveEntry entriesOfThatName = nameMap.get(name);
-return entriesOfThatName != null ? entriesOfThatName.iterator()
-: Collections.ZipArchiveEntryemptyList().iterator();
+return entriesOfThatName != null ? entriesOfThatName
+: Collections.ZipArchiveEntryemptyList();
 }
 
 /**
@@ -331,17 +331,17 @@ public class ZipFile {
  * appear within the archive.
  *
  * @param name name of the entry.
- * @return the IteratorZipArchiveEntry corresponding to the
+ * @return the IterableZipArchiveEntry corresponding to the
  * given name
  * @since 1.6
  */
-public IteratorZipArchiveEntry getEntriesInPhysicalOrder(String name) {
+public IterableZipArchiveEntry getEntriesInPhysicalOrder(String name) {
 ZipArchiveEntry[] entriesOfThatName = new ZipArchiveEntry[0];
 if (nameMap.containsKey(name)) {
 entriesOfThatName = nameMap.get(name).toArray(entriesOfThatName);
 Arrays.sort(entriesOfThatName, OFFSET_COMPARATOR);
 }
-return Arrays.asList(entriesOfThatName).iterator();
+return Arrays.asList(entriesOfThatName);
 }
 
 /**

Modified: 
commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/archivers/zip/ZipFileTest.java
URL: 
http://svn.apache.org/viewvc/commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/archivers/zip/ZipFileTest.java?rev=1489284r1=1489283r2=1489284view=diff
==
--- 
commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/archivers/zip/ZipFileTest.java
 (original)
+++ 
commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/archivers/zip/ZipFileTest.java
 Tue Jun  4 04:22:05 2013
@@ -217,11 +217,9 @@ public class ZipFileTest extends TestCas
 assertNotNull(zf.getInputStream(ze));
 
 int numberOfEntries = 0;
-for (IteratorZipArchiveEntry it = zf.getEntries(test1.txt);
- it.hasNext(); ) {
+for (ZipArchiveEntry entry : zf.getEntries(test1.txt)) {
 numberOfEntries++;
-ze = it.next();
-assertNotNull(zf.getInputStream(ze));
+assertNotNull(zf.getInputStream(entry));
 }
 assertEquals(2, numberOfEntries);
 }




svn commit: r1489285 - /commons/proper/compress/trunk/src/changes/changes.xml

2013-06-03 Thread bodewig
Author: bodewig
Date: Tue Jun  4 04:26:51 2013
New Revision: 1489285

URL: http://svn.apache.org/r1489285
Log:
keep track of changes

Modified:
commons/proper/compress/trunk/src/changes/changes.xml

Modified: commons/proper/compress/trunk/src/changes/changes.xml
URL: 
http://svn.apache.org/viewvc/commons/proper/compress/trunk/src/changes/changes.xml?rev=1489285r1=1489284r2=1489285view=diff
==
--- commons/proper/compress/trunk/src/changes/changes.xml (original)
+++ commons/proper/compress/trunk/src/changes/changes.xml Tue Jun  4 04:26:51 
2013
@@ -49,6 +49,16 @@ The action type attribute can be add,u
 TarBuffer.tryToConsumeSecondEOFRecord could throw a
 NullPointerException
   /action
+  action type=add date=2013-05-07 issue=COMPRESS-54
+  due-to=Damjan Jovanovic
+Added read-only support for 7z archives that don't use
+LZMA compression.
+  /action
+  action type=add date=2013-05-19 issue=COMPRESS-226
+  due-to=Damjan Jovanovic
+Added read-only support for ARJ archives that don't use
+compression.
+  /action
   action type=fix date=2013-05-26 issue=COMPRESS-228
 Parsing of zip64 extra fields has become more lenient in order
 to be able to read archives created by DotNetZip and maybe
@@ -60,6 +70,12 @@ The action type attribute can be add,u
 long names that use the GNU variant to specify the long file
 name.
   /action
+  action type=fix date=2013-06-04 issue=COMPRESS-227
+ZipFile#getInoutStream could return null if the archive
+contained duplicate entries.
+The class now also provides two new methods to obtain all
+entries of a given name rather than just the first one.
+  /action
 /release
 release version=1.5 date=2013-03-14
  description=Release 1.5




svn commit: r1491177 - in /commons/proper/compress/trunk/src/site/xdoc: examples.xml index.xml

2013-06-09 Thread bodewig
Author: bodewig
Date: Sun Jun  9 10:24:20 2013
New Revision: 1491177

URL: http://svn.apache.org/r1491177
Log:
not the current limitations of 7z and arj support

Modified:
commons/proper/compress/trunk/src/site/xdoc/examples.xml
commons/proper/compress/trunk/src/site/xdoc/index.xml

Modified: commons/proper/compress/trunk/src/site/xdoc/examples.xml
URL: 
http://svn.apache.org/viewvc/commons/proper/compress/trunk/src/site/xdoc/examples.xml?rev=1491177r1=1491176r2=1491177view=diff
==
--- commons/proper/compress/trunk/src/site/xdoc/examples.xml (original)
+++ commons/proper/compress/trunk/src/site/xdoc/examples.xml Sun Jun  9 
10:24:20 2013
@@ -32,9 +32,10 @@
 compressed) archive are archiver formats./p
 
 pThe compressor formats supported are gzip, bzip2, xz and
-Pack200, the archiver formats are ar, cpio, dump (read-only),
-tar, zip, 7z and arj.  Pack200 is a special case as it can only
-compress JAR files./p
+Pack200, the archiver formats are ar, cpio, tar and zip as
+well as dump, 7z and arj for which we currently only support
+reading.  Pack200 is a special case as it can only compress
+JAR files./p
   /subsection
 
   subsection name=Common Notes
@@ -426,6 +427,11 @@ xzIn.close();
 
   subsection name=7z
 
+pNote that Commons Compress currently only supports
+uncompressed entries or entries compressed using BZIP2 or
+LZMA2 and no header compression at all.  Only AES-256/SHA-256
+are supported for encryption./p
+
 pUncompressing a given 7z archive (you would
   certainly add exception handling and make sure all streams
   get closed properly):/p
@@ -441,6 +447,9 @@ LOOP UNTIL entry.getSize() HAS BEEN READ
 
   subsection name=arj
 
+pNote that Commons Compress doesn't support compressed,
+encrypted or multi-volume ARJ archives, yet./p
+
 pUncompressing a given arj archive (you would
   certainly add exception handling and make sure all streams
   get closed properly):/p

Modified: commons/proper/compress/trunk/src/site/xdoc/index.xml
URL: 
http://svn.apache.org/viewvc/commons/proper/compress/trunk/src/site/xdoc/index.xml?rev=1491177r1=1491176r2=1491177view=diff
==
--- commons/proper/compress/trunk/src/site/xdoc/index.xml (original)
+++ commons/proper/compress/trunk/src/site/xdoc/index.xml Sun Jun  9 10:24:20 
2013
@@ -76,7 +76,8 @@
 archivers where the a href=zip.htmlzip/a
 implementation provides capabilities that go beyond the
 features found in java.util.zip.  As of Commons Compress
-1.3 support for the dump, 7z and arj formats is read-only./p
+1.6 support for the dump, 7z and arj formats is
+read-only./p
 
   pThe compress component provides abstract base classes for
 compressors and archivers together with factories that can




svn commit: r865011 - in /websites/production/commons/content/proper/commons-compress: ./ apidocs/ apidocs/org/apache/commons/compress/archivers/arj/ apidocs/org/apache/commons/compress/archivers/tar/

2013-06-09 Thread bodewig
Author: bodewig
Date: Sun Jun  9 10:31:02 2013
New Revision: 865011

Log:
update compress' site


[This commit notification would consist of 58 parts, 
which exceeds the limit of 50 ones, so it was shortened to the summary.]


svn commit: r1491182 - /commons/proper/compress/branches/LZMA/

2013-06-09 Thread bodewig
Author: bodewig
Date: Sun Jun  9 11:08:10 2013
New Revision: 1491182

URL: http://svn.apache.org/r1491182
Log:
create a branch to implement LZMA support

Added:
commons/proper/compress/branches/LZMA/   (props changed)
  - copied from r1491181, commons/proper/compress/trunk/

Propchange: commons/proper/compress/branches/LZMA/
--
--- subclipse:tags (added)
+++ subclipse:tags Sun Jun  9 11:08:10 2013
@@ -0,0 +1,2 @@
+1152546,COMPRESS_1.2,/commons/proper/compress/tags/COMPRESS_1.2,tag
+1196226,COMPRESS_1.3,/commons/proper/compress/tags/COMPRESS_1.3,tag

Propchange: commons/proper/compress/branches/LZMA/
--
--- svn:ignore (added)
+++ svn:ignore Sun Jun  9 11:08:10 2013
@@ -0,0 +1,7 @@
+target
+*.iml
+*.ipr
+*.iws
+.*
+maven-eclipse.xml
+TAGS

Propchange: commons/proper/compress/branches/LZMA/
--
svn:mergeinfo = /commons/proper/compress/branches/zip64:1149597-1152684




svn commit: r1491183 - /commons/proper/compress/branches/LZMA/pom.xml

2013-06-09 Thread bodewig
Author: bodewig
Date: Sun Jun  9 11:09:49 2013
New Revision: 1491183

URL: http://svn.apache.org/r1491183
Log:
use more recent version of XZ for Java

Modified:
commons/proper/compress/branches/LZMA/pom.xml

Modified: commons/proper/compress/branches/LZMA/pom.xml
URL: 
http://svn.apache.org/viewvc/commons/proper/compress/branches/LZMA/pom.xml?rev=1491183r1=1491182r2=1491183view=diff
==
--- commons/proper/compress/branches/LZMA/pom.xml (original)
+++ commons/proper/compress/branches/LZMA/pom.xml Sun Jun  9 11:09:49 2013
@@ -60,7 +60,7 @@ These include: bzip2, gzip, pack200, xz 
 dependency
   groupIdorg.tukaani/groupId
   artifactIdxz/artifactId
-  version1.3/version
+  version1.4-SNAPSHOT/version
 /dependency
   /dependencies
 




svn commit: r1491185 - in /commons/proper/compress/branches/LZMA/src: main/java/org/apache/commons/compress/compressors/ main/java/org/apache/commons/compress/compressors/lzma/ test/java/org/apache/co

2013-06-09 Thread bodewig
Author: bodewig
Date: Sun Jun  9 11:49:03 2013
New Revision: 1491185

URL: http://svn.apache.org/r1491185
Log:
COMPRESS-111 read-only support for LZMA

Added:

commons/proper/compress/branches/LZMA/src/main/java/org/apache/commons/compress/compressors/lzma/

commons/proper/compress/branches/LZMA/src/main/java/org/apache/commons/compress/compressors/lzma/LZMACompressorInputStream.java
   (with props)

commons/proper/compress/branches/LZMA/src/test/java/org/apache/commons/compress/compressors/LZMATestCase.java
   (with props)
commons/proper/compress/branches/LZMA/src/test/resources/bla.tar.lzma   
(with props)
Modified:

commons/proper/compress/branches/LZMA/src/main/java/org/apache/commons/compress/compressors/CompressorStreamFactory.java

Modified: 
commons/proper/compress/branches/LZMA/src/main/java/org/apache/commons/compress/compressors/CompressorStreamFactory.java
URL: 
http://svn.apache.org/viewvc/commons/proper/compress/branches/LZMA/src/main/java/org/apache/commons/compress/compressors/CompressorStreamFactory.java?rev=1491185r1=1491184r2=1491185view=diff
==
--- 
commons/proper/compress/branches/LZMA/src/main/java/org/apache/commons/compress/compressors/CompressorStreamFactory.java
 (original)
+++ 
commons/proper/compress/branches/LZMA/src/main/java/org/apache/commons/compress/compressors/CompressorStreamFactory.java
 Sun Jun  9 11:49:03 2013
@@ -26,6 +26,7 @@ import org.apache.commons.compress.compr
 import 
org.apache.commons.compress.compressors.bzip2.BZip2CompressorOutputStream;
 import org.apache.commons.compress.compressors.gzip.GzipCompressorInputStream;
 import org.apache.commons.compress.compressors.gzip.GzipCompressorOutputStream;
+import org.apache.commons.compress.compressors.lzma.LZMACompressorInputStream;
 import org.apache.commons.compress.compressors.xz.XZCompressorInputStream;
 import org.apache.commons.compress.compressors.xz.XZCompressorOutputStream;
 import org.apache.commons.compress.compressors.xz.XZUtils;
@@ -83,6 +84,12 @@ public class CompressorStreamFactory {
  */
 public static final String XZ = xz;
 
+/**
+ * Constant used to identify the LZMA compression method.
+ * @since 1.6
+ */
+public static final String LZMA = lzma;
+
 private boolean decompressConcatenated = false;
 
 /**
@@ -156,7 +163,7 @@ public class CompressorStreamFactory {
 /**
  * Create a compressor input stream from a compressor name and an input 
stream.
  * 
- * @param name of the compressor, i.e. gz, bzip2, xz, or pack200
+ * @param name of the compressor, i.e. gz, bzip2, xz, lzma, or 
pack200
  * @param in the input stream
  * @return compressor input stream
  * @throws CompressorException if the compressor name is not known
@@ -183,6 +190,10 @@ public class CompressorStreamFactory {
 return new XZCompressorInputStream(in);
 }
 
+if (LZMA.equalsIgnoreCase(name)) {
+return new LZMACompressorInputStream(in);
+}
+
 if (PACK200.equalsIgnoreCase(name)) {
 return new Pack200CompressorInputStream(in);
 }

Added: 
commons/proper/compress/branches/LZMA/src/main/java/org/apache/commons/compress/compressors/lzma/LZMACompressorInputStream.java
URL: 
http://svn.apache.org/viewvc/commons/proper/compress/branches/LZMA/src/main/java/org/apache/commons/compress/compressors/lzma/LZMACompressorInputStream.java?rev=1491185view=auto
==
--- 
commons/proper/compress/branches/LZMA/src/main/java/org/apache/commons/compress/compressors/lzma/LZMACompressorInputStream.java
 (added)
+++ 
commons/proper/compress/branches/LZMA/src/main/java/org/apache/commons/compress/compressors/lzma/LZMACompressorInputStream.java
 Sun Jun  9 11:49:03 2013
@@ -0,0 +1,84 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * License); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * AS IS BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.commons.compress.compressors.lzma;
+
+import java.io.IOException;
+import java.io.InputStream;
+import org.tukaani.xz.LZMAInputStream;
+
+import org.apache.commons.compress.compressors.CompressorInputStream

svn commit: r1491187 - in /commons/proper/compress/branches/LZMA/src/site/xdoc: examples.xml index.xml

2013-06-09 Thread bodewig
Author: bodewig
Date: Sun Jun  9 12:01:21 2013
New Revision: 1491187

URL: http://svn.apache.org/r1491187
Log:
COMPRESS-111 document lzma support

Modified:
commons/proper/compress/branches/LZMA/src/site/xdoc/examples.xml
commons/proper/compress/branches/LZMA/src/site/xdoc/index.xml

Modified: commons/proper/compress/branches/LZMA/src/site/xdoc/examples.xml
URL: 
http://svn.apache.org/viewvc/commons/proper/compress/branches/LZMA/src/site/xdoc/examples.xml?rev=1491187r1=1491186r2=1491187view=diff
==
--- commons/proper/compress/branches/LZMA/src/site/xdoc/examples.xml (original)
+++ commons/proper/compress/branches/LZMA/src/site/xdoc/examples.xml Sun Jun  9 
12:01:21 2013
@@ -31,11 +31,13 @@
 collect multiple entries inside a single (potentially
 compressed) archive are archiver formats./p
 
-pThe compressor formats supported are gzip, bzip2, xz and
+pThe compressor formats supported are gzip, bzip2, xz, lzma and
 Pack200, the archiver formats are ar, cpio, tar and zip as
 well as dump, 7z and arj for which we currently only support
 reading.  Pack200 is a special case as it can only compress
 JAR files./p
+
+pWe currently only provide read support for lzma as well./p
   /subsection
 
   subsection name=Common Notes
@@ -76,6 +78,10 @@ CompressorInputStream input = new Compre
 .createCompressorInputStream(originalInput);
 ]]/source
 
+pNote that there is no way to detect the lzma format so only
+the two-arg version of
+codecreateCompressorInputStream/code can be used./p
+
   /subsection
 
   subsection name=Unsupported Features
@@ -425,6 +431,30 @@ xzIn.close();
 ]]/source
   /subsection
 
+  subsection name=lzma
+
+pThe implementation of this package is provided by the
+  public domain a href=http://tukaani.org/xz/java.html;XZ
+  for Java/a library./p
+
+pUncompressing a given lzma compressed file (you would
+  certainly add exception handling and make sure all streams
+  get closed properly):/p
+source![CDATA[
+FileInputStream fin = new FileInputStream(archive.tar.lzma);
+BufferedInputStream in = new BufferedInputStream(fin);
+FileOutputStream out = new FileOutputStream(archive.tar);
+LZMACompressorInputStream lzmaIn = new LZMACompressorInputStream(in);
+final byte[] buffer = new byte[buffersize];
+int n = 0;
+while (-1 != (n = xzIn.read(buffer))) {
+out.write(buffer, 0, n);
+}
+out.close();
+lzmaIn.close();
+]]/source
+  /subsection
+
   subsection name=7z
 
 pNote that Commons Compress currently only supports

Modified: commons/proper/compress/branches/LZMA/src/site/xdoc/index.xml
URL: 
http://svn.apache.org/viewvc/commons/proper/compress/branches/LZMA/src/site/xdoc/index.xml?rev=1491187r1=1491186r2=1491187view=diff
==
--- commons/proper/compress/branches/LZMA/src/site/xdoc/index.xml (original)
+++ commons/proper/compress/branches/LZMA/src/site/xdoc/index.xml Sun Jun  9 
12:01:21 2013
@@ -27,7 +27,7 @@
 p
 The Apache Commons Compress library defines an API for
 working with ar, cpio, Unix dump, tar, zip, gzip, XZ, Pack200,
-bzip2, 7z and arj files.
+bzip2, 7z, arj and lzma files.
 /p
 p
 The code in this component has many origins:
@@ -64,13 +64,14 @@
 by codeArchiveEntry/code instances which in turn
 usually correspond to single files or directories./p
 
-  pCurrently the bzip2, Pack200, XZ and gzip formats are
+  pCurrently the bzip2, Pack200, XZ, gzip and lzma formats are
 supported as compressors where gzip support is mostly provided by
 the codejava.util.zip/code package and Pack200 support
 by the codejava.util.jar/code package of the Java
-class library.  XZ support is provided by the public
+class library.  XZ and lzma support is provided by the public
 domain a href=http://tukaani.org/xz/java.html;XZ for
-Java/a library./p
+Java/a library.  As of Commons Compress 1.6 support for
+the lzma formats is read-only./p
 
   pThe ar, arj, cpio, dump, tar, 7z and zip formats are supported as
 archivers where the a href=zip.htmlzip/a




svn commit: r1491216 - in /commons/proper/compress/branches/LZMA/src: main/java/org/apache/commons/compress/archivers/sevenz/Coders.java test/java/org/apache/commons/compress/archivers/sevenz/SevenZFi

2013-06-09 Thread bodewig
Author: bodewig
Date: Sun Jun  9 13:34:26 2013
New Revision: 1491216

URL: http://svn.apache.org/r1491216
Log:
Add LZMA support to 7z - I don't think this adds support for compressed headers

Added:
commons/proper/compress/branches/LZMA/src/test/resources/bla.7z   (with 
props)
Modified:

commons/proper/compress/branches/LZMA/src/main/java/org/apache/commons/compress/archivers/sevenz/Coders.java

commons/proper/compress/branches/LZMA/src/test/java/org/apache/commons/compress/archivers/sevenz/SevenZFileTest.java

Modified: 
commons/proper/compress/branches/LZMA/src/main/java/org/apache/commons/compress/archivers/sevenz/Coders.java
URL: 
http://svn.apache.org/viewvc/commons/proper/compress/branches/LZMA/src/main/java/org/apache/commons/compress/archivers/sevenz/Coders.java?rev=1491216r1=1491215r2=1491216view=diff
==
--- 
commons/proper/compress/branches/LZMA/src/main/java/org/apache/commons/compress/archivers/sevenz/Coders.java
 (original)
+++ 
commons/proper/compress/branches/LZMA/src/main/java/org/apache/commons/compress/archivers/sevenz/Coders.java
 Sun Jun  9 13:34:26 2013
@@ -31,6 +31,7 @@ import javax.crypto.spec.IvParameterSpec
 import javax.crypto.spec.SecretKeySpec;
 
 import 
org.apache.commons.compress.compressors.bzip2.BZip2CompressorInputStream;
+import org.tukaani.xz.LZMAInputStream;
 import org.tukaani.xz.LZMA2InputStream;
 
 class Coders {
@@ -47,6 +48,7 @@ class Coders {
 
 static CoderId[] coderTable = new CoderId[] {
 new CoderId(new byte[] { (byte)0x00 }, new CopyDecoder()),
+new CoderId(new byte[] { (byte)0x03, (byte)0x01, (byte)0x01 }, new 
LZMADecoder()),
 new CoderId(new byte[] { (byte)0x21 }, new LZMA2Decoder()),
 // FIXME: gives corrupt output
 //new CoderId(new byte[] { (byte)0x04, (byte)0x01, (byte)0x08 }, new 
DeflateDecoder()),
@@ -98,6 +100,22 @@ class Coders {
 }
 }
 
+static class LZMADecoder extends CoderBase {
+@Override
+InputStream decode(final InputStream in, final Coder coder,
+String password) throws IOException {
+byte propsByte = coder.properties[0];
+long dictSize = coder.properties[1];
+for (int i = 1; i  4; i++) {
+dictSize |= (coder.properties[i + 1]  (8 * i));
+}
+if (dictSize  LZMAInputStream.DICT_SIZE_MAX) {
+throw new IOException(Dictionary larger than 4GiB maximum 
size);
+}
+return new LZMAInputStream(in, -1, propsByte, (int) dictSize);
+}
+}
+
 //static class DeflateDecoder extends CoderBase {
 //@Override
 //InputStream decode(final InputStream in, final Coder coder, final 
String password)

Modified: 
commons/proper/compress/branches/LZMA/src/test/java/org/apache/commons/compress/archivers/sevenz/SevenZFileTest.java
URL: 
http://svn.apache.org/viewvc/commons/proper/compress/branches/LZMA/src/test/java/org/apache/commons/compress/archivers/sevenz/SevenZFileTest.java?rev=1491216r1=1491215r2=1491216view=diff
==
--- 
commons/proper/compress/branches/LZMA/src/test/java/org/apache/commons/compress/archivers/sevenz/SevenZFileTest.java
 (original)
+++ 
commons/proper/compress/branches/LZMA/src/test/java/org/apache/commons/compress/archivers/sevenz/SevenZFileTest.java
 Sun Jun  9 13:34:26 2013
@@ -20,6 +20,9 @@ package org.apache.commons.compress.arch
 import org.apache.commons.compress.AbstractTestCase;
 
 public class SevenZFileTest extends AbstractTestCase {
+private static String TEST2_CONTENT = ?xml version = 
'1.0'?\r\n!DOCTYPE
++  connections\r\nmeinxml\r\n\tleer /\r\n/meinxml\n;
+
 public void testAllEmptyFilesArchive() throws Exception {
 SevenZFile archive = new SevenZFile(getFile(7z-empty-mhc-off.7z));
 try {
@@ -37,6 +40,27 @@ public class SevenZFileTest extends Abst
 checkHelloWorld(7z-hello-mhc-off-lzma2.7z);
 }
 
+public void test7zUnarchive() throws Exception {
+SevenZFile sevenZFile = new SevenZFile(getFile(bla.7z));
+try {
+SevenZArchiveEntry entry = sevenZFile.getNextEntry();
+assertEquals(test1.xml, entry.getName());
+entry = sevenZFile.getNextEntry();
+assertEquals(test2.xml, entry.getName());
+byte[] contents = new byte[(int)entry.getSize()];
+int off = 0;
+while ((off  contents.length)) {
+int bytesRead = sevenZFile.read(contents, off, contents.length 
- off);
+assert(bytesRead = 0);
+off += bytesRead;
+}
+assertEquals(TEST2_CONTENT, new String(contents, UTF-8));
+assertNull(sevenZFile.getNextEntry());
+} finally {
+sevenZFile.close();
+}
+}
+
 private void

svn commit: r1491861 - in /commons/proper/compress/branches/LZMA: ./ src/main/java/org/apache/commons/compress/archivers/sevenz/ src/site/xdoc/ src/test/java/org/apache/commons/compress/archivers/

2013-06-11 Thread bodewig
Author: bodewig
Date: Tue Jun 11 16:20:23 2013
New Revision: 1491861

URL: http://svn.apache.org/r1491861
Log:
merge 7z write support

Added:

commons/proper/compress/branches/LZMA/src/main/java/org/apache/commons/compress/archivers/sevenz/SevenZOutputFile.java
  - copied unchanged from r1491496, 
commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/sevenz/SevenZOutputFile.java

commons/proper/compress/branches/LZMA/src/test/java/org/apache/commons/compress/archivers/SevenZTestCase.java
  - copied unchanged from r1491496, 
commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/archivers/SevenZTestCase.java
Modified:
commons/proper/compress/branches/LZMA/   (props changed)

commons/proper/compress/branches/LZMA/src/main/java/org/apache/commons/compress/archivers/sevenz/SevenZFile.java

commons/proper/compress/branches/LZMA/src/main/java/org/apache/commons/compress/archivers/sevenz/package.html
commons/proper/compress/branches/LZMA/src/site/xdoc/examples.xml
commons/proper/compress/branches/LZMA/src/site/xdoc/index.xml

Propchange: commons/proper/compress/branches/LZMA/
--
  Merged /commons/proper/compress/trunk:r1491496

Modified: 
commons/proper/compress/branches/LZMA/src/main/java/org/apache/commons/compress/archivers/sevenz/SevenZFile.java
URL: 
http://svn.apache.org/viewvc/commons/proper/compress/branches/LZMA/src/main/java/org/apache/commons/compress/archivers/sevenz/SevenZFile.java?rev=1491861r1=1491860r2=1491861view=diff
==
--- 
commons/proper/compress/branches/LZMA/src/main/java/org/apache/commons/compress/archivers/sevenz/SevenZFile.java
 (original)
+++ 
commons/proper/compress/branches/LZMA/src/main/java/org/apache/commons/compress/archivers/sevenz/SevenZFile.java
 Tue Jun 11 16:20:23 2013
@@ -69,7 +69,7 @@ import org.apache.commons.compress.utils
  */
 public class SevenZFile {
 private static final boolean DEBUG = false;
-private static final int SIGNATURE_HEADER_SIZE = 32;
+static final int SIGNATURE_HEADER_SIZE = 32;
 private RandomAccessFile file;
 private final Archive archive;
 private int currentEntryIndex = -1;
@@ -78,7 +78,7 @@ public class SevenZFile {
 private InputStream currentEntryInputStream = null;
 private String password;
 
-private static final byte[] sevenZSignature = {
+static final byte[] sevenZSignature = {
 (byte)'7', (byte)'z', (byte)0xBC, (byte)0xAF, (byte)0x27, (byte)0x1C
 };
 

Modified: 
commons/proper/compress/branches/LZMA/src/main/java/org/apache/commons/compress/archivers/sevenz/package.html
URL: 
http://svn.apache.org/viewvc/commons/proper/compress/branches/LZMA/src/main/java/org/apache/commons/compress/archivers/sevenz/package.html?rev=1491861r1=1491860r2=1491861view=diff
==
--- 
commons/proper/compress/branches/LZMA/src/main/java/org/apache/commons/compress/archivers/sevenz/package.html
 (original)
+++ 
commons/proper/compress/branches/LZMA/src/main/java/org/apache/commons/compress/archivers/sevenz/package.html
 Tue Jun 11 16:20:23 2013
@@ -18,7 +18,7 @@
 
 --
   body
-pProvides classes for reading archives using
+pProvides classes for reading and writing archives using
   the 7z format./p
   /body
 /html

Modified: commons/proper/compress/branches/LZMA/src/site/xdoc/examples.xml
URL: 
http://svn.apache.org/viewvc/commons/proper/compress/branches/LZMA/src/site/xdoc/examples.xml?rev=1491861r1=1491860r2=1491861view=diff
==
--- commons/proper/compress/branches/LZMA/src/site/xdoc/examples.xml (original)
+++ commons/proper/compress/branches/LZMA/src/site/xdoc/examples.xml Tue Jun 11 
16:20:23 2013
@@ -462,6 +462,15 @@ lzmaIn.close();
 LZMA2 and no header compression at all.  Only AES-256/SHA-256
 are supported for encryption./p
 
+pAdding an entry to a 7z archive:/p
+source![CDATA[
+SevenZOutputFile sevenZOutput = new SevenZOutputFile(file);
+SevenZArchiveEntry entry = sevenZOutput.createArchiveEntry(fileToArchive, 
name);
+sevenZOutput.putArchiveEntry(entry);
+sevenZOutput.write(contentOfEntry);
+sevenZOutput.closeArchiveEntry();
+]]/source
+
 pUncompressing a given 7z archive (you would
   certainly add exception handling and make sure all streams
   get closed properly):/p

Modified: commons/proper/compress/branches/LZMA/src/site/xdoc/index.xml
URL: 
http://svn.apache.org/viewvc/commons/proper/compress/branches/LZMA/src/site/xdoc/index.xml?rev=1491861r1=1491860r2=1491861view=diff
==
--- commons/proper/compress/branches/LZMA/src/site/xdoc/index.xml (original)
+++ commons/proper/compress

svn commit: r1493749 - /commons/proper/compress/trunk/README.txt

2013-06-17 Thread bodewig
Author: bodewig
Date: Mon Jun 17 13:07:49 2013
New Revision: 1493749

URL: http://svn.apache.org/r1493749
Log:
mandatory crypto notice

Modified:
commons/proper/compress/trunk/README.txt

Modified: commons/proper/compress/trunk/README.txt
URL: 
http://svn.apache.org/viewvc/commons/proper/compress/trunk/README.txt?rev=1493749r1=1493748r2=1493749view=diff
==
--- commons/proper/compress/trunk/README.txt (original)
+++ commons/proper/compress/trunk/README.txt Mon Jun 17 13:07:49 2013
@@ -10,3 +10,26 @@ Original Zip classes from contributors o
 
 Original CPIO classes contributed by Markus Kuss and the jRPM project
 (jrpm.sourceforge.net).
+
+This distribution includes cryptographic software. The country in
+which you currently reside may have restrictions on the import,
+possession, use, and/or re-export to another country, of encryption
+software. BEFORE using any encryption software, please check your
+country's laws, regulations and policies concerning the import,
+possession, or use, and re-export of encryption software, to see if
+this is permitted. See http://www.wassenaar.org/ for more
+information.
+
+The U.S. Government Department of Commerce, Bureau of Industry and
+Security (BIS), has classified this software as Export Commodity
+Control Number (ECCN) 5D002.C.1, which includes information security
+software using or performing cryptographic functions with asymmetric
+algorithms. The form and manner of this Apache Software Foundation
+distribution makes it eligible for export under the License Exception
+ENC Technology Software Unrestricted (TSU) exception (see the BIS
+Export Administration Regulations, Section 740.13) for both object
+code and source code.
+
+The following provides more details on the included cryptographic
+software:
+  * the 7zip package can read AES encrypted archives




svn commit: r1498776 - /commons/proper/compress/trunk/pom.xml

2013-07-01 Thread bodewig
Author: bodewig
Date: Tue Jul  2 04:17:30 2013
New Revision: 1498776

URL: http://svn.apache.org/r1498776
Log:
upgrade to CP32

Modified:
commons/proper/compress/trunk/pom.xml

Modified: commons/proper/compress/trunk/pom.xml
URL: 
http://svn.apache.org/viewvc/commons/proper/compress/trunk/pom.xml?rev=1498776r1=1498775r2=1498776view=diff
==
--- commons/proper/compress/trunk/pom.xml (original)
+++ commons/proper/compress/trunk/pom.xml Tue Jul  2 04:17:30 2013
@@ -20,7 +20,7 @@
   parent
 groupIdorg.apache.commons/groupId
 artifactIdcommons-parent/artifactId
-version30/version
+version32/version
   /parent
 
   groupIdorg.apache.commons/groupId
@@ -35,8 +35,8 @@ These include: bzip2, gzip, pack200, xz 
   /description
 
   properties
-maven.compile.source1.5/maven.compile.source
-maven.compile.target1.5/maven.compile.target
+maven.compiler.source1.5/maven.compiler.source
+maven.compiler.target1.5/maven.compiler.target
 commons.componentidcompress/commons.componentid
 commons.jira.idCOMPRESS/commons.jira.id
 commons.jira.pid12310904/commons.jira.pid
@@ -199,7 +199,7 @@ These include: bzip2, gzip, pack200, xz 
 version2.5/version
 configuration
   minimumTokens200/minimumTokens
-  targetJdk${maven.compile.source}/targetJdk
+  targetJdk${maven.compiler.source}/targetJdk
   rulesets
 ruleset${basedir}/pmd-ruleset.xml/ruleset
   /rulesets
@@ -211,7 +211,7 @@ These include: bzip2, gzip, pack200, xz 
 artifactIdmaven-javadoc-plugin/artifactId
 configuration 
   quiettrue/quiet
-  source${maven.compile.source}/source
+  source${maven.compiler.source}/source
   encoding${commons.encoding}/encoding
   docEncoding${commons.docEncoding}/docEncoding
   linksourcetrue/linksource




svn commit: r1500025 - in /commons/proper/compress/branches/LZMA: ./ README.txt pom.xml

2013-07-05 Thread bodewig
Author: bodewig
Date: Fri Jul  5 14:42:34 2013
New Revision: 1500025

URL: http://svn.apache.org/r1500025
Log:
merge

Modified:
commons/proper/compress/branches/LZMA/   (props changed)
commons/proper/compress/branches/LZMA/README.txt
commons/proper/compress/branches/LZMA/pom.xml

Propchange: commons/proper/compress/branches/LZMA/
--
  Merged /commons/proper/compress/trunk:r1491497-1500024

Modified: commons/proper/compress/branches/LZMA/README.txt
URL: 
http://svn.apache.org/viewvc/commons/proper/compress/branches/LZMA/README.txt?rev=1500025r1=1500024r2=1500025view=diff
==
--- commons/proper/compress/branches/LZMA/README.txt (original)
+++ commons/proper/compress/branches/LZMA/README.txt Fri Jul  5 14:42:34 2013
@@ -10,3 +10,26 @@ Original Zip classes from contributors o
 
 Original CPIO classes contributed by Markus Kuss and the jRPM project
 (jrpm.sourceforge.net).
+
+This distribution includes cryptographic software. The country in
+which you currently reside may have restrictions on the import,
+possession, use, and/or re-export to another country, of encryption
+software. BEFORE using any encryption software, please check your
+country's laws, regulations and policies concerning the import,
+possession, or use, and re-export of encryption software, to see if
+this is permitted. See http://www.wassenaar.org/ for more
+information.
+
+The U.S. Government Department of Commerce, Bureau of Industry and
+Security (BIS), has classified this software as Export Commodity
+Control Number (ECCN) 5D002.C.1, which includes information security
+software using or performing cryptographic functions with asymmetric
+algorithms. The form and manner of this Apache Software Foundation
+distribution makes it eligible for export under the License Exception
+ENC Technology Software Unrestricted (TSU) exception (see the BIS
+Export Administration Regulations, Section 740.13) for both object
+code and source code.
+
+The following provides more details on the included cryptographic
+software:
+  * the 7zip package can read AES encrypted archives

Modified: commons/proper/compress/branches/LZMA/pom.xml
URL: 
http://svn.apache.org/viewvc/commons/proper/compress/branches/LZMA/pom.xml?rev=1500025r1=1500024r2=1500025view=diff
==
--- commons/proper/compress/branches/LZMA/pom.xml (original)
+++ commons/proper/compress/branches/LZMA/pom.xml Fri Jul  5 14:42:34 2013
@@ -20,7 +20,7 @@
   parent
 groupIdorg.apache.commons/groupId
 artifactIdcommons-parent/artifactId
-version28/version
+version32/version
   /parent
 
   groupIdorg.apache.commons/groupId
@@ -35,8 +35,8 @@ These include: bzip2, gzip, pack200, xz 
   /description
 
   properties
-maven.compile.source1.5/maven.compile.source
-maven.compile.target1.5/maven.compile.target
+maven.compiler.source1.5/maven.compiler.source
+maven.compiler.target1.5/maven.compiler.target
 commons.componentidcompress/commons.componentid
 commons.jira.idCOMPRESS/commons.jira.id
 commons.jira.pid12310904/commons.jira.pid
@@ -199,7 +199,7 @@ These include: bzip2, gzip, pack200, xz 
 version2.5/version
 configuration
   minimumTokens200/minimumTokens
-  targetJdk${maven.compile.source}/targetJdk
+  targetJdk${maven.compiler.source}/targetJdk
   rulesets
 ruleset${basedir}/pmd-ruleset.xml/ruleset
   /rulesets
@@ -211,7 +211,7 @@ These include: bzip2, gzip, pack200, xz 
 artifactIdmaven-javadoc-plugin/artifactId
 configuration 
   quiettrue/quiet
-  source${maven.compile.source}/source
+  source${maven.compiler.source}/source
   encoding${commons.encoding}/encoding
   docEncoding${commons.docEncoding}/docEncoding
   linksourcetrue/linksource




svn commit: r1500757 - in /commons/proper/compress/trunk/src: changes/changes.xml main/java/org/apache/commons/compress/archivers/tar/TarArchiveInputStream.java

2013-07-08 Thread bodewig
Author: bodewig
Date: Mon Jul  8 14:25:37 2013
New Revision: 1500757

URL: http://svn.apache.org/r1500757
Log:
COMPRESS-232 improve readability of TarArchiveInputStream

Modified:
commons/proper/compress/trunk/src/changes/changes.xml

commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/tar/TarArchiveInputStream.java

Modified: commons/proper/compress/trunk/src/changes/changes.xml
URL: 
http://svn.apache.org/viewvc/commons/proper/compress/trunk/src/changes/changes.xml?rev=1500757r1=1500756r2=1500757view=diff
==
--- commons/proper/compress/trunk/src/changes/changes.xml (original)
+++ commons/proper/compress/trunk/src/changes/changes.xml Mon Jul  8 14:25:37 
2013
@@ -76,6 +76,10 @@ The action type attribute can be add,u
 The class now also provides two new methods to obtain all
 entries of a given name rather than just the first one.
   /action
+  action type=update date=2013-07-08 issue=COMPRESS-232
+  due-to=BELUGA BEHR
+Readabilty patch to TarArchiveInputStream.
+  /action
 /release
 release version=1.5 date=2013-03-14
  description=Release 1.5

Modified: 
commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/tar/TarArchiveInputStream.java
URL: 
http://svn.apache.org/viewvc/commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/tar/TarArchiveInputStream.java?rev=1500757r1=1500756r2=1500757view=diff
==
--- 
commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/tar/TarArchiveInputStream.java
 (original)
+++ 
commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/tar/TarArchiveInputStream.java
 Mon Jul  8 14:25:37 2013
@@ -233,7 +233,8 @@ public class TarArchiveInputStream exten
 
 byte[] headerBuf = getRecord();
 
-if (hasHitEOF) {
+if (headerBuf == null) {
+/* hit EOF */
 currEntry = null;
 return null;
 }
@@ -324,28 +325,27 @@ public class TarArchiveInputStream exten
  * over any remaining data in the current entry, if there
  * is one, and place the input stream at the header of the
  * next entry.
- * If there are no more entries in the archive, null will
- * be returned to indicate that the end of the archive has
- * been reached.
+ *
+ * pIf there are no more entries in the archive, null will be
+ * returned to indicate that the end of the archive has been
+ * reached.  At the same time the {@code hasHitEOF} marker will be
+ * set to true./p
  *
  * @return The next header in the archive, or null.
  * @throws IOException on error
  */
 private byte[] getRecord() throws IOException {
-if (hasHitEOF) {
-return null;
-}
-
-byte[] headerBuf = buffer.readRecord();
-
-if (buffer.isEOFRecord(headerBuf)) {
-hasHitEOF = true;
-if (headerBuf != null) {
+byte[] headerBuf = null;
+if (!hasHitEOF) {
+headerBuf = buffer.readRecord();
+hasHitEOF = buffer.isEOFRecord(headerBuf);
+if (hasHitEOF  headerBuf != null) {
 buffer.tryToConsumeSecondEOFRecord();
+headerBuf = null;
 }
 }
 
-return hasHitEOF ? null : headerBuf;
+return headerBuf;
 }
 
 private void paxHeaders() throws IOException{
@@ -456,7 +456,7 @@ public class TarArchiveInputStream exten
 TarArchiveSparseEntry entry;
 do {
 byte[] headerBuf = getRecord();
-if (hasHitEOF) {
+if (headerBuf == null) {
 currEntry = null;
 break;
 }




svn commit: r1500788 - in /commons/proper/compress/trunk/src: changes/changes.xml main/java/org/apache/commons/compress/archivers/tar/TarBuffer.java

2013-07-08 Thread bodewig
Author: bodewig
Date: Mon Jul  8 15:09:16 2013
New Revision: 1500788

URL: http://svn.apache.org/r1500788
Log:
COMPRESS-233 performance and readability tweak for TarBuffer

Modified:
commons/proper/compress/trunk/src/changes/changes.xml

commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/tar/TarBuffer.java

Modified: commons/proper/compress/trunk/src/changes/changes.xml
URL: 
http://svn.apache.org/viewvc/commons/proper/compress/trunk/src/changes/changes.xml?rev=1500788r1=1500787r2=1500788view=diff
==
--- commons/proper/compress/trunk/src/changes/changes.xml (original)
+++ commons/proper/compress/trunk/src/changes/changes.xml Mon Jul  8 15:09:16 
2013
@@ -80,6 +80,10 @@ The action type attribute can be add,u
   due-to=BELUGA BEHR
 Readabilty patch to TarArchiveInputStream.
   /action
+  action type=update date=2013-07-08 issue=COMPRESS-233
+  due-to=BELUGA BEHR
+Performance and readability patch to TarBuffer.
+  /action
 /release
 release version=1.5 date=2013-03-14
  description=Release 1.5

Modified: 
commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/tar/TarBuffer.java
URL: 
http://svn.apache.org/viewvc/commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/tar/TarBuffer.java?rev=1500788r1=1500787r2=1500788view=diff
==
--- 
commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/tar/TarBuffer.java
 (original)
+++ 
commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/tar/TarBuffer.java
 Mon Jul  8 15:09:16 2013
@@ -44,6 +44,8 @@ class TarBuffer { // Not public, because
 /** Default block size */
 public static final int DEFAULT_BLKSIZE = (DEFAULT_RCDSIZE * 20);
 
+private static final byte[] DEFAULT_EOF_RECORD = new byte[DEFAULT_RCDSIZE];
+
 // TODO make these final? (would need to change close() method)
 private InputStream inStream;
 private OutputStreamoutStream;
@@ -51,6 +53,7 @@ class TarBuffer { // Not public, because
 private final int recordSize;
 private final int recsPerBlock;
 private final byte[]  blockBuffer;
+private final byte[]  eofRecord;
 
 private int currBlkIdx;
 private int currRecIdx;
@@ -119,6 +122,8 @@ class TarBuffer { // Not public, because
 this.recordSize = recordSize;
 this.recsPerBlock = (this.blockSize / this.recordSize);
 this.blockBuffer = new byte[this.blockSize];
+this.eofRecord = recordSize == DEFAULT_RCDSIZE
+? DEFAULT_EOF_RECORD : new byte[recordSize];
 
 if (this.inStream != null) {
 this.currBlkIdx = -1;
@@ -153,14 +158,7 @@ class TarBuffer { // Not public, because
  * @return true if the record data is an End of Archive
  */
 public boolean isEOFRecord(byte[] record) {
-if (record != null) {
-for (int i = 0, sz = getRecordSize(); i  sz; ++i) {
-if (record[i] != 0) {
-return false;
-}
-}
-}
-return true;
+return record == null || Arrays.equals(record, eofRecord);
 }
 
 /**




svn commit: r1504154 - in /commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/zip: UnicodeCommentExtraField.java UnicodePathExtraField.java Zip64ExtendedInformationExtra

2013-07-17 Thread bodewig
Author: bodewig
Date: Wed Jul 17 14:37:22 2013
New Revision: 1504154

URL: http://svn.apache.org/r1504154
Log:
Remove direct citations form APPNOTE.TXT in javadocs, obey to section
1.4.2 in http://www.pkware.com/documents/casestudies/APPNOTE.TXT

Modified:

commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/zip/UnicodeCommentExtraField.java

commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/zip/UnicodePathExtraField.java

commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/zip/Zip64ExtendedInformationExtraField.java

commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/zip/ZipArchiveInputStream.java

Modified: 
commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/zip/UnicodeCommentExtraField.java
URL: 
http://svn.apache.org/viewvc/commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/zip/UnicodeCommentExtraField.java?rev=1504154r1=1504153r2=1504154view=diff
==
--- 
commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/zip/UnicodeCommentExtraField.java
 (original)
+++ 
commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/zip/UnicodeCommentExtraField.java
 Wed Jul 17 14:37:22 2013
@@ -24,15 +24,10 @@ package org.apache.commons.compress.arch
  * pStores the UTF-8 version of the file comment as stored in the
  * central directory header./p
  *
- * pre
- * Value SizeDescription
- * - ---
- *  (UCom) 0x6375Short   tag for this extra block type (uc)
- * TSize Short   total data size for this block
- * Version   1 byte  version of this extra field, currently 1
- * ComCRC32  4 bytes Comment Field CRC32 Checksum
- * UnicodeComVariableUTF-8 version of the entry comment
- * /pre
+ * pSee {@link
+ * http://www.pkware.com/documents/casestudies/APPNOTE.TXT PKWARE's
+ * APPNOTE.TXT, section 4.6.8}./p
+ *
  * @NotThreadSafe super-class is not thread-safe
  */
 public class UnicodeCommentExtraField extends AbstractUnicodeExtraField {

Modified: 
commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/zip/UnicodePathExtraField.java
URL: 
http://svn.apache.org/viewvc/commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/zip/UnicodePathExtraField.java?rev=1504154r1=1504153r2=1504154view=diff
==
--- 
commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/zip/UnicodePathExtraField.java
 (original)
+++ 
commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/zip/UnicodePathExtraField.java
 Wed Jul 17 14:37:22 2013
@@ -24,15 +24,9 @@ package org.apache.commons.compress.arch
  * pStores the UTF-8 version of the file name field as stored in the 
  * local header and central directory header./p
  *
- * pre
- * Value SizeDescription
- * - ---
- * (UPath) 0x7075Short   tag for this extra block type (up)
- * TSize Short   total data size for this block
- * Version   1 byte  version of this extra field, currently 1
- * NameCRC32 4 bytes File Name Field CRC32 Checksum
- * UnicodeName   VariableUTF-8 version of the entry File Name
- * /pre
+ * pSee {@link
+ * http://www.pkware.com/documents/casestudies/APPNOTE.TXT PKWARE's
+ * APPNOTE.TXT, section 4.6.9}./p
  * @NotThreadSafe super-class is not thread-safe
  */
 public class UnicodePathExtraField extends AbstractUnicodeExtraField {

Modified: 
commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/zip/Zip64ExtendedInformationExtraField.java
URL: 
http://svn.apache.org/viewvc/commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/zip/Zip64ExtendedInformationExtraField.java?rev=1504154r1=1504153r2=1504154view=diff
==
--- 
commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/zip/Zip64ExtendedInformationExtraField.java
 (original)
+++ 
commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/zip/Zip64ExtendedInformationExtraField.java
 Wed Jul 17 14:37:22 2013
@@ -27,42 +27,9 @@ import static org.apache.commons.compres
  * Holds size and other extended information for entries that use Zip64
  * features.
  *
- * pFrom {@link http://www.pkware.com/documents/casestudies/APPNOTE.TXT 
PKWARE's APPNOTE.TXT}
- * pre
- * Zip64 Extended Information Extra Field (0x0001):
- *
- *  The following is the layout of the zip64 extended

svn commit: r1504155 - in /commons/proper/compress/branches/LZMA: ./ src/changes/ src/main/java/org/apache/commons/compress/archivers/tar/ src/main/java/org/apache/commons/compress/archivers/zip/

2013-07-17 Thread bodewig
Author: bodewig
Date: Wed Jul 17 14:39:09 2013
New Revision: 1504155

URL: http://svn.apache.org/r1504155
Log:
merge from trunk

Modified:
commons/proper/compress/branches/LZMA/   (props changed)
commons/proper/compress/branches/LZMA/NOTICE.txt
commons/proper/compress/branches/LZMA/src/changes/changes.xml

commons/proper/compress/branches/LZMA/src/main/java/org/apache/commons/compress/archivers/tar/
   (props changed)

commons/proper/compress/branches/LZMA/src/main/java/org/apache/commons/compress/archivers/tar/TarArchiveInputStream.java

commons/proper/compress/branches/LZMA/src/main/java/org/apache/commons/compress/archivers/tar/TarBuffer.java
   (contents, props changed)

commons/proper/compress/branches/LZMA/src/main/java/org/apache/commons/compress/archivers/zip/
   (props changed)

commons/proper/compress/branches/LZMA/src/main/java/org/apache/commons/compress/archivers/zip/UnicodeCommentExtraField.java

commons/proper/compress/branches/LZMA/src/main/java/org/apache/commons/compress/archivers/zip/UnicodePathExtraField.java

commons/proper/compress/branches/LZMA/src/main/java/org/apache/commons/compress/archivers/zip/Zip64ExtendedInformationExtraField.java

commons/proper/compress/branches/LZMA/src/main/java/org/apache/commons/compress/archivers/zip/ZipArchiveInputStream.java

Propchange: commons/proper/compress/branches/LZMA/
--
  Merged /commons/proper/compress/trunk:r1500025-1504154

Modified: commons/proper/compress/branches/LZMA/NOTICE.txt
URL: 
http://svn.apache.org/viewvc/commons/proper/compress/branches/LZMA/NOTICE.txt?rev=1504155r1=1504154r2=1504155view=diff
==
--- commons/proper/compress/branches/LZMA/NOTICE.txt (original)
+++ commons/proper/compress/branches/LZMA/NOTICE.txt Wed Jul 17 14:39:09 2013
@@ -4,8 +4,6 @@ Copyright 2002-2013 The Apache Software 
 This product includes software developed at
 The Apache Software Foundation (http://www.apache.org/).
 
-
-
 The files in the package org.apache.commons.compress.archivers.sevenz
 were derived from the LZMA SDK, version 9.20 (C/ and CPP/7zip/),
 which has been placed in the public domain:

Modified: commons/proper/compress/branches/LZMA/src/changes/changes.xml
URL: 
http://svn.apache.org/viewvc/commons/proper/compress/branches/LZMA/src/changes/changes.xml?rev=1504155r1=1504154r2=1504155view=diff
==
--- commons/proper/compress/branches/LZMA/src/changes/changes.xml (original)
+++ commons/proper/compress/branches/LZMA/src/changes/changes.xml Wed Jul 17 
14:39:09 2013
@@ -76,6 +76,14 @@ The action type attribute can be add,u
 The class now also provides two new methods to obtain all
 entries of a given name rather than just the first one.
   /action
+  action type=update date=2013-07-08 issue=COMPRESS-232
+  due-to=BELUGA BEHR
+Readabilty patch to TarArchiveInputStream.
+  /action
+  action type=update date=2013-07-08 issue=COMPRESS-233
+  due-to=BELUGA BEHR
+Performance and readability patch to TarBuffer.
+  /action
 /release
 release version=1.5 date=2013-03-14
  description=Release 1.5

Propchange: 
commons/proper/compress/branches/LZMA/src/main/java/org/apache/commons/compress/archivers/tar/
--
  Merged 
/commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/tar:r1500025-1504154

Modified: 
commons/proper/compress/branches/LZMA/src/main/java/org/apache/commons/compress/archivers/tar/TarArchiveInputStream.java
URL: 
http://svn.apache.org/viewvc/commons/proper/compress/branches/LZMA/src/main/java/org/apache/commons/compress/archivers/tar/TarArchiveInputStream.java?rev=1504155r1=1504154r2=1504155view=diff
==
--- 
commons/proper/compress/branches/LZMA/src/main/java/org/apache/commons/compress/archivers/tar/TarArchiveInputStream.java
 (original)
+++ 
commons/proper/compress/branches/LZMA/src/main/java/org/apache/commons/compress/archivers/tar/TarArchiveInputStream.java
 Wed Jul 17 14:39:09 2013
@@ -233,7 +233,8 @@ public class TarArchiveInputStream exten
 
 byte[] headerBuf = getRecord();
 
-if (hasHitEOF) {
+if (headerBuf == null) {
+/* hit EOF */
 currEntry = null;
 return null;
 }
@@ -324,28 +325,27 @@ public class TarArchiveInputStream exten
  * over any remaining data in the current entry, if there
  * is one, and place the input stream at the header of the
  * next entry.
- * If there are no more entries in the archive, null will
- * be returned to indicate that the end of the archive has

svn commit: r869843 - in /websites/production/commons/content/proper/commons-compress: ./ apidocs/ apidocs/org/apache/commons/compress/archivers/ apidocs/org/apache/commons/compress/archivers/ar/ apid

2013-07-17 Thread bodewig
Author: bodewig
Date: Wed Jul 17 14:52:04 2013
New Revision: 869843

Log:
Update compress' site


[This commit notification would consist of 72 parts, 
which exceeds the limit of 50 ones, so it was shortened to the summary.]


svn commit: r1509356 - /commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/archivers/tar/BigFilesIT.java

2013-08-01 Thread bodewig
Author: bodewig
Date: Thu Aug  1 18:04:36 2013
New Revision: 1509356

URL: http://svn.apache.org/r1509356
Log:
buffer input and add a test that skips a large amount of bytes by winding 
forward to the end of the archive

Modified:

commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/archivers/tar/BigFilesIT.java

Modified: 
commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/archivers/tar/BigFilesIT.java
URL: 
http://svn.apache.org/viewvc/commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/archivers/tar/BigFilesIT.java?rev=1509356r1=1509355r2=1509356view=diff
==
--- 
commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/archivers/tar/BigFilesIT.java
 (original)
+++ 
commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/archivers/tar/BigFilesIT.java
 Thu Aug  1 18:04:36 2013
@@ -22,6 +22,8 @@ import static org.junit.Assert.assertEqu
 import static org.junit.Assert.assertNotNull;
 import static org.junit.Assert.assertNull;
 
+import java.io.BufferedInputStream;
+import java.io.InputStream;
 import java.util.Random;
 
 import org.apache.commons.compress.compressors.gzip.GzipCompressorInputStream;
@@ -39,14 +41,42 @@ public class BigFilesIT {
 readFileBiggerThan8GByte(/8.posix.tar.gz);
 }
 
+@Test
+public void readFileHeadersOfArchiveBiggerThan8GByte() throws Exception {
+InputStream in = null;
+GzipCompressorInputStream gzin = null;
+TarArchiveInputStream tin = null;
+try {
+in = new BufferedInputStream(BigFilesIT.class
+ 
.getResourceAsStream(/8.posix.tar.gz)
+ );
+gzin = new GzipCompressorInputStream(in);
+tin = new TarArchiveInputStream(gzin);
+TarArchiveEntry e = tin.getNextTarEntry();
+assertNotNull(e);
+assertNull(tin.getNextTarEntry());
+} finally {
+if (tin != null) {
+tin.close();
+}
+if (gzin != null) {
+gzin.close();
+}
+if (in != null) {
+in.close();
+}
+}
+}
+
 private void readFileBiggerThan8GByte(String name) throws Exception {
-GzipCompressorInputStream in = null;
+InputStream in = null;
+GzipCompressorInputStream gzin = null;
 TarArchiveInputStream tin = null;
 try {
-in =
-new GzipCompressorInputStream(BigFilesIT.class
-  .getResourceAsStream(name));
-tin = new TarArchiveInputStream(in);
+in = new BufferedInputStream(BigFilesIT.class
+ .getResourceAsStream(name));
+gzin = new GzipCompressorInputStream(in);
+tin = new TarArchiveInputStream(gzin);
 TarArchiveEntry e = tin.getNextTarEntry();
 assertNotNull(e);
 assertEquals(8200l * 1024 * 1024, e.getSize());
@@ -70,6 +100,9 @@ public class BigFilesIT {
 if (tin != null) {
 tin.close();
 }
+if (gzin != null) {
+gzin.close();
+}
 if (in != null) {
 in.close();
 }




svn commit: r1511806 - /commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/archivers/tar/TarArchiveOutputStreamTest.java

2013-08-08 Thread bodewig
Author: bodewig
Date: Thu Aug  8 14:33:06 2013
New Revision: 1511806

URL: http://svn.apache.org/r1511806
Log:
verify TarArchiveOutputStream is a well-behaving citizen and pads the output

Modified:

commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/archivers/tar/TarArchiveOutputStreamTest.java

Modified: 
commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/archivers/tar/TarArchiveOutputStreamTest.java
URL: 
http://svn.apache.org/viewvc/commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/archivers/tar/TarArchiveOutputStreamTest.java?rev=1511806r1=1511805r2=1511806view=diff
==
--- 
commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/archivers/tar/TarArchiveOutputStreamTest.java
 (original)
+++ 
commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/archivers/tar/TarArchiveOutputStreamTest.java
 Thu Aug  8 14:33:06 2013
@@ -32,6 +32,7 @@ import org.apache.commons.compress.Abstr
 import org.apache.commons.compress.archivers.ArchiveOutputStream;
 import org.apache.commons.compress.archivers.ArchiveStreamFactory;
 import org.apache.commons.compress.utils.CharsetNames;
+import org.apache.commons.compress.utils.IOUtils;
 
 public class TarArchiveOutputStreamTest extends AbstractTestCase {
 
@@ -467,4 +468,21 @@ public class TarArchiveOutputStreamTest 
 tin.close();
 }
 
+public void testPadsOutputToFullBlockLength() throws Exception {
+File f = File.createTempFile(commons-compress-padding, .tar);
+f.deleteOnExit();
+FileOutputStream fos = new FileOutputStream(f);
+TarArchiveOutputStream tos = new TarArchiveOutputStream(fos);
+File file1 = getFile(test1.xml);
+TarArchiveEntry sEntry = new TarArchiveEntry(file1);
+tos.putArchiveEntry(sEntry);
+FileInputStream in = new FileInputStream(file1);
+IOUtils.copy(in, tos);
+in.close();
+tos.closeArchiveEntry();
+tos.close();
+// test1.xml is small enough to fit into the default blockv size
+assertEquals(TarBuffer.DEFAULT_BLKSIZE, f.length());
+}
+
 }




svn commit: r1511843 - in /commons/proper/compress/trunk/src: changes/ main/java/org/apache/commons/compress/archivers/tar/ main/java/org/apache/commons/compress/utils/ test/java/org/apache/commons/co

2013-08-08 Thread bodewig
Author: bodewig
Date: Thu Aug  8 15:57:55 2013
New Revision: 1511843

URL: http://svn.apache.org/r1511843
Log:
COMPRESS-234 read/skip performance improvements to TarArchiveInputStream - 
patch by BELUGA BEHR

Removed:

commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/tar/TarBuffer.java
Modified:
commons/proper/compress/trunk/src/changes/changes.xml

commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/tar/TarArchiveInputStream.java

commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/tar/TarArchiveOutputStream.java

commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/tar/TarConstants.java

commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/utils/ArchiveUtils.java

commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/utils/IOUtils.java

commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/archivers/tar/TarArchiveInputStreamTest.java

commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/archivers/tar/TarArchiveOutputStreamTest.java

Modified: commons/proper/compress/trunk/src/changes/changes.xml
URL: 
http://svn.apache.org/viewvc/commons/proper/compress/trunk/src/changes/changes.xml?rev=1511843r1=1511842r2=1511843view=diff
==
--- commons/proper/compress/trunk/src/changes/changes.xml (original)
+++ commons/proper/compress/trunk/src/changes/changes.xml Thu Aug  8 15:57:55 
2013
@@ -80,9 +80,10 @@ The action type attribute can be add,u
   due-to=BELUGA BEHR
 Readabilty patch to TarArchiveInputStream.
   /action
-  action type=update date=2013-07-08 issue=COMPRESS-233
+  action type=update date=2013-07-08 issue=COMPRESS-234
   due-to=BELUGA BEHR
-Performance and readability patch to TarBuffer.
+Performance improvements to TarArchiveInputStream, in
+particular to the skip method.
   /action
 /release
 release version=1.5 date=2013-03-14

Modified: 
commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/tar/TarArchiveInputStream.java
URL: 
http://svn.apache.org/viewvc/commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/tar/TarArchiveInputStream.java?rev=1511843r1=1511842r2=1511843view=diff
==
--- 
commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/tar/TarArchiveInputStream.java
 (original)
+++ 
commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/tar/TarArchiveInputStream.java
 Thu Aug  8 15:57:55 2013
@@ -36,6 +36,7 @@ import org.apache.commons.compress.archi
 import org.apache.commons.compress.archivers.zip.ZipEncodingHelper;
 import org.apache.commons.compress.utils.ArchiveUtils;
 import org.apache.commons.compress.utils.CharsetNames;
+import org.apache.commons.compress.utils.IOUtils;
 
 /**
  * The TarInputStream reads a UNIX tar archive as an InputStream.
@@ -45,18 +46,33 @@ import org.apache.commons.compress.utils
  * @NotThreadSafe
  */
 public class TarArchiveInputStream extends ArchiveInputStream {
+
 private static final int SMALL_BUFFER_SIZE = 256;
-private static final int BUFFER_SIZE = 8 * 1024;
 
-private final byte[] SKIP_BUF = new byte[BUFFER_SIZE];
 private final byte[] SMALL_BUF = new byte[SMALL_BUFFER_SIZE];
 
+/** The size the TAR header */
+private final int recordSize;
+
+/** The size of a block */
+private final int blockSize;
+
+/** True if file has hit EOF */
 private boolean hasHitEOF;
+
+/** Size of the current entry */
 private long entrySize;
+
+/** How far into the entry the stream is at */
 private long entryOffset;
-private byte[] readBuf;
-protected final TarBuffer buffer;
+
+/** An input stream to read from */
+private final InputStream is;
+
+/** The meta-data about the current entry */
 private TarArchiveEntry currEntry;
+
+/** The encoding of the file */
 private final ZipEncoding encoding;
 
 /**
@@ -64,7 +80,7 @@ public class TarArchiveInputStream exten
  * @param is the input stream to use
  */
 public TarArchiveInputStream(InputStream is) {
-this(is, TarBuffer.DEFAULT_BLKSIZE, TarBuffer.DEFAULT_RCDSIZE);
+this(is, TarConstants.DEFAULT_BLKSIZE, TarConstants.DEFAULT_RCDSIZE);
 }
 
 /**
@@ -74,7 +90,8 @@ public class TarArchiveInputStream exten
  * @since 1.4
  */
 public TarArchiveInputStream(InputStream is, String encoding) {
-this(is, TarBuffer.DEFAULT_BLKSIZE, TarBuffer.DEFAULT_RCDSIZE, 
encoding);
+this(is, TarConstants.DEFAULT_BLKSIZE, TarConstants.DEFAULT_RCDSIZE,
+ encoding);
 }
 
 /**
@@ -83,7 +100,7 @@ public class

svn commit: r1511850 - in /commons/proper/compress/trunk/src: changes/ main/java/org/apache/commons/compress/archivers/cpio/ test/java/org/apache/commons/compress/archivers/cpio/ test/resources/

2013-08-08 Thread bodewig
Author: bodewig
Date: Thu Aug  8 16:18:45 2013
New Revision: 1511850

URL: http://svn.apache.org/r1511850
Log:
COMPRESS-236 - CpioArchiveInputStream doesn't like Redline RPM's archives.  
Patch by Andrew Duffy

Added:
commons/proper/compress/trunk/src/test/resources/redline.cpio   (with props)
Modified:
commons/proper/compress/trunk/src/changes/changes.xml

commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/cpio/CpioArchiveEntry.java

commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/cpio/CpioArchiveInputStream.java

commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/cpio/CpioUtil.java

commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/archivers/cpio/CpioArchiveInputStreamTest.java

Modified: commons/proper/compress/trunk/src/changes/changes.xml
URL: 
http://svn.apache.org/viewvc/commons/proper/compress/trunk/src/changes/changes.xml?rev=1511850r1=1511849r2=1511850view=diff
==
--- commons/proper/compress/trunk/src/changes/changes.xml (original)
+++ commons/proper/compress/trunk/src/changes/changes.xml Thu Aug  8 16:18:45 
2013
@@ -80,11 +80,16 @@ The action type attribute can be add,u
   due-to=BELUGA BEHR
 Readabilty patch to TarArchiveInputStream.
   /action
-  action type=update date=2013-07-08 issue=COMPRESS-234
+  action type=update date=2013-08-08 issue=COMPRESS-234
   due-to=BELUGA BEHR
 Performance improvements to TarArchiveInputStream, in
 particular to the skip method.
   /action
+  action type=fix date=2013-08-08 issue=COMPRESS-236
+  due-to=Andrew Duffy
+CpioArchiveInputStream failed to read archives created by
+Redline RPM.
+  /action
 /release
 release version=1.5 date=2013-03-14
  description=Release 1.5

Modified: 
commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/cpio/CpioArchiveEntry.java
URL: 
http://svn.apache.org/viewvc/commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/cpio/CpioArchiveEntry.java?rev=1511850r1=1511849r2=1511850view=diff
==
--- 
commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/cpio/CpioArchiveEntry.java
 (original)
+++ 
commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/cpio/CpioArchiveEntry.java
 Thu Aug  8 16:18:45 2013
@@ -596,7 +596,7 @@ public class CpioArchiveEntry implements
  * @return TRUE if this entry is a block device.
  */
 public boolean isBlockDevice() {
-return (this.mode  S_IFMT) == C_ISBLK;
+return CpioUtil.fileType(mode) == C_ISBLK;
 }
 
 /**
@@ -605,7 +605,7 @@ public class CpioArchiveEntry implements
  * @return TRUE if this entry is a character device.
  */
 public boolean isCharacterDevice() {
-return (this.mode  S_IFMT) == C_ISCHR;
+return CpioUtil.fileType(mode) == C_ISCHR;
 }
 
 /**
@@ -614,7 +614,7 @@ public class CpioArchiveEntry implements
  * @return TRUE if this entry is a directory.
  */
 public boolean isDirectory() {
-return (this.mode  S_IFMT) == C_ISDIR;
+return CpioUtil.fileType(mode) == C_ISDIR;
 }
 
 /**
@@ -623,7 +623,7 @@ public class CpioArchiveEntry implements
  * @return TRUE if this entry is a network device.
  */
 public boolean isNetwork() {
-return (this.mode  S_IFMT) == C_ISNWK;
+return CpioUtil.fileType(mode) == C_ISNWK;
 }
 
 /**
@@ -632,7 +632,7 @@ public class CpioArchiveEntry implements
  * @return TRUE if this entry is a pipe.
  */
 public boolean isPipe() {
-return (this.mode  S_IFMT) == C_ISFIFO;
+return CpioUtil.fileType(mode) == C_ISFIFO;
 }
 
 /**
@@ -641,7 +641,7 @@ public class CpioArchiveEntry implements
  * @return TRUE if this entry is a regular file.
  */
 public boolean isRegularFile() {
-return (this.mode  S_IFMT) == C_ISREG;
+return CpioUtil.fileType(mode) == C_ISREG;
 }
 
 /**
@@ -650,7 +650,7 @@ public class CpioArchiveEntry implements
  * @return TRUE if this entry is a socket.
  */
 public boolean isSocket() {
-return (this.mode  S_IFMT) == C_ISSOCK;
+return CpioUtil.fileType(mode) == C_ISSOCK;
 }
 
 /**
@@ -659,7 +659,7 @@ public class CpioArchiveEntry implements
  * @return TRUE if this entry is a symbolic link.
  */
 public boolean isSymbolicLink() {
-return (this.mode  S_IFMT) == C_ISLNK;
+return CpioUtil.fileType(mode) == C_ISLNK;
 }
 
 /**

Modified: 
commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/cpio/CpioArchiveInputStream.java
URL: 
http

svn commit: r1512161 - in /commons/proper/compress/trunk/src: changes/changes.xml main/java/org/apache/commons/compress/archivers/tar/TarArchiveOutputStream.java

2013-08-09 Thread bodewig
Author: bodewig
Date: Fri Aug  9 06:51:18 2013
New Revision: 1512161

URL: http://svn.apache.org/r1512161
Log:
COMPRESS-237 properly write TAR entries with long link names.  Patch by 
Emmanuel Bourg

Modified:
commons/proper/compress/trunk/src/changes/changes.xml

commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/tar/TarArchiveOutputStream.java

Modified: commons/proper/compress/trunk/src/changes/changes.xml
URL: 
http://svn.apache.org/viewvc/commons/proper/compress/trunk/src/changes/changes.xml?rev=1512161r1=1512160r2=1512161view=diff
==
--- commons/proper/compress/trunk/src/changes/changes.xml (original)
+++ commons/proper/compress/trunk/src/changes/changes.xml Fri Aug  9 06:51:18 
2013
@@ -90,6 +90,11 @@ The action type attribute can be add,u
 CpioArchiveInputStream failed to read archives created by
 Redline RPM.
   /action
+  action type=fix date=2013-08-09 issue=COMPRESS-237
+  due-to=Emmanuel Bourg
+TarArchiveOutputStream now properly handles link names that
+are too long to fit into a traditional TAR header.
+  /action
 /release
 release version=1.5 date=2013-03-14
  description=Release 1.5

Modified: 
commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/tar/TarArchiveOutputStream.java
URL: 
http://svn.apache.org/viewvc/commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/tar/TarArchiveOutputStream.java?rev=1512161r1=1512160r2=1512161view=diff
==
--- 
commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/tar/TarArchiveOutputStream.java
 (original)
+++ 
commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/tar/TarArchiveOutputStream.java
 Fri Aug  9 06:51:18 2013
@@ -271,31 +271,13 @@ public class TarArchiveOutputStream exte
 TarArchiveEntry entry = (TarArchiveEntry) archiveEntry;
 MapString, String paxHeaders = new HashMapString, String();
 final String entryName = entry.getName();
-final ByteBuffer encodedName = encoding.encode(entryName);
-final int nameLen = encodedName.limit() - encodedName.position();
-boolean paxHeaderContainsPath = false;
-if (nameLen = TarConstants.NAMELEN) {
+boolean paxHeaderContainsPath = handleLongName(entryName, paxHeaders, 
path,
+   
TarConstants.LF_GNUTYPE_LONGNAME);
 
-if (longFileMode == LONGFILE_POSIX) {
-paxHeaders.put(path, entryName);
-paxHeaderContainsPath = true;
-} else if (longFileMode == LONGFILE_GNU) {
-// create a TarEntry for the LongLink, the contents
-// of which are the entry's name
-TarArchiveEntry longLinkEntry = new 
TarArchiveEntry(TarConstants.GNU_LONGLINK,
-
TarConstants.LF_GNUTYPE_LONGNAME);
-
-longLinkEntry.setSize(nameLen + 1); // +1 for NUL
-putArchiveEntry(longLinkEntry);
-write(encodedName.array(), encodedName.arrayOffset(), nameLen);
-write(0); // NUL terminator
-closeArchiveEntry();
-} else if (longFileMode != LONGFILE_TRUNCATE) {
-throw new RuntimeException(file name ' + entryName
-   + ' is too long (  
-   + TarConstants.NAMELEN +  bytes));
-}
-}
+final String linkName = entry.getLinkName();
+boolean paxHeaderContainsLinkPath = linkName != null
+ handleLongName(linkName, paxHeaders, linkpath,
+  TarConstants.LF_GNUTYPE_LONGLINK);
 
 if (bigNumberMode == BIGNUMBER_POSIX) {
 addPaxHeadersForBigNumbers(paxHeaders, entry);
@@ -308,10 +290,10 @@ public class TarArchiveOutputStream exte
 paxHeaders.put(path, entryName);
 }
 
-if (addPaxHeadersForNonAsciiNames
+if (addPaxHeadersForNonAsciiNames  !paxHeaderContainsLinkPath
  (entry.isLink() || entry.isSymbolicLink())
- !ASCII.canEncode(entry.getLinkName())) {
-paxHeaders.put(linkpath, entry.getLinkName());
+ !ASCII.canEncode(linkName)) {
+paxHeaders.put(linkpath, linkName);
 }
 
 if (paxHeaders.size()  0) {
@@ -630,4 +612,54 @@ public class TarArchiveOutputStream exte
+ maxValue +  ));
 }
 }
+
+/**
+ * Handles long file or link names according to the longFileMode setting.
+ *
+ * pI.e. if the given name is too long to be written to a plain
+ * tar header then
+ * ul

svn commit: r1512183 - /commons/proper/compress/trunk/src/changes/changes.xml

2013-08-09 Thread bodewig
Author: bodewig
Date: Fri Aug  9 07:13:06 2013
New Revision: 1512183

URL: http://svn.apache.org/r1512183
Log:
typo

Modified:
commons/proper/compress/trunk/src/changes/changes.xml

Modified: commons/proper/compress/trunk/src/changes/changes.xml
URL: 
http://svn.apache.org/viewvc/commons/proper/compress/trunk/src/changes/changes.xml?rev=1512183r1=1512182r2=1512183view=diff
==
--- commons/proper/compress/trunk/src/changes/changes.xml (original)
+++ commons/proper/compress/trunk/src/changes/changes.xml Fri Aug  9 07:13:06 
2013
@@ -71,7 +71,7 @@ The action type attribute can be add,u
 name.
   /action
   action type=fix date=2013-06-04 issue=COMPRESS-227
-ZipFile#getInoutStream could return null if the archive
+ZipFile#getInputStream could return null if the archive
 contained duplicate entries.
 The class now also provides two new methods to obtain all
 entries of a given name rather than just the first one.




svn commit: r1512789 - in /commons/proper/compress/trunk/src: changes/ main/java/org/apache/commons/compress/archivers/ main/java/org/apache/commons/compress/archivers/dump/ main/java/org/apache/commo

2013-08-10 Thread bodewig
Author: bodewig
Date: Sat Aug 10 16:22:49 2013
New Revision: 1512789

URL: http://svn.apache.org/r1512789
Log:
Add encoding support to DumpArchiveInputStream - related to COMPRESS-180

Modified:
commons/proper/compress/trunk/src/changes/changes.xml

commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/ArchiveStreamFactory.java

commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/dump/DumpArchiveInputStream.java

commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/dump/DumpArchiveSummary.java

commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/dump/DumpArchiveUtil.java

commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/sevenz/SevenZFile.java

commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/tar/TarUtils.java

Modified: commons/proper/compress/trunk/src/changes/changes.xml
URL: 
http://svn.apache.org/viewvc/commons/proper/compress/trunk/src/changes/changes.xml?rev=1512789r1=1512788r2=1512789view=diff
==
--- commons/proper/compress/trunk/src/changes/changes.xml (original)
+++ commons/proper/compress/trunk/src/changes/changes.xml Sat Aug 10 16:22:49 
2013
@@ -95,6 +95,10 @@ The action type attribute can be add,u
 TarArchiveOutputStream now properly handles link names that
 are too long to fit into a traditional TAR header.
   /action
+  action type=add date=2013-08-10
+DumpArchiveInputStream now supports an encoding parameter that
+can be used to specify the default encoding of file names.
+  /action
 /release
 release version=1.5 date=2013-03-14
  description=Release 1.5

Modified: 
commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/ArchiveStreamFactory.java
URL: 
http://svn.apache.org/viewvc/commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/ArchiveStreamFactory.java?rev=1512789r1=1512788r2=1512789view=diff
==
--- 
commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/ArchiveStreamFactory.java
 (original)
+++ 
commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/ArchiveStreamFactory.java
 Sat Aug 10 16:22:49 2013
@@ -116,7 +116,7 @@ public class ArchiveStreamFactory {
 private String entryEncoding = null;
 
 /**
- * Returns the encoding to use for arj, zip and tar files,
+ * Returns the encoding to use for arj, zip, dump and tar files,
  * or null for the default.
  *
  * @return entry encoding, or null
@@ -127,8 +127,8 @@ public class ArchiveStreamFactory {
 }
 
 /**
- * Sets the encoding to use for arj, zip and tar files.
- * Use null for the default.
+ * Sets the encoding to use for arj, zip, dump and tar files.  Use
+ * null for the default.
  *
  * @since 1.5
  */
@@ -188,7 +188,11 @@ public class ArchiveStreamFactory {
 return new CpioArchiveInputStream(in);
 }
 if (DUMP.equalsIgnoreCase(archiverName)) {
-return new DumpArchiveInputStream(in);
+if (entryEncoding != null) {
+return new DumpArchiveInputStream(in, entryEncoding);
+} else {
+return new DumpArchiveInputStream(in);
+}
 }
 
 throw new ArchiveException(Archiver:  + archiverName +  not 
found.);

Modified: 
commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/dump/DumpArchiveInputStream.java
URL: 
http://svn.apache.org/viewvc/commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/dump/DumpArchiveInputStream.java?rev=1512789r1=1512788r2=1512789view=diff
==
--- 
commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/dump/DumpArchiveInputStream.java
 (original)
+++ 
commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/dump/DumpArchiveInputStream.java
 Sat Aug 10 16:22:49 2013
@@ -20,6 +20,8 @@ package org.apache.commons.compress.arch
 
 import org.apache.commons.compress.archivers.ArchiveException;
 import org.apache.commons.compress.archivers.ArchiveInputStream;
+import org.apache.commons.compress.archivers.zip.ZipEncoding;
+import org.apache.commons.compress.archivers.zip.ZipEncodingHelper;
 
 import java.io.EOFException;
 import java.io.IOException;
@@ -39,6 +41,11 @@ import java.util.Stack;
  * the archive, and the read each entry as a normal input stream
  * using read().
  *
+ * There doesn't seem to exist a hint on the encoding of string values
+ * in any piece documentation.  Given the main purpose of dump/restore
+ * is backing up

svn commit: r1512804 - in /commons/proper/compress/trunk/src: changes/ main/java/org/apache/commons/compress/archivers/ main/java/org/apache/commons/compress/archivers/cpio/ main/java/org/apache/commo

2013-08-10 Thread bodewig
Author: bodewig
Date: Sat Aug 10 17:04:41 2013
New Revision: 1512804

URL: http://svn.apache.org/r1512804
Log:
Add encoding support to CPIO package - related to COMPRESS-180

Modified:
commons/proper/compress/trunk/src/changes/changes.xml

commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/ArchiveStreamFactory.java

commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/cpio/CpioArchiveInputStream.java

commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/cpio/CpioArchiveOutputStream.java

commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/utils/ArchiveUtils.java

Modified: commons/proper/compress/trunk/src/changes/changes.xml
URL: 
http://svn.apache.org/viewvc/commons/proper/compress/trunk/src/changes/changes.xml?rev=1512804r1=1512803r2=1512804view=diff
==
--- commons/proper/compress/trunk/src/changes/changes.xml (original)
+++ commons/proper/compress/trunk/src/changes/changes.xml Sat Aug 10 17:04:41 
2013
@@ -97,7 +97,11 @@ The action type attribute can be add,u
   /action
   action type=add date=2013-08-10
 DumpArchiveInputStream now supports an encoding parameter that
-can be used to specify the default encoding of file names.
+can be used to specify the encoding of file names.
+  /action
+  action type=add date=2013-08-10
+The CPIO streams now support an encoding parameter that can be
+used to specify the encoding of file names.
   /action
 /release
 release version=1.5 date=2013-03-14

Modified: 
commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/ArchiveStreamFactory.java
URL: 
http://svn.apache.org/viewvc/commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/ArchiveStreamFactory.java?rev=1512804r1=1512803r2=1512804view=diff
==
--- 
commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/ArchiveStreamFactory.java
 (original)
+++ 
commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/ArchiveStreamFactory.java
 Sat Aug 10 17:04:41 2013
@@ -116,8 +116,8 @@ public class ArchiveStreamFactory {
 private String entryEncoding = null;
 
 /**
- * Returns the encoding to use for arj, zip, dump and tar files,
- * or null for the default.
+ * Returns the encoding to use for arj, zip, dump, cpio and tar
+ * files, or null for the default.
  *
  * @return entry encoding, or null
  * @since 1.5
@@ -127,8 +127,8 @@ public class ArchiveStreamFactory {
 }
 
 /**
- * Sets the encoding to use for arj, zip, dump and tar files.  Use
- * null for the default.
+ * Sets the encoding to use for arj, zip, dump, cpio and tar
+ * files.  Use null for the default.
  *
  * @since 1.5
  */
@@ -185,7 +185,11 @@ public class ArchiveStreamFactory {
 return new JarArchiveInputStream(in);
 }
 if (CPIO.equalsIgnoreCase(archiverName)) {
-return new CpioArchiveInputStream(in);
+if (entryEncoding != null) {
+return new CpioArchiveInputStream(in, entryEncoding);
+} else {
+return new CpioArchiveInputStream(in);
+}
 }
 if (DUMP.equalsIgnoreCase(archiverName)) {
 if (entryEncoding != null) {
@@ -238,7 +242,11 @@ public class ArchiveStreamFactory {
 return new JarArchiveOutputStream(out);
 }
 if (CPIO.equalsIgnoreCase(archiverName)) {
-return new CpioArchiveOutputStream(out);
+if (entryEncoding != null) {
+return new CpioArchiveOutputStream(out, entryEncoding);
+} else {
+return new CpioArchiveOutputStream(out);
+}
 }
 throw new ArchiveException(Archiver:  + archiverName +  not 
found.);
 }

Modified: 
commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/cpio/CpioArchiveInputStream.java
URL: 
http://svn.apache.org/viewvc/commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/cpio/CpioArchiveInputStream.java?rev=1512804r1=1512803r2=1512804view=diff
==
--- 
commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/cpio/CpioArchiveInputStream.java
 (original)
+++ 
commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/cpio/CpioArchiveInputStream.java
 Sat Aug 10 17:04:41 2013
@@ -24,7 +24,10 @@ import java.io.InputStream;
 
 import org.apache.commons.compress.archivers.ArchiveEntry;
 import org.apache.commons.compress.archivers.ArchiveInputStream;
+import

svn commit: r1515039 - /commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/arj/ArjArchiveInputStream.java

2013-08-17 Thread bodewig
Author: bodewig
Date: Sat Aug 17 19:46:10 2013
New Revision: 1515039

URL: http://svn.apache.org/r1515039
Log:
count bytes read in ArjArchiveInputStream

Modified:

commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/arj/ArjArchiveInputStream.java

Modified: 
commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/arj/ArjArchiveInputStream.java
URL: 
http://svn.apache.org/viewvc/commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/arj/ArjArchiveInputStream.java?rev=1515039r1=1515038r2=1515039view=diff
==
--- 
commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/arj/ArjArchiveInputStream.java
 (original)
+++ 
commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/arj/ArjArchiveInputStream.java
 Sat Aug 17 19:46:10 2013
@@ -95,10 +95,23 @@ public class ArjArchiveInputStream exten
 System.out.println(message);
 }
 
-private static int read16(final DataInputStream in) throws IOException {
+private int read8(final DataInputStream in) throws IOException {
+int value = in.readUnsignedByte();
+count(1);
+return value;
+}
+
+private int read16(final DataInputStream in) throws IOException {
 final int value = in.readUnsignedShort();
+count(2);
 return Integer.reverseBytes(value)  16;
 }
+
+private int read32(final DataInputStream in) throws IOException {
+final int value = in.readInt();
+count(4);
+return Integer.reverseBytes(value);
+}
 
 private String readString(final DataInputStream in) throws IOException {
 final ByteArrayOutputStream buffer = new ByteArrayOutputStream();
@@ -109,15 +122,21 @@ public class ArjArchiveInputStream exten
 return new String(buffer.toByteArray(), charset);
 }
 
+private void readFully(final DataInputStream in, byte[] b)
+throws IOException {
+in.readFully(b);
+count(b.length);
+}
+
 private byte[] readHeader() throws IOException {
 boolean found = false;
 byte[] basicHeaderBytes = null;
 do {
 int first = 0;
-int second = in.readUnsignedByte();
+int second = read8(in);
 do {
 first = second;
-second = in.readUnsignedByte();
+second = read8(in);
 } while (first != ARJ_MAGIC_1  second != ARJ_MAGIC_2);
 final int basicHeaderSize = read16(in);
 if (basicHeaderSize == 0) {
@@ -126,8 +145,8 @@ public class ArjArchiveInputStream exten
 }
 if (basicHeaderSize = 2600) {
 basicHeaderBytes = new byte[basicHeaderSize];
-in.readFully(basicHeaderBytes);
-final int basicHeaderCrc32 = 
Integer.reverseBytes(in.readInt());
+readFully(in, basicHeaderBytes);
+final int basicHeaderCrc32 = read32(in);
 final CRC32 crc32 = new CRC32();
 crc32.update(basicHeaderBytes);
 if (basicHeaderCrc32 == (int)crc32.getValue()) {
@@ -160,12 +179,13 @@ public class ArjArchiveInputStream exten
 mainHeader.securityVersion = firstHeader.readUnsignedByte();
 mainHeader.fileType = firstHeader.readUnsignedByte();
 mainHeader.reserved = firstHeader.readUnsignedByte();
-mainHeader.dateTimeCreated = 
Integer.reverseBytes(firstHeader.readInt());
-mainHeader.dateTimeModified = 
Integer.reverseBytes(firstHeader.readInt());
-mainHeader.archiveSize = 0xL  
Integer.reverseBytes(firstHeader.readInt());
-mainHeader.securityEnvelopeFilePosition = 
Integer.reverseBytes(firstHeader.readInt());
+mainHeader.dateTimeCreated = read32(firstHeader);
+mainHeader.dateTimeModified = read32(firstHeader);
+mainHeader.archiveSize = 0xL  read32(firstHeader);
+mainHeader.securityEnvelopeFilePosition = read32(firstHeader);
 mainHeader.fileSpecPosition = read16(firstHeader);
 mainHeader.securityEnvelopeLength = read16(firstHeader);
+pushedBackBytes(20); // count has already counted them via readFully
 mainHeader.encryptionVersion = firstHeader.readUnsignedByte();
 mainHeader.lastChapter = firstHeader.readUnsignedByte();
 
@@ -183,8 +203,8 @@ public class ArjArchiveInputStream exten
 final  int extendedHeaderSize = read16(in);
 if (extendedHeaderSize  0) {
 mainHeader.extendedHeaderBytes = new byte[extendedHeaderSize];
-in.readFully(mainHeader.extendedHeaderBytes);
-final int extendedHeaderCrc32 = Integer.reverseBytes(in.readInt());
+readFully(in, mainHeader.extendedHeaderBytes);
+final int extendedHeaderCrc32 = read32

svn commit: r1515041 - /commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/arj/ArjArchiveEntry.java

2013-08-17 Thread bodewig
Author: bodewig
Date: Sat Aug 17 20:15:27 2013
New Revision: 1515041

URL: http://svn.apache.org/r1515041
Log:
the constants will be far more useful when public

Modified:

commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/arj/ArjArchiveEntry.java

Modified: 
commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/arj/ArjArchiveEntry.java
URL: 
http://svn.apache.org/viewvc/commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/arj/ArjArchiveEntry.java?rev=1515041r1=1515040r2=1515041view=diff
==
--- 
commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/arj/ArjArchiveEntry.java
 (original)
+++ 
commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/arj/ArjArchiveEntry.java
 Sat Aug 17 20:15:27 2013
@@ -92,18 +92,18 @@ public class ArjArchiveEntry implements 
  * The known values for HostOs.
  */
 public static class HostOs {
-static final int DOS = 0;
-static final int PRIMOS = 1;
-static final int UNIX = 2;
-static final int AMIGA = 3;
-static final int MAC_OS = 4;
-static final int OS_2 = 5;
-static final int APPLE_GS = 6;
-static final int ATARI_ST = 7;
-static final int NEXT = 8;
-static final int VAX_VMS = 9;
-static final int WIN95 = 10;
-static final int WIN32 = 11;
+public static final int DOS = 0;
+public static final int PRIMOS = 1;
+public static final int UNIX = 2;
+public static final int AMIGA = 3;
+public static final int MAC_OS = 4;
+public static final int OS_2 = 5;
+public static final int APPLE_GS = 6;
+public static final int ATARI_ST = 7;
+public static final int NEXT = 8;
+public static final int VAX_VMS = 9;
+public static final int WIN95 = 10;
+public static final int WIN32 = 11;
 }
 
 }




svn commit: r1517177 - /commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/arj/ArjArchiveInputStream.java

2013-08-24 Thread bodewig
Author: bodewig
Date: Sat Aug 24 18:25:16 2013
New Revision: 1517177

URL: http://svn.apache.org/r1517177
Log:
allow null-charset for platform's default encoding in arj

Modified:

commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/arj/ArjArchiveInputStream.java

Modified: 
commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/arj/ArjArchiveInputStream.java
URL: 
http://svn.apache.org/viewvc/commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/arj/ArjArchiveInputStream.java?rev=1517177r1=1517176r2=1517177view=diff
==
--- 
commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/arj/ArjArchiveInputStream.java
 (original)
+++ 
commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/arj/ArjArchiveInputStream.java
 Sat Aug 24 18:25:16 2013
@@ -119,7 +119,11 @@ public class ArjArchiveInputStream exten
 while ((nextByte = in.readUnsignedByte()) != 0) {
 buffer.write(nextByte);
 }
-return new String(buffer.toByteArray(), charset);
+if (charset != null) {
+return new String(buffer.toByteArray(), charset);
+} else {
+return new String(buffer.toByteArray());
+}
 }
 
 private void readFully(final DataInputStream in, byte[] b)




svn commit: r1525353 - in /commons/proper/compress/trunk: ./ src/changes/ src/main/java/org/apache/commons/compress/archivers/sevenz/ src/main/java/org/apache/commons/compress/archivers/tar/ src/main/

2013-09-22 Thread bodewig
Author: bodewig
Date: Sun Sep 22 13:09:29 2013
New Revision: 1525353

URL: http://svn.apache.org/r1525353
Log:
XZ for Java 1.4 has been released, merge the LZMA branch.

Added:

commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/compressors/lzma/
  - copied from r1525352, 
commons/proper/compress/branches/LZMA/src/main/java/org/apache/commons/compress/compressors/lzma/

commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/compressors/LZMATestCase.java
  - copied unchanged from r1525352, 
commons/proper/compress/branches/LZMA/src/test/java/org/apache/commons/compress/compressors/LZMATestCase.java
commons/proper/compress/trunk/src/test/resources/bla.7z
  - copied unchanged from r1525352, 
commons/proper/compress/branches/LZMA/src/test/resources/bla.7z
commons/proper/compress/trunk/src/test/resources/bla.tar.lzma
  - copied unchanged from r1525352, 
commons/proper/compress/branches/LZMA/src/test/resources/bla.tar.lzma
Modified:
commons/proper/compress/trunk/   (props changed)
commons/proper/compress/trunk/pom.xml
commons/proper/compress/trunk/src/changes/changes.xml

commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/sevenz/Coders.java

commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/tar/
   (props changed)

commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/zip/
   (props changed)

commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/compressors/CompressorStreamFactory.java
commons/proper/compress/trunk/src/site/xdoc/examples.xml
commons/proper/compress/trunk/src/site/xdoc/index.xml

commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/archivers/sevenz/SevenZFileTest.java

Propchange: commons/proper/compress/trunk/
--
  Merged /commons/proper/compress/branches/LZMA:r1491183-1525352

Modified: commons/proper/compress/trunk/pom.xml
URL: 
http://svn.apache.org/viewvc/commons/proper/compress/trunk/pom.xml?rev=1525353r1=1525352r2=1525353view=diff
==
--- commons/proper/compress/trunk/pom.xml (original)
+++ commons/proper/compress/trunk/pom.xml Sun Sep 22 13:09:29 2013
@@ -60,7 +60,7 @@ These include: bzip2, gzip, pack200, xz 
 dependency
   groupIdorg.tukaani/groupId
   artifactIdxz/artifactId
-  version1.3/version
+  version1.4/version
 /dependency
   /dependencies
 

Modified: commons/proper/compress/trunk/src/changes/changes.xml
URL: 
http://svn.apache.org/viewvc/commons/proper/compress/trunk/src/changes/changes.xml?rev=1525353r1=1525352r2=1525353view=diff
==
--- commons/proper/compress/trunk/src/changes/changes.xml (original)
+++ commons/proper/compress/trunk/src/changes/changes.xml Sun Sep 22 13:09:29 
2013
@@ -51,8 +51,7 @@ The action type attribute can be add,u
   /action
   action type=add date=2013-05-07 issue=COMPRESS-54
   due-to=Damjan Jovanovic
-Added read-only support for 7z archives that don't use
-LZMA compression.
+Added support for 7z archives.
   /action
   action type=add date=2013-05-19 issue=COMPRESS-226
   due-to=Damjan Jovanovic

Modified: 
commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/sevenz/Coders.java
URL: 
http://svn.apache.org/viewvc/commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/sevenz/Coders.java?rev=1525353r1=1525352r2=1525353view=diff
==
--- 
commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/sevenz/Coders.java
 (original)
+++ 
commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/sevenz/Coders.java
 Sun Sep 22 13:09:29 2013
@@ -31,6 +31,7 @@ import javax.crypto.spec.IvParameterSpec
 import javax.crypto.spec.SecretKeySpec;
 
 import 
org.apache.commons.compress.compressors.bzip2.BZip2CompressorInputStream;
+import org.tukaani.xz.LZMAInputStream;
 import org.tukaani.xz.LZMA2InputStream;
 
 class Coders {
@@ -47,6 +48,7 @@ class Coders {
 
 static CoderId[] coderTable = new CoderId[] {
 new CoderId(new byte[] { (byte)0x00 }, new CopyDecoder()),
+new CoderId(new byte[] { (byte)0x03, (byte)0x01, (byte)0x01 }, new 
LZMADecoder()),
 new CoderId(new byte[] { (byte)0x21 }, new LZMA2Decoder()),
 // FIXME: gives corrupt output
 //new CoderId(new byte[] { (byte)0x04, (byte)0x01, (byte)0x08 }, new 
DeflateDecoder()),
@@ -98,6 +100,22 @@ class Coders {
 }
 }
 
+static class LZMADecoder extends CoderBase {
+@Override
+InputStream decode(final InputStream

svn commit: r1525354 - /commons/proper/compress/branches/LZMA/

2013-09-22 Thread bodewig
Author: bodewig
Date: Sun Sep 22 13:11:02 2013
New Revision: 1525354

URL: http://svn.apache.org/r1525354
Log:
LZMA branch has been merged to trunk

Removed:
commons/proper/compress/branches/LZMA/



svn commit: r1527032 - /commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/sevenz/SevenZFile.java

2013-09-27 Thread bodewig
Author: bodewig
Date: Fri Sep 27 19:02:38 2013
New Revision: 1527032

URL: http://svn.apache.org/r1527032
Log:
note on 7z's limitations is outdated

Modified:

commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/sevenz/SevenZFile.java

Modified: 
commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/sevenz/SevenZFile.java
URL: 
http://svn.apache.org/viewvc/commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/sevenz/SevenZFile.java?rev=1527032r1=1527031r2=1527032view=diff
==
--- 
commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/sevenz/SevenZFile.java
 (original)
+++ 
commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/sevenz/SevenZFile.java
 Fri Sep 27 19:02:38 2013
@@ -39,16 +39,8 @@ import org.apache.commons.compress.utils
  * The 7z file format is a flexible container
  * that can contain many compression and
  * encryption types, but at the moment only
- * only Copy, LZMA2, BZIP2, and AES-256 + SHA-256
- * are supported, and archive header compression
- * (when it uses the unsupported LZMA
- * compression) isn't. So the only archives
- * that can be read are the following:
- * pre
- * 7z a -mhc=off [-mhe=on] -mx=0 [-ppassword] archive.7z files
- * 7z a -mhc=off [-mhe=on] -m0=LZMA2 [-ppassword] archive.7z files
- * 7z a -mhc=off [-mhe=on] -m0=BZIP2 [-ppassword] archive.7z files
- * /pre
+ * only Copy, LZMA, LZMA2, BZIP2, and AES-256 + SHA-256
+ * are supported.
  * p
  * The format is very Windows/Intel specific,
  * so it uses little-endian byte order,




svn commit: r1527270 - in /commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/sevenz: SevenZArchiveEntry.java SevenZOutputFile.java

2013-09-28 Thread bodewig
Author: bodewig
Date: Sun Sep 29 05:06:12 2013
New Revision: 1527270

URL: http://svn.apache.org/r1527270
Log:
simplify has*Date handling in SevenZEntry

Modified:

commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/sevenz/SevenZArchiveEntry.java

commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/sevenz/SevenZOutputFile.java

Modified: 
commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/sevenz/SevenZArchiveEntry.java
URL: 
http://svn.apache.org/viewvc/commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/sevenz/SevenZArchiveEntry.java?rev=1527270r1=1527269r2=1527270view=diff
==
--- 
commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/sevenz/SevenZArchiveEntry.java
 (original)
+++ 
commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/sevenz/SevenZArchiveEntry.java
 Sun Sep 29 05:06:12 2013
@@ -112,6 +112,7 @@ public class SevenZArchiveEntry implemen
 }
 
 public void setCreationDate(Date creationDate) {
+hasCreationDate = creationDate != null;
 this.creationDate = javaTimeToNtfsTime(creationDate);
 }
 
@@ -137,6 +138,7 @@ public class SevenZArchiveEntry implemen
 }
 
 public void setLastModifiedDate(Date lastModifiedDate) {
+hasLastModifiedDate = lastModifiedDate != null;
 this.lastModifiedDate = javaTimeToNtfsTime(lastModifiedDate);
 }
 
@@ -162,6 +164,7 @@ public class SevenZArchiveEntry implemen
 }
 
 public void setAccessDate(Date accessDate) {
+hasAccessDate = accessDate != null;
 this.accessDate = javaTimeToNtfsTime(accessDate);
 }
 

Modified: 
commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/sevenz/SevenZOutputFile.java
URL: 
http://svn.apache.org/viewvc/commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/sevenz/SevenZOutputFile.java?rev=1527270r1=1527269r2=1527270view=diff
==
--- 
commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/sevenz/SevenZOutputFile.java
 (original)
+++ 
commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/sevenz/SevenZOutputFile.java
 Sun Sep 29 05:06:12 2013
@@ -62,7 +62,6 @@ public class SevenZOutputFile {
 final SevenZArchiveEntry entry = new SevenZArchiveEntry();
 entry.setDirectory(inputFile.isDirectory());
 entry.setName(entryName);
-entry.setHasLastModifiedDate(true);
 entry.setLastModifiedDate(new Date(inputFile.lastModified()));
 return entry;
 }




svn commit: r1527274 - /commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/sevenz/SevenZFile.java

2013-09-28 Thread bodewig
Author: bodewig
Date: Sun Sep 29 05:52:52 2013
New Revision: 1527274

URL: http://svn.apache.org/r1527274
Log:
an archive without folders may skip CodersInfo

Modified:

commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/sevenz/SevenZFile.java

Modified: 
commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/sevenz/SevenZFile.java
URL: 
http://svn.apache.org/viewvc/commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/sevenz/SevenZFile.java?rev=1527274r1=1527273r2=1527274view=diff
==
--- 
commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/sevenz/SevenZFile.java
 (original)
+++ 
commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/sevenz/SevenZFile.java
 Sun Sep 29 05:52:52 2013
@@ -309,6 +309,9 @@ public class SevenZFile {
 if (nid == NID.kUnpackInfo) {
 readUnpackInfo(header, archive);
 nid = header.readUnsignedByte();
+} else {
+// archive without unpack/coders info
+archive.folders = new Folder[0];
 }
 
 if (nid == NID.kSubStreamsInfo) {




svn commit: r1527276 - in /commons/proper/compress/trunk/src: changes/changes.xml site/xdoc/examples.xml site/xdoc/index.xml

2013-09-29 Thread bodewig
Author: bodewig
Date: Sun Sep 29 06:35:11 2013
New Revision: 1527276

URL: http://svn.apache.org/r1527276
Log:
properly document the current level of support provided for 7z

Modified:
commons/proper/compress/trunk/src/changes/changes.xml
commons/proper/compress/trunk/src/site/xdoc/examples.xml
commons/proper/compress/trunk/src/site/xdoc/index.xml

Modified: commons/proper/compress/trunk/src/changes/changes.xml
URL: 
http://svn.apache.org/viewvc/commons/proper/compress/trunk/src/changes/changes.xml?rev=1527276r1=1527275r2=1527276view=diff
==
--- commons/proper/compress/trunk/src/changes/changes.xml (original)
+++ commons/proper/compress/trunk/src/changes/changes.xml Sun Sep 29 06:35:11 
2013
@@ -51,7 +51,8 @@ The action type attribute can be add,u
   /action
   action type=add date=2013-05-07 issue=COMPRESS-54
   due-to=Damjan Jovanovic
-Added support for 7z archives.
+Added support for 7z archives.  Most compression algorithms
+can be read, but only uncompressed archives can be written.
   /action
   action type=add date=2013-05-19 issue=COMPRESS-226
   due-to=Damjan Jovanovic
@@ -102,6 +103,9 @@ The action type attribute can be add,u
 The CPIO streams now support an encoding parameter that can be
 used to specify the encoding of file names.
   /action
+  action type=fix date=2013-09-22 issue=COMPRESS-111
+Read-only support for LZMA standalone compression has been added.
+  /action
 /release
 release version=1.5 date=2013-03-14
  description=Release 1.5

Modified: commons/proper/compress/trunk/src/site/xdoc/examples.xml
URL: 
http://svn.apache.org/viewvc/commons/proper/compress/trunk/src/site/xdoc/examples.xml?rev=1527276r1=1527275r2=1527276view=diff
==
--- commons/proper/compress/trunk/src/site/xdoc/examples.xml (original)
+++ commons/proper/compress/trunk/src/site/xdoc/examples.xml Sun Sep 29 
06:35:11 2013
@@ -31,13 +31,16 @@
 collect multiple entries inside a single (potentially
 compressed) archive are archiver formats./p
 
-pThe compressor formats supported are gzip, bzip2, xz, lzma and
-Pack200, the archiver formats are ar, cpio, tar and zip as
-well as dump, 7z and arj for which we currently only support
-reading.  Pack200 is a special case as it can only compress
-JAR files./p
-
-pWe currently only provide read support for lzma as well./p
+pThe compressor formats supported are gzip, bzip2, xz, lzma
+and Pack200, the archiver formats are 7z, ar, arj, cpio, dump,
+tar and zip.  Pack200 is a special case as it can only
+compress JAR files./p
+
+pWe currently only provide read support for lzma, arj and
+dump.  arj can only read uncompressed archives, 7z can read
+archives with many compression and encryption algorithms
+supported by 7z but can only write uncompressed and
+unencrypted archives./p
   /subsection
 
   subsection name=Common Notes
@@ -458,9 +461,10 @@ lzmaIn.close();
   subsection name=7z
 
 pNote that Commons Compress currently only supports
-uncompressed entries or entries compressed using BZIP2 or
-LZMA2 and no header compression at all.  Only AES-256/SHA-256
-are supported for encryption./p
+a subset of compression and encryption algorithms used for 7z
+archives.  For reading only uncompressed entries of LZMA,
+LZMA2, BZIP2 and AES-256/SHA-256 are supported.  Only
+uncompressed and unencrypted archives can be written./p
 
 pAdding an entry to a 7z archive:/p
 source![CDATA[

Modified: commons/proper/compress/trunk/src/site/xdoc/index.xml
URL: 
http://svn.apache.org/viewvc/commons/proper/compress/trunk/src/site/xdoc/index.xml?rev=1527276r1=1527275r2=1527276view=diff
==
--- commons/proper/compress/trunk/src/site/xdoc/index.xml (original)
+++ commons/proper/compress/trunk/src/site/xdoc/index.xml Sun Sep 29 06:35:11 
2013
@@ -78,7 +78,10 @@
 implementation provides capabilities that go beyond the
 features found in java.util.zip.  As of Commons Compress
 1.6 support for the dump and arj formats is
-read-only./p
+read-only - 7z can read most compressed and encrypted
+archives but only write uncompressed ones.  LZMA(2) supprt
+in 7z requires a href=http://tukaani.org/xz/java.html;XZ for
+Java/a as well./p
 
   pThe compress component provides abstract base classes for
 compressors and archivers together with factories that can




svn commit: r1529157 - in /commons/proper/compress/trunk/src/main/java/org/apache/commons/compress: archivers/cpio/CpioArchiveInputStream.java archivers/dump/TapeInputStream.java archivers/zip/ZipArch

2013-10-04 Thread bodewig
Author: bodewig
Date: Fri Oct  4 13:17:32 2013
New Revision: 1529157

URL: http://svn.apache.org/r1529157
Log:
one readFully method to rule them all

Modified:

commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/cpio/CpioArchiveInputStream.java

commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/dump/TapeInputStream.java

commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/zip/ZipArchiveInputStream.java

commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/utils/IOUtils.java

Modified: 
commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/cpio/CpioArchiveInputStream.java
URL: 
http://svn.apache.org/viewvc/commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/cpio/CpioArchiveInputStream.java?rev=1529157r1=1529156r2=1529157view=diff
==
--- 
commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/cpio/CpioArchiveInputStream.java
 (original)
+++ 
commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/cpio/CpioArchiveInputStream.java
 Fri Oct  4 13:17:32 2013
@@ -28,6 +28,7 @@ import org.apache.commons.compress.archi
 import org.apache.commons.compress.archivers.zip.ZipEncodingHelper;
 import org.apache.commons.compress.utils.ArchiveUtils;
 import org.apache.commons.compress.utils.CharsetNames;
+import org.apache.commons.compress.utils.IOUtils;
 
 /**
  * CPIOArchiveInputStream is a stream for reading cpio streams. All formats of
@@ -330,19 +331,12 @@ public class CpioArchiveInputStream exte
 
 private final int readFully(final byte[] b, final int off, final int len)
 throws IOException {
-if (len  0) {
-throw new IndexOutOfBoundsException();
-}
-int n = 0;
-while (n  len) {
-int count = this.in.read(b, off + n, len - n);
-count(count);
-if (count  0) {
-throw new EOFException();
-}
-n += count;
+int count = IOUtils.readFully(in, b, off, len);
+count(count);
+if (count  len) {
+throw new EOFException();
 }
-return n;
+return count;
 }
 
 private long readBinaryLong(final int length, final boolean swapHalfWord)

Modified: 
commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/dump/TapeInputStream.java
URL: 
http://svn.apache.org/viewvc/commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/dump/TapeInputStream.java?rev=1529157r1=1529156r2=1529157view=diff
==
--- 
commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/dump/TapeInputStream.java
 (original)
+++ 
commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/dump/TapeInputStream.java
 Fri Oct  4 13:17:32 2013
@@ -26,6 +26,7 @@ import java.util.Arrays;
 import java.util.zip.DataFormatException;
 import java.util.zip.Inflater;
 
+import org.apache.commons.compress.utils.IOUtils;
 
 /**
  * Filter stream that mimics a physical tape drive capable of compressing
@@ -333,16 +334,9 @@ class TapeInputStream extends FilterInpu
  */
 private boolean readFully(byte[] b, int off, int len)
 throws IOException {
-int count = 0;
-
-while (count  len) {
-int n = in.read(b, off + count, len - count);
-
-if (n == -1) {
-throw new ShortFileException();
-}
-
-count += n;
+int count = IOUtils.readFully(in, b, off, len);
+if (count  len) {
+throw new ShortFileException();
 }
 
 return true;

Modified: 
commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/zip/ZipArchiveInputStream.java
URL: 
http://svn.apache.org/viewvc/commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/zip/ZipArchiveInputStream.java?rev=1529157r1=1529156r2=1529157view=diff
==
--- 
commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/zip/ZipArchiveInputStream.java
 (original)
+++ 
commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/zip/ZipArchiveInputStream.java
 Fri Oct  4 13:17:32 2013
@@ -32,6 +32,7 @@ import java.util.zip.ZipException;
 
 import org.apache.commons.compress.archivers.ArchiveEntry;
 import org.apache.commons.compress.archivers.ArchiveInputStream;
+import org.apache.commons.compress.utils.IOUtils;
 
 import static org.apache.commons.compress.archivers.zip.ZipConstants.DWORD;
 import static org.apache.commons.compress.archivers.zip.ZipConstants.SHORT;
@@ -674,13 +675,10

svn commit: r1529159 - in /commons/proper/compress/trunk/src: changes/changes.xml main/java/org/apache/commons/compress/archivers/ArchiveStreamFactory.java main/java/org/apache/commons/compress/compre

2013-10-04 Thread bodewig
Author: bodewig
Date: Fri Oct  4 13:25:44 2013
New Revision: 1529159

URL: http://svn.apache.org/r1529159
Log:
allow format-detection to deal with blocking inputs - COMPRESS-239

Modified:
commons/proper/compress/trunk/src/changes/changes.xml

commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/ArchiveStreamFactory.java

commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/compressors/CompressorStreamFactory.java

Modified: commons/proper/compress/trunk/src/changes/changes.xml
URL: 
http://svn.apache.org/viewvc/commons/proper/compress/trunk/src/changes/changes.xml?rev=1529159r1=1529158r2=1529159view=diff
==
--- commons/proper/compress/trunk/src/changes/changes.xml (original)
+++ commons/proper/compress/trunk/src/changes/changes.xml Fri Oct  4 13:25:44 
2013
@@ -106,6 +106,11 @@ The action type attribute can be add,u
   action type=fix date=2013-09-22 issue=COMPRESS-111
 Read-only support for LZMA standalone compression has been added.
   /action
+  action type=fix date=2013-10-04 issue=COMPRESS-239
+The auto-detecting create*InputStream methods of Archive and
+CompressorStreamFactory could fail to detect the format of
+blocking input stream.
+  /action
 /release
 release version=1.5 date=2013-03-14
  description=Release 1.5

Modified: 
commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/ArchiveStreamFactory.java
URL: 
http://svn.apache.org/viewvc/commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/ArchiveStreamFactory.java?rev=1529159r1=1529158r2=1529159view=diff
==
--- 
commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/ArchiveStreamFactory.java
 (original)
+++ 
commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/ArchiveStreamFactory.java
 Fri Oct  4 13:25:44 2013
@@ -35,6 +35,7 @@ import org.apache.commons.compress.archi
 import org.apache.commons.compress.archivers.tar.TarArchiveOutputStream;
 import org.apache.commons.compress.archivers.zip.ZipArchiveInputStream;
 import org.apache.commons.compress.archivers.zip.ZipArchiveOutputStream;
+import org.apache.commons.compress.utils.IOUtils;
 
 /**
  * Factory to create Archive[In|Out]putStreams from names or the first bytes of
@@ -274,7 +275,7 @@ public class ArchiveStreamFactory {
 final byte[] signature = new byte[12];
 in.mark(signature.length);
 try {
-int signatureLength = in.read(signature);
+int signatureLength = IOUtils.readFully(in, signature);
 in.reset();
 if (ZipArchiveInputStream.matches(signature, signatureLength)) {
 if (entryEncoding != null) {
@@ -295,7 +296,7 @@ public class ArchiveStreamFactory {
 // Dump needs a bigger buffer to check the signature;
 final byte[] dumpsig = new byte[32];
 in.mark(dumpsig.length);
-signatureLength = in.read(dumpsig);
+signatureLength = IOUtils.readFully(in, dumpsig);
 in.reset();
 if (DumpArchiveInputStream.matches(dumpsig, signatureLength)) {
 return new DumpArchiveInputStream(in);
@@ -304,7 +305,7 @@ public class ArchiveStreamFactory {
 // Tar needs an even bigger buffer to check the signature; read 
the first block
 final byte[] tarheader = new byte[512];
 in.mark(tarheader.length);
-signatureLength = in.read(tarheader);
+signatureLength = IOUtils.readFully(in, tarheader);
 in.reset();
 if (TarArchiveInputStream.matches(tarheader, signatureLength)) {
 if (entryEncoding != null) {

Modified: 
commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/compressors/CompressorStreamFactory.java
URL: 
http://svn.apache.org/viewvc/commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/compressors/CompressorStreamFactory.java?rev=1529159r1=1529158r2=1529159view=diff
==
--- 
commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/compressors/CompressorStreamFactory.java
 (original)
+++ 
commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/compressors/CompressorStreamFactory.java
 Fri Oct  4 13:25:44 2013
@@ -32,6 +32,7 @@ import org.apache.commons.compress.compr
 import org.apache.commons.compress.compressors.xz.XZUtils;
 import 
org.apache.commons.compress.compressors.pack200.Pack200CompressorInputStream;
 import 
org.apache.commons.compress.compressors.pack200.Pack200CompressorOutputStream;
+import org.apache.commons.compress.utils.IOUtils;
 
 /**
  * pFactory to create Compressor[In|Out

svn commit: r1529202 - in /commons/proper/compress/trunk/src: main/java/org/apache/commons/compress/archivers/sevenz/Coders.java test/java/org/apache/commons/compress/archivers/sevenz/SevenZFileTest.j

2013-10-04 Thread bodewig
Author: bodewig
Date: Fri Oct  4 16:07:23 2013
New Revision: 1529202

URL: http://svn.apache.org/r1529202
Log:
deflate support when reading 7Z archives

Added:
commons/proper/compress/trunk/src/test/resources/bla.deflate.7z   (with 
props)
Modified:

commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/sevenz/Coders.java

commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/archivers/sevenz/SevenZFileTest.java

Modified: 
commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/sevenz/Coders.java
URL: 
http://svn.apache.org/viewvc/commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/sevenz/Coders.java?rev=1529202r1=1529201r2=1529202view=diff
==
--- 
commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/sevenz/Coders.java
 (original)
+++ 
commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/sevenz/Coders.java
 Fri Oct  4 16:07:23 2013
@@ -17,12 +17,15 @@
  */
 package org.apache.commons.compress.archivers.sevenz;
 
+import java.io.FilterInputStream;
 import java.io.IOException;
 import java.io.InputStream;
 import java.security.GeneralSecurityException;
 import java.security.MessageDigest;
 import java.security.NoSuchAlgorithmException;
 import java.util.Arrays;
+import java.util.zip.Inflater;
+import java.util.zip.InflaterInputStream;
 
 import javax.crypto.Cipher;
 import javax.crypto.CipherInputStream;
@@ -50,8 +53,7 @@ class Coders {
 new CoderId(new byte[] { (byte)0x00 }, new CopyDecoder()),
 new CoderId(new byte[] { (byte)0x03, (byte)0x01, (byte)0x01 }, new 
LZMADecoder()),
 new CoderId(new byte[] { (byte)0x21 }, new LZMA2Decoder()),
-// FIXME: gives corrupt output
-//new CoderId(new byte[] { (byte)0x04, (byte)0x01, (byte)0x08 }, new 
DeflateDecoder()),
+new CoderId(new byte[] { (byte)0x04, (byte)0x01, (byte)0x08 }, new 
DeflateDecoder()),
 new CoderId(new byte[] { (byte)0x04, (byte)0x02, (byte)0x02 }, new 
BZIP2Decoder()),
 new CoderId(new byte[] { (byte)0x06, (byte)0xf1, (byte)0x07, 
(byte)0x01 }, new AES256SHA256Decoder())
 };
@@ -116,15 +118,14 @@ class Coders {
 }
 }
 
-//static class DeflateDecoder extends CoderBase {
-//@Override
-//InputStream decode(final InputStream in, final Coder coder, final 
String password)
-//throws IOException {
-//System.out.println(deflate prop count =  + (coder.properties 
== null ? -1 : coder.properties.length));
-//return new DeflaterInputStream(in, new 
Deflater(Deflater.DEFAULT_COMPRESSION, true));
-////return new GZIPInputStream(in);
-//}
-//}
+static class DeflateDecoder extends CoderBase {
+@Override
+InputStream decode(final InputStream in, final Coder coder, final 
String password)
+throws IOException {
+return new InflaterInputStream(new DummyByteAddingInputStream(in),
+   new Inflater(true));
+}
+}
 
 static class BZIP2Decoder extends CoderBase {
 @Override
@@ -232,4 +233,39 @@ class Coders {
 };
 }
 }
+
+/**
+ * ZLIB requires an extra dummy byte.
+ *
+ * @see java.util.zip.Inflater#Inflater(boolean)
+ * @see 
org.apache.commons.compress.archivers.zip.ZipFile.BoundedInputStream
+ */
+private static class DummyByteAddingInputStream extends FilterInputStream {
+private boolean addDummyByte = true;
+
+private DummyByteAddingInputStream(InputStream in) {
+super(in);
+}
+
+@Override
+public int read() throws IOException {
+int result = super.read();
+if (result == -1  addDummyByte) {
+addDummyByte = false;
+result = 0;
+}
+return result;
+}
+
+@Override
+public int read(byte[] b, int off, int len) throws IOException {
+int result = super.read(b, off, len);
+if (result == -1  addDummyByte) {
+addDummyByte = false;
+b[off] = 0;
+return 1;
+}
+return result;
+}
+}
 }

Modified: 
commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/archivers/sevenz/SevenZFileTest.java
URL: 
http://svn.apache.org/viewvc/commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/archivers/sevenz/SevenZFileTest.java?rev=1529202r1=1529201r2=1529202view=diff
==
--- 
commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/archivers/sevenz/SevenZFileTest.java
 (original)
+++ 
commons/proper/compress/trunk/src/test/java/org/apache/commons

svn commit: r1529388 - in /commons/proper/compress/trunk/src: main/java/org/apache/commons/compress/archivers/sevenz/SevenZFile.java site/xdoc/examples.xml site/xdoc/index.xml

2013-10-04 Thread bodewig
Author: bodewig
Date: Sat Oct  5 05:25:51 2013
New Revision: 1529388

URL: http://svn.apache.org/r1529388
Log:
record Deflate support

Modified:

commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/sevenz/SevenZFile.java
commons/proper/compress/trunk/src/site/xdoc/examples.xml
commons/proper/compress/trunk/src/site/xdoc/index.xml

Modified: 
commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/sevenz/SevenZFile.java
URL: 
http://svn.apache.org/viewvc/commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/sevenz/SevenZFile.java?rev=1529388r1=1529387r2=1529388view=diff
==
--- 
commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/sevenz/SevenZFile.java
 (original)
+++ 
commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/sevenz/SevenZFile.java
 Sat Oct  5 05:25:51 2013
@@ -39,7 +39,7 @@ import org.apache.commons.compress.utils
  * The 7z file format is a flexible container
  * that can contain many compression and
  * encryption types, but at the moment only
- * only Copy, LZMA, LZMA2, BZIP2, and AES-256 + SHA-256
+ * only Copy, LZMA, LZMA2, BZIP2, Deflate and AES-256 + SHA-256
  * are supported.
  * p
  * The format is very Windows/Intel specific,
@@ -270,30 +270,6 @@ public class SevenZFile {
 nextHeaderInputStream.close();
 }
 return new DataInputStream(new ByteArrayInputStream(nextHeader));
-
-
-//throw new IOException(LZMA compression unsupported, so files with 
compressed header cannot be read);
-// FIXME: this extracts the header to an LZMA file which can then be
-// manually decompressed.
-//long offset = SIGNATURE_HEADER_SIZE + archive.packPos;
-//file.seek(offset);
-//long unpackSize = archive.folders[0].getUnpackSize();
-//byte[] packed = new byte[(int)archive.packSizes[0]];
-//file.readFully(packed);
-//
-//FileOutputStream fos = new FileOutputStream(new 
File(/tmp/encodedHeader.7z));
-//fos.write(archive.folders[0].coders[0].properties);
-//// size - assuming  256
-//fos.write((int)(unpackSize  0xff));
-//fos.write(0);
-//fos.write(0);
-//fos.write(0);
-//fos.write(0);
-//fos.write(0);
-//fos.write(0);
-//fos.write(0);
-//fos.write(packed);
-//fos.close();
 }
 
 private void readStreamsInfo(final DataInput header, final Archive 
archive) throws IOException {

Modified: commons/proper/compress/trunk/src/site/xdoc/examples.xml
URL: 
http://svn.apache.org/viewvc/commons/proper/compress/trunk/src/site/xdoc/examples.xml?rev=1529388r1=1529387r2=1529388view=diff
==
--- commons/proper/compress/trunk/src/site/xdoc/examples.xml (original)
+++ commons/proper/compress/trunk/src/site/xdoc/examples.xml Sat Oct  5 
05:25:51 2013
@@ -462,8 +462,8 @@ lzmaIn.close();
 
 pNote that Commons Compress currently only supports
 a subset of compression and encryption algorithms used for 7z
-archives.  For reading only uncompressed entries of LZMA,
-LZMA2, BZIP2 and AES-256/SHA-256 are supported.  Only
+archives.  For reading only uncompressed entries or LZMA,
+LZMA2, BZIP2, Deflate and AES-256/SHA-256 are supported.  Only
 uncompressed and unencrypted archives can be written./p
 
 pAdding an entry to a 7z archive:/p

Modified: commons/proper/compress/trunk/src/site/xdoc/index.xml
URL: 
http://svn.apache.org/viewvc/commons/proper/compress/trunk/src/site/xdoc/index.xml?rev=1529388r1=1529387r2=1529388view=diff
==
--- commons/proper/compress/trunk/src/site/xdoc/index.xml (original)
+++ commons/proper/compress/trunk/src/site/xdoc/index.xml Sat Oct  5 05:25:51 
2013
@@ -79,7 +79,7 @@
 features found in java.util.zip.  As of Commons Compress
 1.6 support for the dump and arj formats is
 read-only - 7z can read most compressed and encrypted
-archives but only write uncompressed ones.  LZMA(2) supprt
+archives but only write uncompressed ones.  LZMA(2) support
 in 7z requires a href=http://tukaani.org/xz/java.html;XZ for
 Java/a as well./p
 




svn commit: r1529645 - /commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/zip/ZipUtil.java

2013-10-06 Thread bodewig
Author: bodewig
Date: Sun Oct  6 16:55:44 2013
New Revision: 1529645

URL: http://svn.apache.org/r1529645
Log:
DOS time for ZIP/ARJ never stores milliseconds (it is at two second granularity)

Modified:

commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/zip/ZipUtil.java

Modified: 
commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/zip/ZipUtil.java
URL: 
http://svn.apache.org/viewvc/commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/zip/ZipUtil.java?rev=1529645r1=1529644r2=1529645view=diff
==
--- 
commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/zip/ZipUtil.java
 (original)
+++ 
commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/zip/ZipUtil.java
 Sun Oct  6 16:55:44 2013
@@ -200,6 +200,7 @@ public abstract class ZipUtil {
 cal.set(Calendar.HOUR_OF_DAY, (int) (dosTime  11)  0x1f);
 cal.set(Calendar.MINUTE, (int) (dosTime  5)  0x3f);
 cal.set(Calendar.SECOND, (int) (dosTime  1)  0x3e);
+cal.set(Calendar.MILLISECOND, 0);
 // CheckStyle:MagicNumberCheck ON
 return cal.getTime().getTime();
 }




svn commit: r1529665 - /commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/arj/ArjArchiveEntry.java

2013-10-06 Thread bodewig
Author: bodewig
Date: Sun Oct  6 18:46:45 2013
New Revision: 1529665

URL: http://svn.apache.org/r1529665
Log:
arj stores date in seconds since epoch on Unix

Modified:

commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/arj/ArjArchiveEntry.java

Modified: 
commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/arj/ArjArchiveEntry.java
URL: 
http://svn.apache.org/viewvc/commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/arj/ArjArchiveEntry.java?rev=1529665r1=1529664r2=1529665view=diff
==
--- 
commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/arj/ArjArchiveEntry.java
 (original)
+++ 
commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/arj/ArjArchiveEntry.java
 Sun Oct  6 18:46:45 2013
@@ -58,8 +58,9 @@ public class ArjArchiveEntry implements 
 }
 
 public Date getLastModifiedDate() {
-return new Date(ZipUtil.dosToJavaTime(
-0xL  localFileHeader.dateTimeModified));
+long ts = isHostOsUnix() ? (localFileHeader.dateTimeModified * 1000l)
+: ZipUtil.dosToJavaTime(0xL  
localFileHeader.dateTimeModified);
+return new Date(ts);
 }
 
 /**
@@ -77,7 +78,7 @@ public class ArjArchiveEntry implements 
  * pWill only be non-zero of the host os was UNIX.
  */
 public int getUnixMode() {
-return getHostOs() == HostOs.UNIX ? getMode() : 0;
+return isHostOsUnix() ? getMode() : 0;
 }
 
 /**
@@ -89,6 +90,14 @@ public class ArjArchiveEntry implements 
 }
 
 /**
+ * Is the operating system the archive has been created on one
+ * that is considered a UNIX OS by arj?
+ */
+public boolean isHostOsUnix() {
+return getHostOs() == HostOs.UNIX || getHostOs() == HostOs.NEXT;
+}
+
+/**
  * The known values for HostOs.
  */
 public static class HostOs {




svn commit: r881476 - in /websites/production/commons/content/proper/commons-compress: ./ apidocs/ apidocs/org/apache/commons/compress/archivers/ apidocs/org/apache/commons/compress/archivers/ar/ apid

2013-10-06 Thread bodewig
Author: bodewig
Date: Sun Oct  6 19:57:46 2013
New Revision: 881476

Log:
update compress site


[This commit notification would consist of 118 parts, 
which exceeds the limit of 50 ones, so it was shortened to the summary.]


svn commit: r1529673 - in /commons/proper/compress/trunk/src: main/java/org/apache/commons/compress/archivers/cpio/ main/java/org/apache/commons/compress/archivers/tar/ test/java/org/apache/commons/co

2013-10-06 Thread bodewig
Author: bodewig
Date: Sun Oct  6 20:03:08 2013
New Revision: 1529673

URL: http://svn.apache.org/r1529673
Log:
backwards incompatible changes

Modified:

commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/cpio/CpioArchiveInputStream.java

commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/tar/TarArchiveInputStream.java

commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/archivers/cpio/CpioArchiveInputStreamTest.java

Modified: 
commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/cpio/CpioArchiveInputStream.java
URL: 
http://svn.apache.org/viewvc/commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/cpio/CpioArchiveInputStream.java?rev=1529673r1=1529672r2=1529673view=diff
==
--- 
commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/cpio/CpioArchiveInputStream.java
 (original)
+++ 
commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/cpio/CpioArchiveInputStream.java
 Sun Oct  6 20:03:08 2013
@@ -484,7 +484,7 @@ public class CpioArchiveInputStream exte
 }
 
 @Override
-public CpioArchiveEntry getNextEntry() throws IOException {
+public ArchiveEntry getNextEntry() throws IOException {
 return getNextCPIOEntry();
 }
 

Modified: 
commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/tar/TarArchiveInputStream.java
URL: 
http://svn.apache.org/viewvc/commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/tar/TarArchiveInputStream.java?rev=1529673r1=1529672r2=1529673view=diff
==
--- 
commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/tar/TarArchiveInputStream.java
 (original)
+++ 
commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/tar/TarArchiveInputStream.java
 Sun Oct  6 20:03:08 2013
@@ -606,7 +606,7 @@ public class TarArchiveInputStream exten
  * 
  * @return The current Archive Entry
  */
-public ArchiveEntry getCurrentEntry() {
+public TarArchiveEntry getCurrentEntry() {
 return currEntry;
 }
 

Modified: 
commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/archivers/cpio/CpioArchiveInputStreamTest.java
URL: 
http://svn.apache.org/viewvc/commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/archivers/cpio/CpioArchiveInputStreamTest.java?rev=1529673r1=1529672r2=1529673view=diff
==
--- 
commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/archivers/cpio/CpioArchiveInputStreamTest.java
 (original)
+++ 
commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/archivers/cpio/CpioArchiveInputStreamTest.java
 Sun Oct  6 20:03:08 2013
@@ -35,7 +35,7 @@ public class CpioArchiveInputStreamTest 
 CpioArchiveEntry entry;
 
 StringBuilder result = new StringBuilder();
-while ((entry = in.getNextEntry()) != null) {
+while ((entry = (CpioArchiveEntry) in.getNextEntry()) != null) {
 result.append(entry.getName());
 int tmp;
 while ((tmp = in.read()) != -1) {




<    1   2   3   4   5   6   7   8   9   10   >