commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From krosenv...@apache.org
Subject svn commit: r1646532 - in /commons/proper/compress/trunk/src: main/java/org/apache/commons/compress/archivers/zip/ZipArchiveOutputStream.java test/java/org/apache/commons/compress/archivers/ZipTestCase.java
Date Thu, 18 Dec 2014 20:58:00 GMT
Author: krosenvold
Date: Thu Dec 18 20:58:00 2014
New Revision: 1646532

URL: http://svn.apache.org/r1646532
Log:
COMPRESS-296 Parallel compression. Add support for cloning ZipArchiveOutputStream

With these changes it is possible to realize parallel compression. There is one more class
coming that coordinates it all

Modified:
    commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/zip/ZipArchiveOutputStream.java
    commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/archivers/ZipTestCase.java

Modified: commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/zip/ZipArchiveOutputStream.java
URL: http://svn.apache.org/viewvc/commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/zip/ZipArchiveOutputStream.java?rev=1646532&r1=1646531&r2=1646532&view=diff
==============================================================================
--- commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/zip/ZipArchiveOutputStream.java
(original)
+++ commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/zip/ZipArchiveOutputStream.java
Thu Dec 18 20:58:00 2014
@@ -505,6 +505,24 @@ public class ZipArchiveOutputStream exte
     }
 
     /**
+     * Make a copy of this stream with all its settings, but point to a new file.
+     * Used for scatter/gather operations to make several streams from a user-supplied master.
+     *
+     * @param newFile The file to use for the copy of this stream
+     * @return A copy of this stream
+     */
+    public ZipArchiveOutputStream cloneWith(File newFile) throws IOException {
+        ZipArchiveOutputStream zos = new ZipArchiveOutputStream(newFile);
+        zos.setCreateUnicodeExtraFields(createUnicodeExtraFields);
+        zos.setMethod(method);
+        zos.setEncoding(encoding);
+        zos.setFallbackToUTF8(fallbackToUTF8);
+        zos.setUseLanguageEncodingFlag(useUTF8Flag);
+        zos.setUseZip64(zip64Mode);
+        return zos;
+    }
+
+    /**
      * Ensures all bytes sent to the deflater are written to the stream.
      */
     private void flushDeflater() throws IOException {

Modified: commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/archivers/ZipTestCase.java
URL: http://svn.apache.org/viewvc/commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/archivers/ZipTestCase.java?rev=1646532&r1=1646531&r2=1646532&view=diff
==============================================================================
--- commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/archivers/ZipTestCase.java
(original)
+++ commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/archivers/ZipTestCase.java
Thu Dec 18 20:58:00 2014
@@ -294,6 +294,18 @@ public final class ZipTestCase extends A
     };
 
 
+    public void testCloneZipOutputStream( ) throws IOException {
+        File tempDir = createTempDir();
+        File fred = new File(tempDir, "fred");
+        ZipArchiveOutputStream zipArchiveOutputStream = new ZipArchiveOutputStream(fred);
+        File frank = new File(tempDir, "frank");
+        ZipArchiveOutputStream actual = zipArchiveOutputStream.cloneWith(frank);
+        zipArchiveOutputStream.close();
+        actual.close();
+        assertTrue( fred.exists());
+        assertTrue( frank.exists());
+    }
+
     public void testCopyRawEntriesFromFile
             ()
             throws IOException {



Mime
View raw message