commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bode...@apache.org
Subject svn commit: r1571434 - in /commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/sevenz: Folder.java SevenZFile.java
Date Mon, 24 Feb 2014 20:53:23 GMT
Author: bodewig
Date: Mon Feb 24 20:53:23 2014
New Revision: 1571434

URL: http://svn.apache.org/r1571434
Log:
wire multiple codecs by the specified binding pairs rather than relying on order

Modified:
    commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/sevenz/Folder.java
    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/Folder.java
URL: http://svn.apache.org/viewvc/commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/sevenz/Folder.java?rev=1571434&r1=1571433&r2=1571434&view=diff
==============================================================================
--- commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/sevenz/Folder.java
(original)
+++ commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/sevenz/Folder.java
Mon Feb 24 20:53:23 2014
@@ -17,6 +17,8 @@
  */
 package org.apache.commons.compress.archivers.sevenz;
 
+import java.util.LinkedList;
+
 /**
  * The unit of solid compression.
  */
@@ -41,6 +43,23 @@ class Folder {
     /// The number of unpack substreams, one per non-empty file in this folder.
     int numUnpackSubStreams;
 
+    /**
+     * Sorts Coders using bind pairs.
+     * <p>The first coder reads from the packed stream (we currently
+     * only support single input stream decoders), the second reads
+     * from the output of the first and so on.</p>
+     */
+    Iterable<Coder> getOrderedCoders() {
+        LinkedList<Coder> l = new LinkedList<Coder>();
+        int current = (int) packedStreams[0]; // more that 2^31 coders?
+        while (current != -1) {
+            l.addLast(coders[current]);
+            int pair = findBindPairForOutStream(current);
+            current = pair != -1 ? (int) bindPairs[pair].inIndex : -1;
+        }
+        return l;
+    }
+
     int findBindPairForInStream(final int index) {
         for (int i = 0; i < bindPairs.length; i++) {
             if (bindPairs[i].inIndex == index) {

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=1571434&r1=1571433&r2=1571434&view=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
Mon Feb 24 20:53:23 2014
@@ -271,7 +271,7 @@ public class SevenZFile implements Close
         file.seek(folderOffset);
         InputStream inputStreamStack = new BoundedRandomAccessFileInputStream(file,
                 archive.packSizes[firstPackStreamIndex]);
-        for (final Coder coder : folder.coders) {
+        for (final Coder coder : folder.getOrderedCoders()) {
             if (coder.numInStreams != 1 || coder.numOutStreams != 1) {
                 throw new IOException("Multi input/output stream coders are not yet supported");
             }
@@ -842,7 +842,7 @@ public class SevenZFile implements Close
         file.seek(folderOffset);
         InputStream inputStreamStack = new BoundedRandomAccessFileInputStream(file,
                 archive.packSizes[firstPackStreamIndex]);
-        for (final Coder coder : folder.coders) {
+        for (final Coder coder : folder.getOrderedCoders()) {
             if (coder.numInStreams != 1 || coder.numOutStreams != 1) {
                 throw new IOException("Multi input/output stream coders are not yet supported");
             }



Mime
View raw message