svn commit: r759143 [1/2] - /commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/compressors/bzip2/BZip2CompressorOutputStream.java
Author: bodewig Date: Fri Mar 27 14:14:07 2009 New Revision: 759143 URL: http://svn.apache.org/viewvc?rev=759143view=rev Log: Improve bzip2 creation speed, submitted by Rodrigo Schmidt to Ant, COMPRESS-58 Modified: commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/compressors/bzip2/BZip2CompressorOutputStream.java
svn commit: r759195 - in /commons/proper/compress/trunk/src/main/java/org/apache/commons/compress: archivers/ archivers/ar/ archivers/cpio/ archivers/jar/ archivers/tar/ archivers/zip/ changes/ compre
Author: bodewig Date: Fri Mar 27 16:21:56 2009 New Revision: 759195 URL: http://svn.apache.org/viewvc?rev=759195view=rev Log: minimal package level javadocs Added: commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/ar/package.html (with props) commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/cpio/package.html (with props) commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/jar/package.html (with props) commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/package.html (with props) commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/tar/package.html (with props) commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/zip/package.html (with props) commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/changes/package.html (with props) commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/compressors/bzip2/package.html (with props) commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/compressors/gzip/package.html (with props) commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/compressors/package.html (with props) commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/utils/package.html (with props) Added: commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/ar/package.html URL: http://svn.apache.org/viewvc/commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/ar/package.html?rev=759195view=auto == --- commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/ar/package.html (added) +++ commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/ar/package.html Fri Mar 27 16:21:56 2009 @@ -0,0 +1,24 @@ +html +!-- + + 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. + +-- + body +pProvides stream classes for reading and writing archives using + the AR format./p + /body +/html Propchange: commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/ar/package.html -- svn:eol-style = native Added: commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/cpio/package.html URL: http://svn.apache.org/viewvc/commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/cpio/package.html?rev=759195view=auto == --- commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/cpio/package.html (added) +++ commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/cpio/package.html Fri Mar 27 16:21:56 2009 @@ -0,0 +1,24 @@ +html +!-- + + 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. + +-- + body +pProvides stream classes for reading and writing archives using + the CPIO format./p + /body +/html Propchange: commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/cpio/package.html -- svn:eol-style = native Added
svn commit: r759200 - /commons/proper/compress/trunk/src/site/xdoc/index.xml
Author: bodewig Date: Fri Mar 27 16:30:59 2009 New Revision: 759200 URL: http://svn.apache.org/viewvc?rev=759200view=rev Log: remove links to broken examples, update the documentation a little, fix link to svn Modified: commons/proper/compress/trunk/src/site/xdoc/index.xml 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=759200r1=759199r2=759200view=diff == --- commons/proper/compress/trunk/src/site/xdoc/index.xml (original) +++ commons/proper/compress/trunk/src/site/xdoc/index.xml Fri Mar 27 16:30:59 2009 @@ -25,45 +25,47 @@ body section name=Commons Compress p -Commons Compress defines an API for working with tar, zip and bzip2 files. +Commons Compress defines an API for working with ar, +cpio, tar, zip, gzip and bzip2 files. /p p -The code in this component came from Avalon's Excalibur, but originally from Ant, -as far as life in Apache goes. The tar package is originally Tim Endres' public -domain package. The bzip2 package is based on the work done by Keiron Liddle. -It has migrated via:br/ -Ant -gt; Avalon-Excalibur -gt; Commons-IO -gt; Commons-Compress. +The code in this component has many origins: /p +ul + liThe bzip2, tar and zip support came from Avalon's +Excalibur, but originally from Ant, as far as life in +Apache goes. The tar package is originally Tim Endres' +public domain package. The bzip2 package is based on +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 +and +the a href=http://jrpm.sourceforge.net/;jRPM/a +project/li. +/ul subsection name=Status -ul -liThis component has been promoted to Commons proper/li -liThe code is unreleased/li -liMethods and classes can and will appear and disappear without warning/li -liIf you like the code and want to push it towards a release, join the mailing list!/li -/ul + ul +liThis component has been promoted to Commons proper/li +liThe code is unreleased/li +liMethods and classes can and will appear and +disappear without warning/li +liIf you like the code and want to push it towards a +release, join the mailing list!/li + /ul /subsection /section section name=Documentation -ul -liThe a href=apidocs/index.htmlJavadoc/a of the latest SVN/li -liThe a href=http://svn.apache.org/viewvc/commons/compress/;SVN repository/a can be browsed./li -/ul -p -There are also 2 example for the bzip2 API: -/p -ul -li -a href=xref-test/org/apache/commons/compress/bzip2/example/Bzip2Compress.htmlBzip2Compress/a -/li -li -a href=xref-test/org/apache/commons/compress/bzip2/example/Bzip2Uncompress.htmlBzip2UnCompress/a -/li + ul +liThe a href=apidocs/index.htmlJavadoc/a of the latest SVN/li +liThe a href=http://svn.apache.org/viewvc/commons/proper/compress/;SVN +repository/a can be browsed./li /ul /section section name=Releases -p -None. -/p + p +None. + /p /section /body /document
svn commit: r759472 - in /commons/proper/compress/trunk/src/site: site.xml xdoc/examples.xml xdoc/index.xml xdoc/zip.xml
Author: bodewig Date: Sat Mar 28 14:46:32 2009 New Revision: 759472 URL: http://svn.apache.org/viewvc?rev=759472view=rev Log: some more in depth documentation Added: commons/proper/compress/trunk/src/site/xdoc/examples.xml (with props) commons/proper/compress/trunk/src/site/xdoc/zip.xml (with props) Modified: commons/proper/compress/trunk/src/site/site.xml commons/proper/compress/trunk/src/site/xdoc/index.xml Modified: commons/proper/compress/trunk/src/site/site.xml URL: http://svn.apache.org/viewvc/commons/proper/compress/trunk/src/site/site.xml?rev=759472r1=759471r2=759472view=diff == --- commons/proper/compress/trunk/src/site/site.xml (original) +++ commons/proper/compress/trunk/src/site/site.xml Sat Mar 28 14:46:32 2009 @@ -28,6 +28,7 @@ body menu name=Compress item name=Overviewhref=/index.html/ + item name=Exampleshref=/examples.html/ item name=Issue Tracking href=/issue-tracking.html/ item name=Downloadhref=/downloads.html/ item name=Wikihref=http://wiki.apache.org/commons/Compress/ Added: 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=759472view=auto == --- commons/proper/compress/trunk/src/site/xdoc/examples.xml (added) +++ commons/proper/compress/trunk/src/site/xdoc/examples.xml Sat Mar 28 14:46:32 2009 @@ -0,0 +1,279 @@ +?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 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. + +-- +document + properties +titleCommons Compress Examples/title +author email=d...@commons.apache.orgCommons Documentation Team/author + /properties + body +section name=Examples + + subsection name=Factories + +pCompress provides factory methods to create input/output + streams based on the names of the compressor or archiver + format as well as factory methods that try to guess the + format of an input stream./p + +pTo create a compressor writing to a given output by using + the algorithm name:/p +source![CDATA[ +CompressorOutputStream gzippedOut = new CompressorStreamFactory() +.createCompressorOutputStream(gz, myOutputStream); +]]/source + +pMake the factory guess the input format for a given stream:/p +source![CDATA[ +ArchiveInputStream input = new ArchiveStreamFactory() +.createArchiveInputStream(originalInput); +]]/source + + /subsection + + subsection name=ar + +pIn addition to the information stored + in codeArchiveEntry/code a codeArArchiveEntry/code + stores information about the owner user and group as well as + Unix permissions./p + +pAdding an entry to an ar archive:/p +source![CDATA[ +ArArchiveEntry entry = new ArArchiveEntry(name, size); +arOutput.putNextEntry(entry); +arOutput.write(contentOfEntry); +arOutput.closeArchiveEntry(); +]]/source + +pReading entries from an ar archive:/p +source![CDATA[ +ArArchiveEntry entry = (ArArchiveEntry) arInput.getNextEntry(); +byte[] content = new byte[entry.getSize()]; +LOOP UNTIL entry.getSize() HAS BEEN READ { +arInput(read, offset, content.length - offset); +} +]]/source + + /subsection + + subsection name=cpio + +pIn addition to the information stored + in codeArchiveEntry/code a codeCpioArchiveEntry/code + stores various attributes including information about the + original owner and permissions./p + +pThe cpio package supports the new portable as well as the + old format of CPIO archives in their binary, ASCII and + with CRC variants./p + +pAdding an entry to a cpio archive:/p +source![CDATA[ +CpioArchiveEntry entry = new CpioArchiveEntry(name, size); +cpioOutput.putNextEntry(entry); +cpioOutput.write(contentOfEntry); +cpioOutput.closeArchiveEntry(); +]]/source + +pReading entries from an cpio archive:/p +source![CDATA[ +CpioArchiveEntry entry = cpioInput.getNextCPIOEntry(); +byte[] content = new byte[entry.getSize
svn commit: r759992 - /commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/archivers/ArTestCase.java
Author: bodewig Date: Mon Mar 30 14:41:14 2009 New Revision: 759992 URL: http://svn.apache.org/viewvc?rev=759992view=rev Log: whitespace Modified: commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/archivers/ArTestCase.java Modified: commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/archivers/ArTestCase.java URL: http://svn.apache.org/viewvc/commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/archivers/ArTestCase.java?rev=759992r1=759991r2=759992view=diff == --- commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/archivers/ArTestCase.java (original) +++ commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/archivers/ArTestCase.java Mon Mar 30 14:41:14 2009 @@ -32,146 +32,146 @@ public final class ArTestCase extends AbstractTestCase { - public void testArArchiveCreation() throws Exception { - final File output = new File(dir, bla.ar); - - final File file1 = getFile(test1.xml); - final File file2 = getFile(test2.xml); - - final OutputStream out = new FileOutputStream(output); +public void testArArchiveCreation() throws Exception { +final File output = new File(dir, bla.ar); + +final File file1 = getFile(test1.xml); +final File file2 = getFile(test2.xml); + +final OutputStream out = new FileOutputStream(output); final ArchiveOutputStream os = new ArchiveStreamFactory().createArchiveOutputStream(ar, out); - os.putArchiveEntry(new ArArchiveEntry(test1.xml, file1.length())); - IOUtils.copy(new FileInputStream(file1), os); - os.closeArchiveEntry(); - - os.putArchiveEntry(new ArArchiveEntry(test2.xml, file2.length())); - IOUtils.copy(new FileInputStream(file2), os); - os.closeArchiveEntry(); - - os.close(); - } - - public void testArUnarchive() throws Exception { - final File output = new File(dir, bla.ar); - { - final File file1 = getFile(test1.xml); - final File file2 = getFile(test2.xml); - - final OutputStream out = new FileOutputStream(output); - final ArchiveOutputStream os = new ArchiveStreamFactory().createArchiveOutputStream(ar, out); - os.putArchiveEntry(new ArArchiveEntry(test1.xml, file1.length())); - IOUtils.copy(new FileInputStream(file1), os); - os.closeArchiveEntry(); - - os.putArchiveEntry(new ArArchiveEntry(test2.xml, file2.length())); - IOUtils.copy(new FileInputStream(file2), os); - os.closeArchiveEntry(); - os.close(); - out.close(); - } - - // UnArArchive Operation - final File input = output; - final InputStream is = new FileInputStream(input); - final ArchiveInputStream in = new ArchiveStreamFactory().createArchiveInputStream(new BufferedInputStream(is)); - final ArArchiveEntry entry = (ArArchiveEntry)in.getNextEntry(); - - File target = new File(dir, entry.getName()); +os.putArchiveEntry(new ArArchiveEntry(test1.xml, file1.length())); +IOUtils.copy(new FileInputStream(file1), os); +os.closeArchiveEntry(); + +os.putArchiveEntry(new ArArchiveEntry(test2.xml, file2.length())); +IOUtils.copy(new FileInputStream(file2), os); +os.closeArchiveEntry(); + +os.close(); +} + +public void testArUnarchive() throws Exception { +final File output = new File(dir, bla.ar); +{ +final File file1 = getFile(test1.xml); +final File file2 = getFile(test2.xml); + +final OutputStream out = new FileOutputStream(output); +final ArchiveOutputStream os = new ArchiveStreamFactory().createArchiveOutputStream(ar, out); +os.putArchiveEntry(new ArArchiveEntry(test1.xml, file1.length())); +IOUtils.copy(new FileInputStream(file1), os); +os.closeArchiveEntry(); + +os.putArchiveEntry(new ArArchiveEntry(test2.xml, file2.length())); +IOUtils.copy(new FileInputStream(file2), os); +os.closeArchiveEntry(); +os.close(); +out.close(); +} + +// UnArArchive Operation +final File input = output; +final InputStream is = new FileInputStream(input); +final ArchiveInputStream in = new ArchiveStreamFactory().createArchiveInputStream(new BufferedInputStream
svn commit: r760000 - in /commons/proper/compress/trunk/src: main/java/org/apache/commons/compress/archivers/ar/ArArchiveOutputStream.java test/java/org/apache/commons/compress/archivers/ArTestCase.ja
Author: bodewig Date: Mon Mar 30 15:07:54 2009 New Revision: 76 URL: http://svn.apache.org/viewvc?rev=76view=rev Log: make closeArchiveEntry a NOP if called repeatedly. This makes ArTestCase fail for all platforms consistently 8-) Modified: commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/ar/ArArchiveOutputStream.java commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/archivers/ArTestCase.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=76r1=75r2=76view=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 Mon Mar 30 15:07:54 2009 @@ -35,6 +35,7 @@ private long archiveOffset = 0; private long entryOffset = 0; private ArArchiveEntry prevEntry; +private boolean haveUnclosedEntry = true; public ArArchiveOutputStream( final OutputStream pOut ) { this.out = pOut; @@ -47,10 +48,11 @@ } public void closeArchiveEntry() throws IOException { -if ((entryOffset % 2) != 0) { +if (prevEntry != null haveUnclosedEntry (entryOffset % 2) != 0) { out.write('\n'); // Pad byte archiveOffset++; } +haveUnclosedEntry = false; } public void putArchiveEntry( final ArchiveEntry pEntry ) throws IOException { @@ -70,6 +72,7 @@ archiveOffset += writeEntryHeader(pArEntry); entryOffset = 0; +haveUnclosedEntry = true; } private long fill( final long pOffset, final long pNewOffset, final char pFill ) throws IOException { Modified: commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/archivers/ArTestCase.java URL: http://svn.apache.org/viewvc/commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/archivers/ArTestCase.java?rev=76r1=75r2=76view=diff == --- commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/archivers/ArTestCase.java (original) +++ commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/archivers/ArTestCase.java Mon Mar 30 15:07:54 2009 @@ -89,10 +89,10 @@ public void testArDelete() throws Exception { final File output = new File(dir, bla.ar); +final File file1 = getFile(test1.xml); +final File file2 = getFile(test2.xml); { // create -final File file1 = getFile(test1.xml); -final File file2 = getFile(test2.xml); final OutputStream out = new FileOutputStream(output); final ArchiveOutputStream os = new ArchiveStreamFactory().createArchiveOutputStream(ar, out); @@ -107,7 +107,10 @@ out.close(); } -assertEquals(282, output.length()); +assertEquals(8 + + 60 + file1.length() + (file1.length() % 2) + + 60 + file2.length() + (file2.length() % 2), + output.length()); final File output2 = new File(dir, bla2.ar);
svn commit: r760017 - /commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/ar/ArArchiveInputStream.java
Author: bodewig Date: Mon Mar 30 15:49:16 2009 New Revision: 760017 URL: http://svn.apache.org/viewvc?rev=760017view=rev Log: offset calculation was broken Modified: commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/ar/ArArchiveInputStream.java Modified: commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/ar/ArArchiveInputStream.java URL: http://svn.apache.org/viewvc/commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/ar/ArArchiveInputStream.java?rev=760017r1=760016r2=760017view=diff == --- commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/ar/ArArchiveInputStream.java (original) +++ commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/ar/ArArchiveInputStream.java Mon Mar 30 15:49:16 2009 @@ -111,19 +111,17 @@ public int read() throws IOException { final int ret = input.read(); -offset++; +offset += (ret 0 ? 1 : 0); return ret; } public int read(byte b[]) throws IOException { -final int ret = read(b, 0, b.length); -offset = offset + b.length; -return ret; +return read(b, 0, b.length); } public int read(byte[] b, int off, int len) throws IOException { final int ret = this.input.read(b, off, len); -offset = offset + off; +offset += (ret 0 ? ret : 0); return ret; }
svn commit: r760032 - /commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/ar/ArArchiveInputStream.java
Author: bodewig Date: Mon Mar 30 16:31:15 2009 New Revision: 760032 URL: http://svn.apache.org/viewvc?rev=760032view=rev Log: chunking of input by entries in AR-Input, COMPRESS-11 Modified: commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/ar/ArArchiveInputStream.java Modified: commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/ar/ArArchiveInputStream.java URL: http://svn.apache.org/viewvc/commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/ar/ArArchiveInputStream.java?rev=760032r1=760031r2=760032view=diff == --- commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/ar/ArArchiveInputStream.java (original) +++ commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/ar/ArArchiveInputStream.java Mon Mar 30 16:31:15 2009 @@ -35,13 +35,42 @@ private final InputStream input; private long offset = 0; private boolean closed; +/* + * If getNextEnxtry has been called, the entry metadata is stored in + * currentEntry. + */ +private ArArchiveEntry currentEntry = null; +/* + * The offset where the current entry started. -1 if no entry has been + * called + */ +private long entryOffset = -1; public ArArchiveInputStream( final InputStream pInput ) { input = pInput; closed = false; } +/** + * Returns the next AR entry in this stream. + * + * @return the next AR entry. + * @throws IOException + * if the entry could not be read + */ public ArArchiveEntry getNextArEntry() throws IOException { +if (currentEntry != null) { +final long entryEnd = entryOffset + currentEntry.getLength(); +while (offset entryEnd) { +int x = read(); +if (x == -1) { +// hit EOF before previous entry was complete +// TODO: throw an exception instead? +return null; +} +} +currentEntry = null; +} if (offset == 0) { final byte[] expected = ArArchiveEntry.HEADER.getBytes(); @@ -57,12 +86,15 @@ } } -if (input.available() == 0) { -return null; +if (offset % 2 != 0) { +if (read() 0) { +// hit eof +return null; +} } -if (offset % 2 != 0) { -read(); +if (input.available() == 0) { +return null; } final byte[] name = new byte[16]; @@ -93,8 +125,11 @@ } } -return new ArArchiveEntry(new String(name).trim(), Long.parseLong(new String(length).trim())); - +entryOffset = offset; +currentEntry = new ArArchiveEntry(new String(name).trim(), + Long.parseLong(new String(length) + .trim())); +return currentEntry; } @@ -107,20 +142,30 @@ closed = true; input.close(); } +currentEntry = null; } public int read() throws IOException { -final int ret = input.read(); -offset += (ret 0 ? 1 : 0); -return ret; +byte[] single = new byte[1]; +int num = read(single, 0, 1); +return num == -1 ? -1 : single[0] 0xff; } -public int read(byte b[]) throws IOException { +public int read(byte[] b) throws IOException { return read(b, 0, b.length); } -public int read(byte[] b, int off, int len) throws IOException { -final int ret = this.input.read(b, off, len); +public int read(byte[] b, final int off, final int len) throws IOException { +int toRead = len; +if (currentEntry != null) { +final long entryEnd = entryOffset + currentEntry.getLength(); +if (len 0 entryEnd offset) { +toRead = (int) Math.min(len, entryEnd - offset); +} else { +return -1; +} +} +final int ret = this.input.read(b, off, toRead); offset += (ret 0 ? ret : 0); return ret; }
svn commit: r760033 - /commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/archivers/ArTestCase.java
Author: bodewig Date: Mon Mar 30 16:33:52 2009 New Revision: 760033 URL: http://svn.apache.org/viewvc?rev=760033view=rev Log: make test platform independent Modified: commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/archivers/ArTestCase.java Modified: commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/archivers/ArTestCase.java URL: http://svn.apache.org/viewvc/commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/archivers/ArTestCase.java?rev=760033r1=760032r2=760033view=diff == --- commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/archivers/ArTestCase.java (original) +++ commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/archivers/ArTestCase.java Mon Mar 30 16:33:52 2009 @@ -149,7 +149,9 @@ assertEquals(1, copied); assertEquals(1, deleted); -assertEquals(144, output2.length()); +assertEquals(8 + + 60 + file1.length() + (file1.length() % 2), + output2.length()); long files = 0; long sum = 0; @@ -173,7 +175,7 @@ } assertEquals(1, files); -assertEquals(76, sum); +assertEquals(file1.length(), sum); }
svn commit: r765095 - /commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/zip/AsiExtraField.java
Author: bodewig Date: Wed Apr 15 09:38:47 2009 New Revision: 765095 URL: http://svn.apache.org/viewvc?rev=765095view=rev Log: document default encoding in ASi extra field Modified: commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/zip/AsiExtraField.java Modified: commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/zip/AsiExtraField.java URL: http://svn.apache.org/viewvc/commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/zip/AsiExtraField.java?rev=765095r1=765094r2=765095view=diff == --- commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/zip/AsiExtraField.java (original) +++ commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/zip/AsiExtraField.java Wed Apr 15 09:38:47 2009 @@ -45,6 +45,10 @@ * pShort is two bytes and Long is four bytes in big endian byte and * word order, device numbers are currently not supported./p * @NotThreadSafe + * + * pSince the documentation this class is based upon doesn't mention + * the character encoding of the file name at all, it is assumed that + * it uses the current platform's default encoding./p */ public class AsiExtraField implements ZipExtraField, UnixStat, Cloneable { @@ -101,7 +105,7 @@ + WORD // SizDev + 2 // UID + 2 // GID - + getLinkedFile().getBytes().length); // TODO is it correct to use the default charset here? + + getLinkedFile().getBytes().length); } /** @@ -122,7 +126,7 @@ byte[] data = new byte[getLocalFileDataLength().getValue() - WORD]; System.arraycopy(ZipShort.getBytes(getMode()), 0, data, 0, 2); -byte[] linkArray = getLinkedFile().getBytes(); // TODO is it correct to use the default charset here? +byte[] linkArray = getLinkedFile().getBytes(); // CheckStyle:MagicNumber OFF System.arraycopy(ZipLong.getBytes(linkArray.length), 0, data, 2, WORD); @@ -280,7 +284,7 @@ link = ; } else { System.arraycopy(tmp, 10, linkArray, 0, linkArray.length); -link = new String(linkArray); // TODO is it correct to use the default charset here? +link = new String(linkArray); } // CheckStyle:MagicNumber ON setDirectory((newMode DIR_FLAG) != 0);
svn commit: r765090 - /commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/zip/FallbackZipEncoding.java
Author: bodewig Date: Wed Apr 15 09:32:00 2009 New Revision: 765090 URL: http://svn.apache.org/viewvc?rev=765090view=rev Log: Remove TODO, see constructor's Javadoc Modified: commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/zip/FallbackZipEncoding.java Modified: commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/zip/FallbackZipEncoding.java URL: http://svn.apache.org/viewvc/commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/zip/FallbackZipEncoding.java?rev=765090r1=765089r2=765090view=diff == --- commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/zip/FallbackZipEncoding.java (original) +++ commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/zip/FallbackZipEncoding.java Wed Apr 15 09:32:00 2009 @@ -87,7 +87,7 @@ */ public String decode(byte[] data) throws IOException { if (this.charset == null) { -return new String(data); // TODO is it correct to use the default charset here? +return new String(data); } else { return new String(data,this.charset); }
svn commit: r769291 - /commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/zip/ZipArchiveInputStream.java
Author: bodewig Date: Tue Apr 28 08:31:15 2009 New Revision: 769291 URL: http://svn.apache.org/viewvc?rev=769291view=rev Log: Only use the zip-extra-field if configured to do so and the entry didn't set the EFS flag - COMPRESS-70 Modified: 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/ZipArchiveInputStream.java URL: http://svn.apache.org/viewvc/commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/zip/ZipArchiveInputStream.java?rev=769291r1=769290r2=769291view=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 Tue Apr 28 08:31:15 2009 @@ -54,7 +54,7 @@ /** * Whether to look for and use Unicode extra fields. */ -private final boolean useUnicodeExtraFields; // TODO not yet used +private final boolean useUnicodeExtraFields; private final InputStream in; @@ -178,8 +178,9 @@ readFully(extraData); current.setExtra(extraData); -ZipUtil.setNameAndCommentFromExtraFields(current, fileName, null); - +if (!hasEFS useUnicodeExtraFields) { +ZipUtil.setNameAndCommentFromExtraFields(current, fileName, null); +} return current; }
svn commit: r789597 - in /commons/proper/compress/trunk/src: changes/changes.xml main/java/org/apache/commons/compress/archivers/tar/TarBuffer.java
Author: bodewig Date: Tue Jun 30 07:25:44 2009 New Revision: 789597 URL: http://svn.apache.org/viewvc?rev=789597view=rev Log: clear block after write to avoid garbage in the final block if it isn't full. COMPRESS-81. Merge from Ant. Modified: commons/proper/compress/trunk/src/changes/changes.xml commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/tar/TarBuffer.java (contents, props changed) Modified: commons/proper/compress/trunk/src/changes/changes.xml URL: http://svn.apache.org/viewvc/commons/proper/compress/trunk/src/changes/changes.xml?rev=789597r1=789596r2=789597view=diff == --- commons/proper/compress/trunk/src/changes/changes.xml (original) +++ commons/proper/compress/trunk/src/changes/changes.xml Tue Jun 30 07:25:44 2009 @@ -20,11 +20,15 @@ document properties titlecommons-compress/title -authorStefan Bodewig/author /properties body -release version=1.0 date=as in SVN description=First Public Release - action dev=all type=add +release version=1.1 date=as in SVN description=Release 1.1 + action issue=COMPRESS-81 type=fix date=2009-06-30 +TarOutputStream can leave garbage at the end of the archive + /action +/release +release version=1.0 date=2009-05-21 description=First Public Release + action dev=all type=add date=2009-05-21 Initial release /action action dev=sgoeschl type=fix 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=789597r1=789596r2=789597view=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 Tue Jun 30 07:25:44 2009 @@ -373,6 +373,7 @@ currRecIdx = 0; currBlkIdx++; +Arrays.fill(blockBuffer, (byte) 0); } /** Propchange: commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/tar/TarBuffer.java -- --- svn:mergeinfo (added) +++ svn:mergeinfo Tue Jun 30 07:25:44 2009 @@ -0,0 +1 @@ +/ant/core/trunk/src/main/org/apache/tools/tar/TarBuffer.java:741089,789556
svn commit: r789600 - /commons/proper/compress/trunk/src/site/xdoc/index.xml
Author: bodewig Date: Tue Jun 30 07:48:31 2009 New Revision: 789600 URL: http://svn.apache.org/viewvc?rev=789600view=rev Log: there is a release Modified: commons/proper/compress/trunk/src/site/xdoc/index.xml 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=789600r1=789599r2=789600view=diff == --- commons/proper/compress/trunk/src/site/xdoc/index.xml (original) +++ commons/proper/compress/trunk/src/site/xdoc/index.xml Tue Jun 30 07:48:31 2009 @@ -89,7 +89,8 @@ /section section name=Releases p -None. +The latest version v1.0, is JDK 1.4 compatible - +a href=http://commons.apache.org/compress/download_compress.cgi;Download now!/a /p /section /body
svn commit: r789607 - in /commons/proper/compress/trunk/src: changes/changes.xml main/java/org/apache/commons/compress/compressors/bzip2/BZip2Utils.java test/java/org/apache/commons/compress/compresso
Author: bodewig Date: Tue Jun 30 08:23:08 2009 New Revision: 789607 URL: http://svn.apache.org/viewvc?rev=789607view=rev Log: Add a BZip2Utils class matching GZipUtils. Submitted by Jukka Zitting. COMPRESS-78 Added: commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/compressors/bzip2/BZip2Utils.java (with props) commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/compressors/BZip2UtilsTestCase.java (with props) 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=789607r1=789606r2=789607view=diff == --- commons/proper/compress/trunk/src/changes/changes.xml (original) +++ commons/proper/compress/trunk/src/changes/changes.xml Tue Jun 30 08:23:08 2009 @@ -26,6 +26,10 @@ action issue=COMPRESS-81 type=fix date=2009-06-30 TarOutputStream can leave garbage at the end of the archive /action + action issue=COMPRESS-78 type=add date=2009-06-30 + due-to=Jukka Zitting +Add a BZip2Utils class modelled after GZipUtils + /action /release release version=1.0 date=2009-05-21 description=First Public Release action dev=all type=add date=2009-05-21 Added: commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/compressors/bzip2/BZip2Utils.java URL: http://svn.apache.org/viewvc/commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/compressors/bzip2/BZip2Utils.java?rev=789607view=auto == --- commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/compressors/bzip2/BZip2Utils.java (added) +++ commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/compressors/bzip2/BZip2Utils.java Tue Jun 30 08:23:08 2009 @@ -0,0 +1,112 @@ +/* + * 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.bzip2; + +import java.util.HashMap; +import java.util.Map; + +/** + * Utility code for the BZip2 compression format. + * @ThreadSafe + * @since Commons Compress 1.1 + */ +public abstract class BZip2Utils { + +/** + * Map from common filename suffixes of bzip2ed files to the corresponding + * suffixes of uncompressed files. For example: from .tbz2 to .tar. + * p + * This map also contains bzip2-specific suffixes like .bz2. 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 Map uncompressSuffix = new HashMap(); + +static { +uncompressSuffix.put(.tbz2, .tar); +uncompressSuffix.put(.tbz, .tar); +uncompressSuffix.put(.bz2, ); +uncompressSuffix.put(.bz, ); +} +// 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 BZip2Utils() { +} + +/** + * Detects common bzip2 suffixes in the given filename. + * + * @param filename name of a file + * @return codetrue/code if the filename has a common bzip2 suffix, + * codefalse/code otherwise + */ +public static boolean isCompressedFilename(String filename) { +String lower = filename.toLowerCase(); +int n = lower.length(); +// Shortest suffix is three letters (.bz), longest is five (.tbz2) +for (int i = 3; i = 5 i n; i++) { +if (uncompressSuffix.containsKey(lower.substring(n - i))) { +return true; +} +} +return false; +} + +/** + * Maps the given name of a bzip2-compressed file to the name that the + * file should have after uncompression. Commonly used file type specific + * suffixes like .tbz or .tbz2 are automatically detected and + * correctly mapped. For example the name package.tbz2 is mapped to + * package.tar. And any
svn commit: r799879 - in /commons/proper/compress/trunk/src: main/java/org/apache/commons/compress/archivers/ main/java/org/apache/commons/compress/archivers/ar/ main/java/org/apache/commons/compress/
Author: bodewig Date: Sat Aug 1 14:52:15 2009 New Revision: 799879 URL: http://svn.apache.org/viewvc?rev=799879view=rev Log: add getLastModifiedDate to ArchiveEntry - implement it assuming cpio and ar use seconds since epoch for their time values Modified: commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/ArchiveEntry.java commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/ar/ArArchiveEntry.java 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/tar/TarArchiveEntry.java commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/zip/ZipArchiveEntry.java commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/archivers/memory/MemoryArchiveEntry.java Modified: commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/ArchiveEntry.java URL: http://svn.apache.org/viewvc/commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/ArchiveEntry.java?rev=799879r1=799878r2=799879view=diff == --- commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/ArchiveEntry.java (original) +++ commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/ArchiveEntry.java Sat Aug 1 14:52:15 2009 @@ -18,6 +18,8 @@ */ package org.apache.commons.compress.archivers; +import java.util.Date; + /** * Represents an entry of an archive. */ @@ -34,4 +36,7 @@ /** True if the entry refers to a directory */ public boolean isDirectory(); + +/** The last modified date of the entry */ +public Date getLastModifiedDate(); } Modified: commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/ar/ArArchiveEntry.java URL: http://svn.apache.org/viewvc/commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/ar/ArArchiveEntry.java?rev=799879r1=799878r2=799879view=diff == --- commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/ar/ArArchiveEntry.java (original) +++ commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/ar/ArArchiveEntry.java Sat Aug 1 14:52:15 2009 @@ -19,6 +19,7 @@ package org.apache.commons.compress.archivers.ar; import java.io.File; +import java.util.Date; import org.apache.commons.compress.archivers.ArchiveEntry; @@ -111,6 +112,11 @@ return lastModified; } +/** {...@inheritdocs} */ +public Date getLastModifiedDate() { +return new Date(1000 * getLastModified()); +} + public long getLength() { return length; } 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=799879r1=799878r2=799879view=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 Sat Aug 1 14:52:15 2009 @@ -19,6 +19,7 @@ package org.apache.commons.compress.archivers.cpio; import java.io.File; +import java.util.Date; import org.apache.commons.compress.archivers.ArchiveEntry; @@ -492,6 +493,11 @@ return this.mtime; } +/** {...@inheritdocs} */ +public Date getLastModifiedDate() { +return new Date(1000 * getTime()); +} + /** * Get the user id. * 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=799879r1=799878r2=799879view=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 Sat Aug 1 14:52:15 2009 @@ -463,6 +463,11 @@ return new Date(modTime * MILLIS_PER_SECOND); } +/** {...@inheritdocs} */ +public Date getLastModifiedDate() { +return getModTime(); +} + /** * Get this entry's file. * Modified: commons/proper/compress/trunk/src/main/java
svn commit: r799880 - in /commons/proper/compress/trunk/src: main/java/org/apache/commons/compress/archivers/ main/java/org/apache/commons/compress/archivers/ar/ main/java/org/apache/commons/compress/
Author: bodewig Date: Sat Aug 1 14:53:32 2009 New Revision: 799880 URL: http://svn.apache.org/viewvc?rev=799880view=rev Log: whitespace Modified: commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/ArchiveEntry.java commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/ar/ArArchiveEntry.java commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/cpio/CpioArchiveEntry.java commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/archivers/memory/MemoryArchiveEntry.java Modified: commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/ArchiveEntry.java URL: http://svn.apache.org/viewvc/commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/ArchiveEntry.java?rev=799880r1=799879r2=799880view=diff == --- commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/ArchiveEntry.java (original) +++ commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/ArchiveEntry.java Sat Aug 1 14:53:32 2009 @@ -26,16 +26,16 @@ public interface ArchiveEntry { /** The name of the entry in the archive. May refer to a file or directory or other item */ - public String getName(); - - /** The (uncompressed) size of the entry. May be -1 (SIZE_UNKNOWN) if the size is unknown */ - public long getSize(); - - /** Special value indicating that the size is unknown */ - public static final long SIZE_UNKNOWN = -1; - - /** True if the entry refers to a directory */ - public boolean isDirectory(); +public String getName(); + +/** The (uncompressed) size of the entry. May be -1 (SIZE_UNKNOWN) if the size is unknown */ +public long getSize(); + +/** Special value indicating that the size is unknown */ +public static final long SIZE_UNKNOWN = -1; + +/** True if the entry refers to a directory */ +public boolean isDirectory(); /** The last modified date of the entry */ public Date getLastModifiedDate(); Modified: commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/ar/ArArchiveEntry.java URL: http://svn.apache.org/viewvc/commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/ar/ArArchiveEntry.java?rev=799880r1=799879r2=799880view=diff == --- commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/ar/ArArchiveEntry.java (original) +++ commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/ar/ArArchiveEntry.java Sat Aug 1 14:53:32 2009 @@ -56,74 +56,74 @@ /** The trailer for each entry */ public static final String TRAILER = `\012; - + /** * SVR4/GNU adds a trailing / to names; BSD does not. * They also vary in how names longer than 16 characters are represented. * (Not yet supported by this implementation) */ private final String name; - private final int userId; - private final int groupId; - private final int mode; +private final int userId; +private final int groupId; +private final int mode; private static final int DEFAULT_MODE = 33188; // = (octal) 0100644 - private final long lastModified; - private final long length; +private final long lastModified; +private final long length; - public ArArchiveEntry(String name, long length) { - this(name, length, 0, 0, DEFAULT_MODE, System.currentTimeMillis()); - } - - public ArArchiveEntry(String name, long length, int userId, int groupId, int mode, long lastModified) { - this.name = name; - this.length = length; - this.userId = userId; - this.groupId = groupId; - this.mode = mode; - this.lastModified = lastModified; - } +public ArArchiveEntry(String name, long length) { +this(name, length, 0, 0, DEFAULT_MODE, System.currentTimeMillis()); +} - public ArArchiveEntry(File inputFile, String entryName) { - // TODO sort out mode +public ArArchiveEntry(String name, long length, int userId, int groupId, int mode, long lastModified) { +this.name = name; +this.length = length; +this.userId = userId; +this.groupId = groupId; +this.mode = mode; +this.lastModified = lastModified; +} + +public ArArchiveEntry(File inputFile, String entryName) { +// TODO sort out mode this(entryName, inputFile.isFile() ? inputFile.length() : 0, 0, 0, 0, inputFile.lastModified()); } public long getSize() { - return this.getLength
svn commit: r799882 - in /commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers: ar/ArArchiveEntry.java ar/ArArchiveInputStream.java cpio/CpioArchiveOutputStream.java
Author: bodewig Date: Sat Aug 1 15:04:22 2009 New Revision: 799882 URL: http://svn.apache.org/viewvc?rev=799882view=rev Log: now ar and cpio really use seconds internally and read/write them as such. Modified: commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/ar/ArArchiveEntry.java commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/ar/ArArchiveInputStream.java commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/cpio/CpioArchiveOutputStream.java Modified: commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/ar/ArArchiveEntry.java URL: http://svn.apache.org/viewvc/commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/ar/ArArchiveEntry.java?rev=799882r1=799881r2=799882view=diff == --- commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/ar/ArArchiveEntry.java (original) +++ commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/ar/ArArchiveEntry.java Sat Aug 1 15:04:22 2009 @@ -70,11 +70,32 @@ private final long lastModified; private final long length; +/** + * Create a new instance using a couple of default values. + * + * pSets userId and groupId to 0, the octal file mode to 644 and + * the last modified time to the current time./p + * + * @param name name of the entry + * @param length length of the entry in bytes + */ public ArArchiveEntry(String name, long length) { -this(name, length, 0, 0, DEFAULT_MODE, System.currentTimeMillis()); +this(name, length, 0, 0, DEFAULT_MODE, + System.currentTimeMillis() / 1000); } -public ArArchiveEntry(String name, long length, int userId, int groupId, int mode, long lastModified) { +/** + * Create a new instance. + * + * @param name name of the entry + * @param length length of the entry in bytes + * @param userId numeric user id + * @param groupId numeric group id + * @param mode file mode + * @param lastModified last modified time in seconds since the epoch + */ +public ArArchiveEntry(String name, long length, int userId, int groupId, + int mode, long lastModified) { this.name = name; this.length = length; this.userId = userId; @@ -83,9 +104,13 @@ this.lastModified = lastModified; } +/** + * Create a new instance using the attributes of the given file + */ public ArArchiveEntry(File inputFile, String entryName) { // TODO sort out mode -this(entryName, inputFile.isFile() ? inputFile.length() : 0, 0, 0, 0, inputFile.lastModified()); +this(entryName, inputFile.isFile() ? inputFile.length() : 0, + 0, 0, 0, inputFile.lastModified() / 1000); } public long getSize() { @@ -108,6 +133,9 @@ return mode; } +/** + * Last modified time in seconds since the epoch. + */ public long getLastModified() { return lastModified; } Modified: commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/ar/ArArchiveInputStream.java URL: http://svn.apache.org/viewvc/commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/ar/ArArchiveInputStream.java?rev=799882r1=799881r2=799882view=diff == --- commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/ar/ArArchiveInputStream.java (original) +++ commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/ar/ArArchiveInputStream.java Sat Aug 1 15:04:22 2009 @@ -142,10 +142,20 @@ if (temp.endsWith(/)) { temp = temp.substring(0, temp.length() - 1); } -currentEntry = new ArArchiveEntry(temp, Long.parseLong(new String(length).trim())); +currentEntry = new ArArchiveEntry(temp, asLong(length), asInt(userid), + asInt(groupid), asInt(filemode), + asLong(lastmodified)); return currentEntry; } +private long asLong(byte[] input) { +return Long.parseLong(new String(input).trim()); +} + +private int asInt(byte[] input) { +return Integer.parseInt(new String(input).trim()); +} + /* * (non-Javadoc) * Modified: commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/cpio/CpioArchiveOutputStream.java URL: http://svn.apache.org/viewvc/commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/cpio/CpioArchiveOutputStream.java?rev=799882r1=799881r2=799882view=diff
svn commit: r799911 - in /commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/archivers: TarTestCase.java ZipTestCase.java
Author: bodewig Date: Sat Aug 1 19:32:12 2009 New Revision: 799911 URL: http://svn.apache.org/viewvc?rev=799911view=rev Log: check name/directory/size and lastModified read from tar is consistent with what we write Modified: commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/archivers/TarTestCase.java commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/archivers/ZipTestCase.java Modified: commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/archivers/TarTestCase.java URL: http://svn.apache.org/viewvc/commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/archivers/TarTestCase.java?rev=799911r1=799910r2=799911view=diff == --- commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/archivers/TarTestCase.java (original) +++ commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/archivers/TarTestCase.java Sat Aug 1 19:32:12 2009 @@ -27,6 +27,8 @@ import org.apache.commons.compress.AbstractTestCase; import org.apache.commons.compress.archivers.tar.TarArchiveEntry; +import org.apache.commons.compress.archivers.tar.TarArchiveInputStream; +import org.apache.commons.compress.archivers.tar.TarArchiveOutputStream; import org.apache.commons.compress.utils.IOUtils; public final class TarTestCase extends AbstractTestCase { @@ -112,4 +114,189 @@ out.close(); } +public void testDirectoryEntryFromFile() throws Exception { +File[] tmp = createTempDirAndFile(); +File archive = null; +TarArchiveOutputStream tos = null; +TarArchiveInputStream tis = null; +try { +archive = File.createTempFile(test., .tar, tmp[0]); +archive.deleteOnExit(); +tos = new TarArchiveOutputStream(new FileOutputStream(archive)); +long beforeArchiveWrite = tmp[0].lastModified(); +TarArchiveEntry in = new TarArchiveEntry(tmp[0], foo); +tos.putArchiveEntry(in); +tos.closeArchiveEntry(); +tos.close(); +tos = null; +tis = new TarArchiveInputStream(new FileInputStream(archive)); +TarArchiveEntry out = tis.getNextTarEntry(); +tis.close(); +tis = null; +assertNotNull(out); +assertEquals(foo/, out.getName()); +assertEquals(0, out.getSize()); +// TAR stores time with a granularity of 1 second +assertEquals(beforeArchiveWrite / 1000, + out.getLastModifiedDate().getTime() / 1000); +assertTrue(out.isDirectory()); +} finally { +if (tis != null) { +tis.close(); +} +if (tos != null) { +tos.close(); +} +if (archive != null) { +archive.delete(); +} +tmp[1].delete(); +tmp[0].delete(); +} +} + +public void testExplicitDirectoryEntry() throws Exception { +File[] tmp = createTempDirAndFile(); +File archive = null; +TarArchiveOutputStream tos = null; +TarArchiveInputStream tis = null; +try { +archive = File.createTempFile(test., .tar, tmp[0]); +archive.deleteOnExit(); +tos = new TarArchiveOutputStream(new FileOutputStream(archive)); +long beforeArchiveWrite = tmp[0].lastModified(); +TarArchiveEntry in = new TarArchiveEntry(foo/); +in.setModTime(beforeArchiveWrite); +tos.putArchiveEntry(in); +tos.closeArchiveEntry(); +tos.close(); +tos = null; +tis = new TarArchiveInputStream(new FileInputStream(archive)); +TarArchiveEntry out = tis.getNextTarEntry(); +tis.close(); +tis = null; +assertNotNull(out); +assertEquals(foo/, out.getName()); +assertEquals(0, out.getSize()); +assertEquals(beforeArchiveWrite / 1000, + out.getLastModifiedDate().getTime() / 1000); +assertTrue(out.isDirectory()); +} finally { +if (tis != null) { +tis.close(); +} +if (tos != null) { +tos.close(); +} +if (archive != null) { +archive.delete(); +} +tmp[1].delete(); +tmp[0].delete(); +} +} + +public void testFileEntryFromFile() throws Exception { +File[] tmp = createTempDirAndFile(); +File archive = null; +TarArchiveOutputStream tos = null; +TarArchiveInputStream tis = null; +FileInputStream fis = null; +try { +archive = File.createTempFile(test., .tar, tmp[0]); +archive.deleteOnExit(); +tos
svn commit: r799914 - in /commons/proper/compress/trunk/src: main/java/org/apache/commons/compress/archivers/ar/ArArchiveOutputStream.java test/java/org/apache/commons/compress/archivers/ArTestCase.ja
Author: bodewig Date: Sat Aug 1 19:52:32 2009 New Revision: 799914 URL: http://svn.apache.org/viewvc?rev=799914view=rev Log: check name/size and lastModified read from ar is consistent with what we write Modified: commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/ar/ArArchiveOutputStream.java commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/archivers/ArTestCase.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=799914r1=799913r2=799914view=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 Sat Aug 1 19:52:32 2009 @@ -121,7 +121,7 @@ offset += write(n); offset = fill(offset, 16, ' '); -final String m = + (pEntry.getLastModified() / 1000); +final String m = + (pEntry.getLastModified()); if (m.length() 12) { throw new IOException(modified too long); } Modified: commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/archivers/ArTestCase.java URL: http://svn.apache.org/viewvc/commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/archivers/ArTestCase.java?rev=799914r1=799913r2=799914view=diff == --- commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/archivers/ArTestCase.java (original) +++ commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/archivers/ArTestCase.java Sat Aug 1 19:52:32 2009 @@ -28,6 +28,8 @@ import org.apache.commons.compress.AbstractTestCase; import org.apache.commons.compress.archivers.ar.ArArchiveEntry; +import org.apache.commons.compress.archivers.ar.ArArchiveInputStream; +import org.apache.commons.compress.archivers.ar.ArArchiveOutputStream; import org.apache.commons.compress.utils.IOUtils; public final class ArTestCase extends AbstractTestCase { @@ -179,4 +181,192 @@ } +// TODO: revisit - does AR not support storing directories? +public void XtestDirectoryEntryFromFile() throws Exception { +File[] tmp = createTempDirAndFile(); +File archive = null; +ArArchiveOutputStream aos = null; +ArArchiveInputStream ais = null; +try { +archive = File.createTempFile(test., .ar, tmp[0]); +archive.deleteOnExit(); +aos = new ArArchiveOutputStream(new FileOutputStream(archive)); +long beforeArchiveWrite = tmp[0].lastModified(); +ArArchiveEntry in = new ArArchiveEntry(tmp[0], foo); +aos.putArchiveEntry(in); +aos.closeArchiveEntry(); +aos.close(); +aos = null; +ais = new ArArchiveInputStream(new FileInputStream(archive)); +ArArchiveEntry out = ais.getNextArEntry(); +ais.close(); +ais = null; +assertNotNull(out); +assertEquals(foo/, out.getName()); +assertEquals(0, out.getSize()); +// AR stores time with a granularity of 1 second +assertEquals(beforeArchiveWrite / 1000, + out.getLastModifiedDate().getTime() / 1000); +assertTrue(out.isDirectory()); +} finally { +if (ais != null) { +ais.close(); +} +if (aos != null) { +aos.close(); +} +if (archive != null) { +archive.delete(); +} +tmp[1].delete(); +tmp[0].delete(); +} +} + +// TODO: revisit - does AR not support storing directories? +public void XtestExplicitDirectoryEntry() throws Exception { +File[] tmp = createTempDirAndFile(); +File archive = null; +ArArchiveOutputStream aos = null; +ArArchiveInputStream ais = null; +try { +archive = File.createTempFile(test., .ar, tmp[0]); +archive.deleteOnExit(); +aos = new ArArchiveOutputStream(new FileOutputStream(archive)); +long beforeArchiveWrite = tmp[0].lastModified(); +ArArchiveEntry in = new ArArchiveEntry(foo, 0, 0, 0, 0, + tmp[1].lastModified() / 1000); +aos.putArchiveEntry(in); +aos.closeArchiveEntry(); +aos.close(); +aos = null; +ais = new ArArchiveInputStream(new FileInputStream(archive)); +ArArchiveEntry out
svn commit: r799915 - in /commons/proper/compress/trunk/src: main/java/org/apache/commons/compress/archivers/cpio/ test/java/org/apache/commons/compress/archivers/
Author: bodewig Date: Sat Aug 1 20:07:53 2009 New Revision: 799915 URL: http://svn.apache.org/viewvc?rev=799915view=rev Log: check name/directory/size and lastModified read from cpio is consistent with what we write Modified: 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/CpioArchiveOutputStream.java commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/archivers/CpioTestCase.java 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=799915r1=799914r2=799915view=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 Sat Aug 1 20:07:53 2009 @@ -264,6 +264,7 @@ } // TODO set other fields as needed setMode(mode); +setTime(inputFile.lastModified() / 1000); } /** Modified: commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/cpio/CpioArchiveOutputStream.java URL: http://svn.apache.org/viewvc/commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/cpio/CpioArchiveOutputStream.java?rev=799915r1=799914r2=799915view=diff == --- commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/cpio/CpioArchiveOutputStream.java (original) +++ commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/cpio/CpioArchiveOutputStream.java Sat Aug 1 20:07:53 2009 @@ -48,7 +48,7 @@ * entry.setFileSize(contents.length()); * entry.setMode(CpioConstants.C_ISREG); // regular file * ... set other attributes, e.g. time, number of links - * out.putNextEntry(entry); + * out.putArchiveEntry(entry); * out.write(testContents.getBytes()); * out.close(); * /pre/code Modified: commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/archivers/CpioTestCase.java URL: http://svn.apache.org/viewvc/commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/archivers/CpioTestCase.java?rev=799915r1=799914r2=799915view=diff == --- commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/archivers/CpioTestCase.java (original) +++ commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/archivers/CpioTestCase.java Sat Aug 1 20:07:53 2009 @@ -29,6 +29,8 @@ import org.apache.commons.compress.AbstractTestCase; import org.apache.commons.compress.archivers.cpio.CpioArchiveEntry; import org.apache.commons.compress.archivers.cpio.CpioConstants; +import org.apache.commons.compress.archivers.cpio.CpioArchiveInputStream; +import org.apache.commons.compress.archivers.cpio.CpioArchiveOutputStream; import org.apache.commons.compress.utils.IOUtils; public final class CpioTestCase extends AbstractTestCase { @@ -88,11 +90,11 @@ Map result = new HashMap(); ArchiveEntry entry = null; while ((entry = in.getNextEntry()) != null) { -File target = new File(dir, entry.getName()); -final OutputStream out = new FileOutputStream(target); +File cpioget = new File(dir, entry.getName()); +final OutputStream out = new FileOutputStream(cpioget); IOUtils.copy(in, out); out.close(); -result.put(entry.getName(), target); +result.put(entry.getName(), cpioget); } in.close(); is.close(); @@ -106,4 +108,191 @@ assertEquals(length of + t.getAbsolutePath(), file2Length, t.length()); } +public void testDirectoryEntryFromFile() throws Exception { +File[] tmp = createTempDirAndFile(); +File archive = null; +CpioArchiveOutputStream tos = null; +CpioArchiveInputStream tis = null; +try { +archive = File.createTempFile(test., .cpio, tmp[0]); +archive.deleteOnExit(); +tos = new CpioArchiveOutputStream(new FileOutputStream(archive)); +long beforeArchiveWrite = tmp[0].lastModified(); +CpioArchiveEntry in = new CpioArchiveEntry(tmp[0], foo); +tos.putArchiveEntry(in); +tos.closeArchiveEntry(); +tos.close(); +tos = null; +tis = new CpioArchiveInputStream(new FileInputStream(archive)); +CpioArchiveEntry out
svn commit: r799917 - in /commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/compressors/gzip: GzipCompressorInputStream.java GzipCompressorOutputStream.java
Author: bodewig Date: Sat Aug 1 20:17:00 2009 New Revision: 799917 URL: http://svn.apache.org/viewvc?rev=799917view=rev Log: delegate all read/write methods in gzip streams. COMPRESS-83 Modified: commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/compressors/gzip/GzipCompressorInputStream.java commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/compressors/gzip/GzipCompressorOutputStream.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=799917r1=799916r2=799917view=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 Sat Aug 1 20:17:00 2009 @@ -47,7 +47,26 @@ * @see java.io.InputStream#read() */ public int read() throws IOException { -this.count(1); -return in.read(); +int read = in.read(); +this.count(read 0 ? -1 : 1); +return read; +} + +/* (non-Javadoc) + * @see java.io.InputStream#read(byte[]) + */ +public int read(byte[] b) throws IOException { +int read = in.read(b); +this.count(read); +return read; +} + +/* (non-Javadoc) + * @see java.io.InputStream#read(byte[], int, int) + */ +public int read(byte[] b, int from, int length) throws IOException { +int read = in.read(b, from, length); +this.count(read); +return read; } } Modified: commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/compressors/gzip/GzipCompressorOutputStream.java URL: http://svn.apache.org/viewvc/commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/compressors/gzip/GzipCompressorOutputStream.java?rev=799917r1=799916r2=799917view=diff == --- commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/compressors/gzip/GzipCompressorOutputStream.java (original) +++ commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/compressors/gzip/GzipCompressorOutputStream.java Sat Aug 1 20:17:00 2009 @@ -36,6 +36,14 @@ out.write(b); } +public void write(byte[] b) throws IOException { +out.write(b); +} + +public void write(byte[] b, int from, int length) throws IOException { +out.write(b, from, length); +} + public void close() throws IOException { out.close(); }
svn commit: r799918 - /commons/proper/compress/trunk/src/changes/changes.xml
Author: bodewig Date: Sat Aug 1 20:25:13 2009 New Revision: 799918 URL: http://svn.apache.org/viewvc?rev=799918view=rev Log: document today's 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=799918r1=799917r2=799918view=diff == --- commons/proper/compress/trunk/src/changes/changes.xml (original) +++ commons/proper/compress/trunk/src/changes/changes.xml Sat Aug 1 20:25:13 2009 @@ -23,6 +23,17 @@ /properties body release version=1.1 date=as in SVN description=Release 1.1 + action issue=COMPRESS-83 type=fix date=2009-08-01 +Delegate all read and write methods in GZip stream in order to +speed up operations. + /action + action type=add date=2009-08-01 +ArchiveEntry now has a getLastModifiedDate method. + /action + action type=fix date=2009-08-01 +The ar and cpio streams now properly read and write last +modified times. + /action action issue=COMPRESS-81 type=fix date=2009-06-30 TarOutputStream can leave garbage at the end of the archive /action
svn commit: r806431 - in /commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/ar: ArArchiveEntry.java ArArchiveInputStream.java
Author: bodewig Date: Fri Aug 21 07:05:07 2009 New Revision: 806431 URL: http://svn.apache.org/viewvc?rev=806431view=rev Log: ar stores permissions as octal numbers, output stream does write them correctly, input stream was reading them as decimal Modified: commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/ar/ArArchiveEntry.java commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/ar/ArArchiveInputStream.java Modified: commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/ar/ArArchiveEntry.java URL: http://svn.apache.org/viewvc/commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/ar/ArArchiveEntry.java?rev=806431r1=806430r2=806431view=diff == --- commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/ar/ArArchiveEntry.java (original) +++ commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/ar/ArArchiveEntry.java Fri Aug 21 07:05:07 2009 @@ -110,7 +110,7 @@ public ArArchiveEntry(File inputFile, String entryName) { // TODO sort out mode this(entryName, inputFile.isFile() ? inputFile.length() : 0, - 0, 0, 0, inputFile.lastModified() / 1000); + 0, 0, DEFAULT_MODE, inputFile.lastModified() / 1000); } public long getSize() { Modified: commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/ar/ArArchiveInputStream.java URL: http://svn.apache.org/viewvc/commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/ar/ArArchiveInputStream.java?rev=806431r1=806430r2=806431view=diff == --- commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/ar/ArArchiveInputStream.java (original) +++ commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/ar/ArArchiveInputStream.java Fri Aug 21 07:05:07 2009 @@ -143,7 +143,7 @@ temp = temp.substring(0, temp.length() - 1); } currentEntry = new ArArchiveEntry(temp, asLong(length), asInt(userid), - asInt(groupid), asInt(filemode), + asInt(groupid), asInt(filemode, 8), asLong(lastmodified)); return currentEntry; } @@ -153,7 +153,11 @@ } private int asInt(byte[] input) { -return Integer.parseInt(new String(input).trim()); +return asInt(input, 10); +} + +private int asInt(byte[] input, int base) { +return Integer.parseInt(new String(input).trim(), base); } /*
svn commit: r807514 - in /commons/proper/compress/trunk/src: changes/changes.xml main/java/org/apache/commons/compress/archivers/tar/TarArchiveEntry.java
Author: bodewig Date: Tue Aug 25 08:11:44 2009 New Revision: 807514 URL: http://svn.apache.org/viewvc?rev=807514view=rev Log: The tar Ant task has a usecase where absolute paths inside archives are required - allow creation of such entries Modified: commons/proper/compress/trunk/src/changes/changes.xml commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/tar/TarArchiveEntry.java (contents, props changed) Modified: commons/proper/compress/trunk/src/changes/changes.xml URL: http://svn.apache.org/viewvc/commons/proper/compress/trunk/src/changes/changes.xml?rev=807514r1=807513r2=807514view=diff == --- commons/proper/compress/trunk/src/changes/changes.xml (original) +++ commons/proper/compress/trunk/src/changes/changes.xml Tue Aug 25 08:11:44 2009 @@ -23,6 +23,11 @@ /properties body release version=1.1 date=as in SVN description=Release 1.1 + action type=add date=2009-08-25 +A new constructor of TarArchiveEntry can create entries with +names that start with slashes - the default is to strip +leading slashes in order to create relative path names. + /action action issue=COMPRESS-83 type=fix date=2009-08-01 Delegate all read and write methods in GZip stream in order to speed up operations. 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=807514r1=807513r2=807514view=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 Tue Aug 25 08:11:44 2009 @@ -167,9 +167,21 @@ * @param name the entry name */ public TarArchiveEntry(String name) { +this(name, false); +} + +/** + * Construct an entry with only a name. This allows the programmer + * to construct the entry's header by hand. File is set to null. + * + * @param name the entry name + * @param preserveLeadingSlashes whether to allow leading slashes + * in the name. + */ +public TarArchiveEntry(String name, boolean preserveLeadingSlashes) { this(); -name = normalizeFileName(name); +name = normalizeFileName(name, preserveLeadingSlashes); boolean isDir = name.endsWith(/); this.devMajor = 0; @@ -208,7 +220,7 @@ * @param file The file that the entry represents. */ public TarArchiveEntry(File file) { -this(file, normalizeFileName(file.getPath())); +this(file, normalizeFileName(file.getPath(), false)); } /** @@ -320,7 +332,7 @@ * @param name This entry's new name. */ public void setName(String name) { -this.name = normalizeFileName(name); +this.name = normalizeFileName(name, false); } /** @@ -642,7 +654,8 @@ * Strips Windows' drive letter as well as any leading slashes, * turns path separators into forward slahes. */ -private static String normalizeFileName(String fileName) { +private static String normalizeFileName(String fileName, +boolean preserveLeadingSlashes) { String osname = System.getProperty(os.name).toLowerCase(Locale.US); if (osname != null) { @@ -674,7 +687,7 @@ // No absolute pathnames // Windows (and Posix?) paths can start with \\NetworkDrive\, // so we loop on starting /'s. -while (fileName.startsWith(/)) { +while (!preserveLeadingSlashes fileName.startsWith(/)) { fileName = fileName.substring(1); } return fileName; Propchange: commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/tar/TarArchiveEntry.java -- --- svn:mergeinfo (added) +++ svn:mergeinfo Tue Aug 25 08:11:44 2009 @@ -0,0 +1,2 @@ +/ant/core/trunk/src/main/org/apache/tools/tar/TarArchiveEntry.java:741089 +/ant/core/trunk/src/main/org/apache/tools/tar/TarEntry.java:807513
svn commit: r896818 - in /commons/proper/compress/trunk/src: changes/changes.xml main/java/org/apache/commons/compress/archivers/zip/ZipArchiveEntry.java test/java/org/apache/commons/compress/archiver
Author: bodewig Date: Thu Jan 7 09:34:55 2010 New Revision: 896818 URL: http://svn.apache.org/viewvc?rev=896818view=rev Log: ZipArchiveEntry#equals is broken if the String-arg constructor is used. COMPRESS-94 - submitted by Anon Devs Modified: commons/proper/compress/trunk/src/changes/changes.xml commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/zip/ZipArchiveEntry.java commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/archivers/zip/ZipArchiveEntryTest.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=896818r1=896817r2=896818view=diff == --- commons/proper/compress/trunk/src/changes/changes.xml (original) +++ commons/proper/compress/trunk/src/changes/changes.xml Thu Jan 7 09:34:55 2010 @@ -23,6 +23,12 @@ /properties body release version=1.1 date=as in SVN description=Release 1.1 + action type=fix issue=COMPRESS-94 date=2010-01-07 + due-to=Anon Devs +ZipArchiveEntry's equals method was broken for entries created +with the String-arg constructor. This lead to broken ZIP +archives if two different entries had the same hash code. + /action action type=fix issue=COMPRESS-87 date=2009-10-30 due-to=Antoni Mylka ZipArchiveInputStream could repeatedly return 0 on read() when Modified: commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/zip/ZipArchiveEntry.java URL: http://svn.apache.org/viewvc/commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/zip/ZipArchiveEntry.java?rev=896818r1=896817r2=896818view=diff == --- commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/zip/ZipArchiveEntry.java (original) +++ commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/zip/ZipArchiveEntry.java Thu Jan 7 09:34:55 2010 @@ -61,6 +61,7 @@ */ public ZipArchiveEntry(String name) { super(name); +setName(name); } /** @@ -96,7 +97,7 @@ /** */ protected ZipArchiveEntry() { -super(); +this(); } public ZipArchiveEntry(File inputFile, String entryName) { @@ -459,11 +460,13 @@ return false; } ZipArchiveEntry other = (ZipArchiveEntry) obj; -if (name == null) { -if (other.name != null) { +String myName = getName(); +String otherName = other.getName(); +if (myName == null) { +if (otherName != null) { return false; } -} else if (!name.equals(other.name)) { +} else if (!myName.equals(otherName)) { return false; } return true; Modified: commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/archivers/zip/ZipArchiveEntryTest.java URL: http://svn.apache.org/viewvc/commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/archivers/zip/ZipArchiveEntryTest.java?rev=896818r1=896817r2=896818view=diff == --- commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/archivers/zip/ZipArchiveEntryTest.java (original) +++ commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/archivers/zip/ZipArchiveEntryTest.java Thu Jan 7 09:34:55 2010 @@ -219,4 +219,14 @@ assertFalse(entry.isSupportedCompressionMethod()); } +/** + * Test case for + * a href=https://issues.apache.org/jira/browse/COMPRESS-94; + * COMPRESS-94/a. + */ +public void testNotEquals() { +ZipArchiveEntry entry1 = new ZipArchiveEntry(foo); +ZipArchiveEntry entry2 = new ZipArchiveEntry(bar); +assertFalse(entry1.equals(entry2)); +} }
svn commit: r903086 - /commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/zip/ZipArchiveEntry.java
Author: bodewig Date: Tue Jan 26 05:24:17 2010 New Revision: 903086 URL: http://svn.apache.org/viewvc?rev=903086view=rev Log: complete equals implementation. COMPRESS-94 Modified: commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/zip/ZipArchiveEntry.java Modified: commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/zip/ZipArchiveEntry.java URL: http://svn.apache.org/viewvc/commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/zip/ZipArchiveEntry.java?rev=903086r1=903085r2=903086view=diff == --- commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/zip/ZipArchiveEntry.java (original) +++ commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/zip/ZipArchiveEntry.java Tue Jan 26 05:24:17 2010 @@ -18,6 +18,7 @@ package org.apache.commons.compress.archivers.zip; import java.io.File; +import java.util.Arrays; import java.util.Date; import java.util.LinkedHashMap; import java.util.zip.ZipException; @@ -469,6 +470,26 @@ } else if (!myName.equals(otherName)) { return false; } -return true; +String myComment = getComment(); +String otherComment = other.getComment(); +if (myComment == null) { +if (otherComment != null) { +return false; +} +} else if (!myComment.equals(otherComment)) { +return false; +} +return getTime() == other.getTime() + getInternalAttributes() == other.getInternalAttributes() + getPlatform() == other.getPlatform() + getExternalAttributes() == other.getExternalAttributes() + getMethod() == other.getMethod() + getSize() == other.getSize() + getCrc() == other.getCrc() + getCompressedSize() == other.getCompressedSize() + Arrays.equals(getCentralDirectoryExtra(), + other.getCentralDirectoryExtra()) + Arrays.equals(getLocalFileDataExtra(), + other.getLocalFileDataExtra()); } }
svn commit: r908083 - /commons/proper/compress/trunk/doap_compress.rdf
Author: bodewig Date: Tue Feb 9 15:48:10 2010 New Revision: 908083 URL: http://svn.apache.org/viewvc?rev=908083view=rev Log: compress does tar as well Modified: commons/proper/compress/trunk/doap_compress.rdf Modified: commons/proper/compress/trunk/doap_compress.rdf URL: http://svn.apache.org/viewvc/commons/proper/compress/trunk/doap_compress.rdf?rev=908083r1=908082r2=908083view=diff == --- commons/proper/compress/trunk/doap_compress.rdf (original) +++ commons/proper/compress/trunk/doap_compress.rdf Tue Feb 9 15:48:10 2010 @@ -26,7 +26,7 @@ download-page rdf:resource=http://commons.apache.org/downloads/download_compress.cgi/ asfext:pmc rdf:resource=http://commons.apache.org// shortdesc xml:lang=enCommons Compress/shortdesc -description xml:lang=enCommons Compress: working with zip, ar, jar, bz2, cpio and gz files./description +description xml:lang=enCommons Compress: working with zip, ar, jar, bz2, cpio, tar and gz files./description repository SVNRepository browse rdf:resource=http://svn.apache.org/repos/asf/commons/proper/compress/trunk/
svn commit: r740604 - /commons/sandbox/compress/trunk/src/main/java/org/apache/commons/compress/archivers/zip/ZipFile.java
Author: bodewig Date: Wed Feb 4 04:56:10 2009 New Revision: 740604 URL: http://svn.apache.org/viewvc?rev=740604view=rev Log: merge revision 738853 from Ant - [SANDBOX-276] Modified: commons/sandbox/compress/trunk/src/main/java/org/apache/commons/compress/archivers/zip/ZipFile.java (contents, props changed) Modified: commons/sandbox/compress/trunk/src/main/java/org/apache/commons/compress/archivers/zip/ZipFile.java URL: http://svn.apache.org/viewvc/commons/sandbox/compress/trunk/src/main/java/org/apache/commons/compress/archivers/zip/ZipFile.java?rev=740604r1=740603r2=740604view=diff == --- commons/sandbox/compress/trunk/src/main/java/org/apache/commons/compress/archivers/zip/ZipFile.java (original) +++ commons/sandbox/compress/trunk/src/main/java/org/apache/commons/compress/archivers/zip/ZipFile.java Wed Feb 4 04:56:10 2009 @@ -147,16 +147,19 @@ public ZipFile(File f, String encoding) throws IOException { this.encoding = encoding; archive = new RandomAccessFile(f, r); +boolean success = false; try { populateFromCentralDirectory(); resolveLocalFileHeaderData(); -} catch (IOException e) { -try { -archive.close(); -} catch (IOException e2) { -// swallow, throw the original exception instead +success = true; +} finally { +if (!success) { +try { +archive.close(); +} catch (IOException e2) { +// swallow, throw the original exception instead +} } -throw e; } } Propchange: commons/sandbox/compress/trunk/src/main/java/org/apache/commons/compress/archivers/zip/ZipFile.java -- --- svn:mergeinfo (added) +++ svn:mergeinfo Wed Feb 4 04:56:10 2009 @@ -0,0 +1 @@ +/ant/core/trunk/src/main/org/apache/tools/zip/ZipFile.java:738853
svn commit: r740605 - in /commons/sandbox/compress/trunk/src/main/java/org/apache/commons/compress/archivers/zip: ./ ExtraFieldUtils.java ZipEntry.java ZipExtraField.java ZipFile.java
Author: bodewig Date: Wed Feb 4 05:02:08 2009 New Revision: 740605 URL: http://svn.apache.org/viewvc?rev=740605view=rev Log: merge revision 739300 from Ant - [SANDBOX-276] Modified: commons/sandbox/compress/trunk/src/main/java/org/apache/commons/compress/archivers/zip/ (props changed) commons/sandbox/compress/trunk/src/main/java/org/apache/commons/compress/archivers/zip/ExtraFieldUtils.java commons/sandbox/compress/trunk/src/main/java/org/apache/commons/compress/archivers/zip/ZipEntry.java commons/sandbox/compress/trunk/src/main/java/org/apache/commons/compress/archivers/zip/ZipExtraField.java commons/sandbox/compress/trunk/src/main/java/org/apache/commons/compress/archivers/zip/ZipFile.java (props changed) Propchange: commons/sandbox/compress/trunk/src/main/java/org/apache/commons/compress/archivers/zip/ -- svn:mergeinfo = /ant/core/trunk/src/main/org/apache/tools/zip:739300 Modified: commons/sandbox/compress/trunk/src/main/java/org/apache/commons/compress/archivers/zip/ExtraFieldUtils.java URL: http://svn.apache.org/viewvc/commons/sandbox/compress/trunk/src/main/java/org/apache/commons/compress/archivers/zip/ExtraFieldUtils.java?rev=740605r1=740604r2=740605view=diff == --- commons/sandbox/compress/trunk/src/main/java/org/apache/commons/compress/archivers/zip/ExtraFieldUtils.java (original) +++ commons/sandbox/compress/trunk/src/main/java/org/apache/commons/compress/archivers/zip/ExtraFieldUtils.java Wed Feb 4 05:02:08 2009 @@ -114,10 +114,6 @@ } start += (length + WORD); } -if (start != data.length) { // array not exhausted -throw new ZipException(data starting at + start -+ is in unknown format); -} ZipExtraField[] result = new ZipExtraField[v.size()]; v.copyInto(result); Modified: commons/sandbox/compress/trunk/src/main/java/org/apache/commons/compress/archivers/zip/ZipEntry.java URL: http://svn.apache.org/viewvc/commons/sandbox/compress/trunk/src/main/java/org/apache/commons/compress/archivers/zip/ZipEntry.java?rev=740605r1=740604r2=740605view=diff == --- commons/sandbox/compress/trunk/src/main/java/org/apache/commons/compress/archivers/zip/ZipEntry.java (original) +++ commons/sandbox/compress/trunk/src/main/java/org/apache/commons/compress/archivers/zip/ZipEntry.java Wed Feb 4 05:02:08 2009 @@ -269,7 +269,7 @@ try { setExtraFields(ExtraFieldUtils.parse(extra)); } catch (Exception e) { -throw new RuntimeException(e.getMessage()); +throw new RuntimeException(e.getMessage(), e); } } Modified: commons/sandbox/compress/trunk/src/main/java/org/apache/commons/compress/archivers/zip/ZipExtraField.java URL: http://svn.apache.org/viewvc/commons/sandbox/compress/trunk/src/main/java/org/apache/commons/compress/archivers/zip/ZipExtraField.java?rev=740605r1=740604r2=740605view=diff == --- commons/sandbox/compress/trunk/src/main/java/org/apache/commons/compress/archivers/zip/ZipExtraField.java (original) +++ commons/sandbox/compress/trunk/src/main/java/org/apache/commons/compress/archivers/zip/ZipExtraField.java Wed Feb 4 05:02:08 2009 @@ -66,8 +66,8 @@ byte[] getLocalFileDataData(); /** - * The actual data to put central directory - without Header-ID or length - * specifier. + * The actual data to put into central directory - without Header-ID or + * length specifier. * * @return The CentralDirectoryData value * @since 1.1 Propchange: commons/sandbox/compress/trunk/src/main/java/org/apache/commons/compress/archivers/zip/ZipFile.java -- --- svn:mergeinfo (original) +++ svn:mergeinfo Wed Feb 4 05:02:08 2009 @@ -1 +1 @@ -/ant/core/trunk/src/main/org/apache/tools/zip/ZipFile.java:738853 +/ant/core/trunk/src/main/org/apache/tools/zip/ZipFile.java:738853,739300
svn commit: r740657 - in /commons/sandbox/compress/trunk/src/main/java/org/apache/commons/compress/archivers/zip: ./ ExtraFieldUtils.java ZipEntry.java ZipFile.java ZipOutputStream.java
Author: bodewig Date: Wed Feb 4 08:45:31 2009 New Revision: 740657 URL: http://svn.apache.org/viewvc?rev=740657view=rev Log: [SANDBOX-256] - merge revision 738844 from Ant - use JDK 1.4+ collections Modified: commons/sandbox/compress/trunk/src/main/java/org/apache/commons/compress/archivers/zip/ (props changed) commons/sandbox/compress/trunk/src/main/java/org/apache/commons/compress/archivers/zip/ExtraFieldUtils.java commons/sandbox/compress/trunk/src/main/java/org/apache/commons/compress/archivers/zip/ZipEntry.java commons/sandbox/compress/trunk/src/main/java/org/apache/commons/compress/archivers/zip/ZipFile.java (contents, props changed) commons/sandbox/compress/trunk/src/main/java/org/apache/commons/compress/archivers/zip/ZipOutputStream.java Propchange: commons/sandbox/compress/trunk/src/main/java/org/apache/commons/compress/archivers/zip/ -- --- svn:mergeinfo (original) +++ svn:mergeinfo Wed Feb 4 08:45:31 2009 @@ -1 +1 @@ -/ant/core/trunk/src/main/org/apache/tools/zip:739300 +/ant/core/trunk/src/main/org/apache/tools/zip:738844,739300 Modified: commons/sandbox/compress/trunk/src/main/java/org/apache/commons/compress/archivers/zip/ExtraFieldUtils.java URL: http://svn.apache.org/viewvc/commons/sandbox/compress/trunk/src/main/java/org/apache/commons/compress/archivers/zip/ExtraFieldUtils.java?rev=740657r1=740656r2=740657view=diff == --- commons/sandbox/compress/trunk/src/main/java/org/apache/commons/compress/archivers/zip/ExtraFieldUtils.java (original) +++ commons/sandbox/compress/trunk/src/main/java/org/apache/commons/compress/archivers/zip/ExtraFieldUtils.java Wed Feb 4 08:45:31 2009 @@ -17,8 +17,10 @@ */ package org.apache.commons.compress.archivers.zip; -import java.util.Hashtable; -import java.util.Vector; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; import java.util.zip.ZipException; /** @@ -35,10 +37,10 @@ * * @since 1.1 */ -private static Hashtable implementations; +private static final Map implementations; static { -implementations = new Hashtable(); +implementations = new HashMap(); register(AsiExtraField.class); register(JarMarker.class); } @@ -94,7 +96,7 @@ * @throws ZipException on error */ public static ZipExtraField[] parse(byte[] data) throws ZipException { -Vector v = new Vector(); +List v = new ArrayList(); int start = 0; while (start = data.length - WORD) { ZipShort headerId = new ZipShort(data, start); @@ -106,7 +108,7 @@ try { ZipExtraField ze = createExtraField(headerId); ze.parseFromLocalFileData(data, start + WORD, length); -v.addElement(ze); +v.add(ze); } catch (InstantiationException ie) { throw new ZipException(ie.getMessage()); } catch (IllegalAccessException iae) { @@ -116,8 +118,7 @@ } ZipExtraField[] result = new ZipExtraField[v.size()]; -v.copyInto(result); -return result; +return (ZipExtraField[]) v.toArray(result); } /** Modified: commons/sandbox/compress/trunk/src/main/java/org/apache/commons/compress/archivers/zip/ZipEntry.java URL: http://svn.apache.org/viewvc/commons/sandbox/compress/trunk/src/main/java/org/apache/commons/compress/archivers/zip/ZipEntry.java?rev=740657r1=740656r2=740657view=diff == --- commons/sandbox/compress/trunk/src/main/java/org/apache/commons/compress/archivers/zip/ZipEntry.java (original) +++ commons/sandbox/compress/trunk/src/main/java/org/apache/commons/compress/archivers/zip/ZipEntry.java Wed Feb 4 08:45:31 2009 @@ -17,7 +17,7 @@ */ package org.apache.commons.compress.archivers.zip; -import java.util.Vector; +import java.util.LinkedHashMap; import java.util.zip.ZipException; /** @@ -35,7 +35,7 @@ private int internalAttributes = 0; private int platform = PLATFORM_FAT; private long externalAttributes = 0; -private Vector/*ZipExtraField*/ extraFields = null; +private LinkedHashMap/*ZipShort, ZipExtraField*/ extraFields = null; private String name = null; /** @@ -92,7 +92,7 @@ public Object clone() { ZipEntry e = (ZipEntry) super.clone(); -e.extraFields = extraFields != null ? (Vector) extraFields.clone() : null; +e.extraFields = extraFields != null ? (LinkedHashMap) extraFields.clone() : null; e.setInternalAttributes(getInternalAttributes()); e.setExternalAttributes(getExternalAttributes()); e.setExtraFields(getExtraFields()); @@ -191,9 +191,9 @@ * @since 1.1 */ public
svn commit: r741075 - in /commons/sandbox/compress/trunk: pom.xml src/main/java/org/apache/commons/compress/archivers/zip/ZipArchiveInputStream.java src/main/java/org/apache/commons/compress/compresso
Author: bodewig Date: Thu Feb 5 11:01:35 2009 New Revision: 741075 URL: http://svn.apache.org/viewvc?rev=741075view=rev Log: some indentation changes and add myself to the POM Modified: commons/sandbox/compress/trunk/pom.xml commons/sandbox/compress/trunk/src/main/java/org/apache/commons/compress/archivers/zip/ZipArchiveInputStream.java commons/sandbox/compress/trunk/src/main/java/org/apache/commons/compress/compressors/bzip2/BZip2CompressorOutputStream.java Modified: commons/sandbox/compress/trunk/pom.xml URL: http://svn.apache.org/viewvc/commons/sandbox/compress/trunk/pom.xml?rev=741075r1=741074r2=741075view=diff == --- commons/sandbox/compress/trunk/pom.xml (original) +++ commons/sandbox/compress/trunk/pom.xml Thu Feb 5 11:01:35 2009 @@ -51,6 +51,11 @@ idbayard/id emailbayard at apache.org/email /developer +developer + nameStefan Bodewig/name + idbodewig/id + emailbodewig at apache.org/email +/developer /developers contributors Modified: commons/sandbox/compress/trunk/src/main/java/org/apache/commons/compress/archivers/zip/ZipArchiveInputStream.java URL: http://svn.apache.org/viewvc/commons/sandbox/compress/trunk/src/main/java/org/apache/commons/compress/archivers/zip/ZipArchiveInputStream.java?rev=741075r1=741074r2=741075view=diff == --- commons/sandbox/compress/trunk/src/main/java/org/apache/commons/compress/archivers/zip/ZipArchiveInputStream.java (original) +++ commons/sandbox/compress/trunk/src/main/java/org/apache/commons/compress/archivers/zip/ZipArchiveInputStream.java Thu Feb 5 11:01:35 2009 @@ -27,11 +27,11 @@ public class ZipArchiveInputStream extends ArchiveInputStream { - private final ZipInputStream input; +private final ZipInputStream input; - public ZipArchiveInputStream(InputStream inputStream) { - input = new ZipInputStream(inputStream); - } +public ZipArchiveInputStream(InputStream inputStream) { +input = new ZipInputStream(inputStream); +} public ArchiveEntry getNextEntry() throws IOException { java.util.zip.ZipEntry entry = input.getNextEntry(); Modified: commons/sandbox/compress/trunk/src/main/java/org/apache/commons/compress/compressors/bzip2/BZip2CompressorOutputStream.java URL: http://svn.apache.org/viewvc/commons/sandbox/compress/trunk/src/main/java/org/apache/commons/compress/compressors/bzip2/BZip2CompressorOutputStream.java?rev=741075r1=741074r2=741075view=diff == --- commons/sandbox/compress/trunk/src/main/java/org/apache/commons/compress/compressors/bzip2/BZip2CompressorOutputStream.java (original) +++ commons/sandbox/compress/trunk/src/main/java/org/apache/commons/compress/compressors/bzip2/BZip2CompressorOutputStream.java Thu Feb 5 11:01:35 2009 @@ -28,7 +28,7 @@ * header chars) into another stream. TODO: Update to BZip2 1.0.1 */ public class BZip2CompressorOutputStream extends CompressorOutputStream implements BZip2Constants { - protected static final int SETMASK = (1 21); +protected static final int SETMASK = (1 21); protected static final int CLEARMASK = (~SETMASK); protected static final int GREATER_ICOST = 15; protected static final int LESSER_ICOST = 0;
svn commit: r741092 - in /commons/sandbox/compress/trunk/src/main/java/org/apache/commons/compress: archivers/tar/ archivers/zip/ compressors/bzip2/
Author: bodewig Date: Thu Feb 5 12:45:23 2009 New Revision: 741092 URL: http://svn.apache.org/viewvc?rev=741092view=rev Log: merge revision 741089 from Ant trunk - fix for various findbugs issues - [SANDBOX-246] Modified: commons/sandbox/compress/trunk/src/main/java/org/apache/commons/compress/archivers/tar/ (props changed) commons/sandbox/compress/trunk/src/main/java/org/apache/commons/compress/archivers/tar/TarInputStream.java commons/sandbox/compress/trunk/src/main/java/org/apache/commons/compress/archivers/tar/TarOutputStream.java commons/sandbox/compress/trunk/src/main/java/org/apache/commons/compress/archivers/zip/ (props changed) commons/sandbox/compress/trunk/src/main/java/org/apache/commons/compress/archivers/zip/AsiExtraField.java commons/sandbox/compress/trunk/src/main/java/org/apache/commons/compress/archivers/zip/UnrecognizedExtraField.java commons/sandbox/compress/trunk/src/main/java/org/apache/commons/compress/archivers/zip/ZipFile.java (contents, props changed) commons/sandbox/compress/trunk/src/main/java/org/apache/commons/compress/archivers/zip/ZipLong.java commons/sandbox/compress/trunk/src/main/java/org/apache/commons/compress/archivers/zip/ZipShort.java commons/sandbox/compress/trunk/src/main/java/org/apache/commons/compress/compressors/bzip2/BZip2CompressorOutputStream.java (contents, props changed) Propchange: commons/sandbox/compress/trunk/src/main/java/org/apache/commons/compress/archivers/tar/ -- svn:mergeinfo = /ant/core/trunk/src/main/org/apache/tools/tar:741089 Modified: commons/sandbox/compress/trunk/src/main/java/org/apache/commons/compress/archivers/tar/TarInputStream.java URL: http://svn.apache.org/viewvc/commons/sandbox/compress/trunk/src/main/java/org/apache/commons/compress/archivers/tar/TarInputStream.java?rev=741092r1=741091r2=741092view=diff == --- commons/sandbox/compress/trunk/src/main/java/org/apache/commons/compress/archivers/tar/TarInputStream.java (original) +++ commons/sandbox/compress/trunk/src/main/java/org/apache/commons/compress/archivers/tar/TarInputStream.java Thu Feb 5 12:45:23 2009 @@ -218,8 +218,13 @@ + numToSkip + bytes); } -if (numToSkip 0) { -skip(numToSkip); +while (numToSkip 0) { +long skipped = skip(numToSkip); +if (skipped = 0) { +throw new RuntimeException(failed to skip current tar + + entry); +} +numToSkip -= skipped; } readBuf = null; Modified: commons/sandbox/compress/trunk/src/main/java/org/apache/commons/compress/archivers/tar/TarOutputStream.java URL: http://svn.apache.org/viewvc/commons/sandbox/compress/trunk/src/main/java/org/apache/commons/compress/archivers/tar/TarOutputStream.java?rev=741092r1=741091r2=741092view=diff == --- commons/sandbox/compress/trunk/src/main/java/org/apache/commons/compress/archivers/tar/TarOutputStream.java (original) +++ commons/sandbox/compress/trunk/src/main/java/org/apache/commons/compress/archivers/tar/TarOutputStream.java Thu Feb 5 12:45:23 2009 @@ -305,7 +305,7 @@ wOffset += numToWrite; assemLen += numToWrite; -numToWrite -= numToWrite; +numToWrite = 0; } } Propchange: commons/sandbox/compress/trunk/src/main/java/org/apache/commons/compress/archivers/zip/ -- --- svn:mergeinfo (original) +++ svn:mergeinfo Thu Feb 5 12:45:23 2009 @@ -1 +1 @@ -/ant/core/trunk/src/main/org/apache/tools/zip:738844,739300 +/ant/core/trunk/src/main/org/apache/tools/zip:738844,739300,741089 Modified: commons/sandbox/compress/trunk/src/main/java/org/apache/commons/compress/archivers/zip/AsiExtraField.java URL: http://svn.apache.org/viewvc/commons/sandbox/compress/trunk/src/main/java/org/apache/commons/compress/archivers/zip/AsiExtraField.java?rev=741092r1=741091r2=741092view=diff == --- commons/sandbox/compress/trunk/src/main/java/org/apache/commons/compress/archivers/zip/AsiExtraField.java (original) +++ commons/sandbox/compress/trunk/src/main/java/org/apache/commons/compress/archivers/zip/AsiExtraField.java Thu Feb 5 12:45:23 2009 @@ -334,4 +334,14 @@ return type | (mode PERM_MASK); } +public Object clone() { +try { +AsiExtraField cloned = (AsiExtraField) super.clone(); +cloned.crc = new CRC32(); +return cloned; +} catch (CloneNotSupportedException cnfe
svn commit: r741095 - in /commons/sandbox/compress/trunk/src/main/java/org/apache/commons/compress/archivers: ArchiveStreamFactory.java cpio/CpioArchiveEntry.java cpio/CpioArchiveOutputStream.java jar
Author: bodewig Date: Thu Feb 5 13:00:07 2009 New Revision: 741095 URL: http://svn.apache.org/viewvc?rev=741095view=rev Log: fix some findbugs issues - SANDBOX-246 Modified: commons/sandbox/compress/trunk/src/main/java/org/apache/commons/compress/archivers/ArchiveStreamFactory.java commons/sandbox/compress/trunk/src/main/java/org/apache/commons/compress/archivers/cpio/CpioArchiveEntry.java commons/sandbox/compress/trunk/src/main/java/org/apache/commons/compress/archivers/cpio/CpioArchiveOutputStream.java commons/sandbox/compress/trunk/src/main/java/org/apache/commons/compress/archivers/jar/JarArchiveEntry.java commons/sandbox/compress/trunk/src/main/java/org/apache/commons/compress/archivers/zip/ZipArchiveEntry.java Modified: commons/sandbox/compress/trunk/src/main/java/org/apache/commons/compress/archivers/ArchiveStreamFactory.java URL: http://svn.apache.org/viewvc/commons/sandbox/compress/trunk/src/main/java/org/apache/commons/compress/archivers/ArchiveStreamFactory.java?rev=741095r1=741094r2=741095view=diff == --- commons/sandbox/compress/trunk/src/main/java/org/apache/commons/compress/archivers/ArchiveStreamFactory.java (original) +++ commons/sandbox/compress/trunk/src/main/java/org/apache/commons/compress/archivers/ArchiveStreamFactory.java Thu Feb 5 13:00:07 2009 @@ -80,8 +80,9 @@ final byte[] signature = new byte[12]; input.mark(signature.length); - input.read(signature); + int signatureLength = input.read(signature); // TODO if reset is not supported pass on the IOException or return null? +// TODO, what if we failed to read 12 bytes? input.reset(); if(ZipArchiveInputStream.matches(signature)) { Modified: commons/sandbox/compress/trunk/src/main/java/org/apache/commons/compress/archivers/cpio/CpioArchiveEntry.java URL: http://svn.apache.org/viewvc/commons/sandbox/compress/trunk/src/main/java/org/apache/commons/compress/archivers/cpio/CpioArchiveEntry.java?rev=741095r1=741094r2=741095view=diff == --- commons/sandbox/compress/trunk/src/main/java/org/apache/commons/compress/archivers/cpio/CpioArchiveEntry.java (original) +++ commons/sandbox/compress/trunk/src/main/java/org/apache/commons/compress/archivers/cpio/CpioArchiveEntry.java Thu Feb 5 13:00:07 2009 @@ -535,7 +535,11 @@ case C_ISNWK: break; default: -new IllegalArgumentException(Unknown mode); +// FIXME: testCpioUnarchive fails if I change the line to +//actually throw the excpetion +new IllegalArgumentException(Unknown mode (full mode: + + mode + , masked mode: + + (mode S_IFMT)); } this.mode = mode; Modified: commons/sandbox/compress/trunk/src/main/java/org/apache/commons/compress/archivers/cpio/CpioArchiveOutputStream.java URL: http://svn.apache.org/viewvc/commons/sandbox/compress/trunk/src/main/java/org/apache/commons/compress/archivers/cpio/CpioArchiveOutputStream.java?rev=741095r1=741094r2=741095view=diff == --- commons/sandbox/compress/trunk/src/main/java/org/apache/commons/compress/archivers/cpio/CpioArchiveOutputStream.java (original) +++ commons/sandbox/compress/trunk/src/main/java/org/apache/commons/compress/archivers/cpio/CpioArchiveOutputStream.java Thu Feb 5 13:00:07 2009 @@ -121,7 +121,9 @@ throw new IllegalArgumentException(Unknown header type); } -this.entryFormat = format; +synchronized (this) { +this.entryFormat = format; +} } /** @@ -135,7 +137,7 @@ * @throws IOException if an I/O error has occurred or if a CPIO file error has * occurred */ -public void putNextEntry(final CpioArchiveEntry e) throws IOException { +public synchronized void putNextEntry(final CpioArchiveEntry e) throws IOException { ensureOpen(); if (this.cpioEntry != null) { closeEntry(); // close previous entry @@ -233,7 +235,7 @@ * @throws IOException if an I/O error has occurred or if a CPIO file error has * occurred */ -public void closeEntry() throws IOException { +public synchronized void closeEntry() throws IOException { ensureOpen(); if (this.cpioEntry.getSize() != this.written) { @@ -251,9 +253,7 @@ throw new IOException(CRC Error); } } -if (this.cpioEntry != null) { -this.cpioEntry = null; -} +this.cpioEntry = null; this.crc = 0; this.written
svn commit: r741475 - in /commons/sandbox/compress/trunk/src/main/java/org/apache/commons/compress/archivers: ar/ArArchiveInputStream.java cpio/CpioArchiveInputStream.java jar/JarArchiveInputStream.ja
Author: bodewig Date: Fri Feb 6 08:54:45 2009 New Revision: 741475 URL: http://svn.apache.org/viewvc?rev=741475view=rev Log: whitespace only Modified: commons/sandbox/compress/trunk/src/main/java/org/apache/commons/compress/archivers/ar/ArArchiveInputStream.java commons/sandbox/compress/trunk/src/main/java/org/apache/commons/compress/archivers/cpio/CpioArchiveInputStream.java commons/sandbox/compress/trunk/src/main/java/org/apache/commons/compress/archivers/jar/JarArchiveInputStream.java commons/sandbox/compress/trunk/src/main/java/org/apache/commons/compress/archivers/tar/TarArchiveInputStream.java Modified: commons/sandbox/compress/trunk/src/main/java/org/apache/commons/compress/archivers/ar/ArArchiveInputStream.java URL: http://svn.apache.org/viewvc/commons/sandbox/compress/trunk/src/main/java/org/apache/commons/compress/archivers/ar/ArArchiveInputStream.java?rev=741475r1=741474r2=741475view=diff == --- commons/sandbox/compress/trunk/src/main/java/org/apache/commons/compress/archivers/ar/ArArchiveInputStream.java (original) +++ commons/sandbox/compress/trunk/src/main/java/org/apache/commons/compress/archivers/ar/ArArchiveInputStream.java Fri Feb 6 08:54:45 2009 @@ -26,117 +26,117 @@ public class ArArchiveInputStream extends ArchiveInputStream { - private final InputStream input; - private long offset = 0; - - public ArArchiveInputStream( final InputStream pInput ) { - input = pInput; - } - - public ArchiveEntry getNextEntry() throws IOException { - - if (offset == 0) { - final byte[] expected = !arch\n.getBytes(); - final byte[] realized = new byte[expected.length]; - final int read = read(realized); - if (read != expected.length) { - throw new IOException(failed to read header); - } - for (int i = 0; i expected.length; i++) { - if (expected[i] != realized[i]) { - throw new IOException(invalid header + new String(realized)); - } - } - } - - if (input.available() == 0) { - return null; - } - - if (offset % 2 != 0) { - read(); - } - - final byte[] name = new byte[16]; - final byte[] lastmodified = new byte[12]; - final byte[] userid = new byte[6]; - final byte[] groupid = new byte[6]; - final byte[] filemode = new byte[8]; - final byte[] length = new byte[10]; - - read(name); - read(lastmodified); - read(userid); - read(groupid); - read(filemode); - read(length); - - { - final byte[] expected = `\012.getBytes(); - final byte[] realized = new byte[expected.length]; - final int read = read(realized); - if (read != expected.length) { - throw new IOException(failed to read entry header); - } - for (int i = 0; i expected.length; i++) { - if (expected[i] != realized[i]) { - throw new IOException(invalid entry header. not read the content?); - } - } - } - - return new ArArchiveEntry(new String(name).trim(), Long.parseLong(new String(length).trim())); - - } - - - public int read() throws IOException { - final int ret = input.read(); - offset++; - return ret; - } - - public int read(byte b[]) throws IOException { - final int ret = read(b, 0, b.length); - offset = offset + b.length; - return ret; - } - - public int read(byte[] b, int off, int len) throws IOException { - final int ret = this.input.read(b, off, len); - offset = offset + off; - return ret; - } - - public static boolean matches( byte[] signature ) { - // 3c21 7261 6863 0a3e - - if (signature[0] != 0x21) { - return false; - } - if (signature[1] != 0x3c) { - return false; - } - if (signature[2] != 0x61) { - return false; - } - if (signature[3] != 0x72
svn commit: r741637 - in /commons/sandbox/compress/trunk/src: main/java/org/apache/commons/compress/archivers/jar/ main/java/org/apache/commons/compress/archivers/zip/ test/java/org/apache/commons/com
Author: bodewig Date: Fri Feb 6 17:11:40 2009 New Revision: 741637 URL: http://svn.apache.org/viewvc?rev=741637view=rev Log: rename ZipEntry to ZipArchiveEntry Added: commons/sandbox/compress/trunk/src/main/java/org/apache/commons/compress/archivers/zip/ZipArchiveEntry.java (contents, props changed) - copied, changed from r741632, commons/sandbox/compress/trunk/src/main/java/org/apache/commons/compress/archivers/zip/ZipEntry.java Removed: commons/sandbox/compress/trunk/src/main/java/org/apache/commons/compress/archivers/zip/ZipEntry.java Modified: commons/sandbox/compress/trunk/src/main/java/org/apache/commons/compress/archivers/jar/JarArchiveEntry.java commons/sandbox/compress/trunk/src/main/java/org/apache/commons/compress/archivers/jar/JarArchiveInputStream.java commons/sandbox/compress/trunk/src/main/java/org/apache/commons/compress/archivers/jar/JarArchiveOutputStream.java commons/sandbox/compress/trunk/src/main/java/org/apache/commons/compress/archivers/zip/ZipArchiveInputStream.java commons/sandbox/compress/trunk/src/main/java/org/apache/commons/compress/archivers/zip/ZipArchiveOutputStream.java commons/sandbox/compress/trunk/src/main/java/org/apache/commons/compress/archivers/zip/ZipFile.java commons/sandbox/compress/trunk/src/main/java/org/apache/commons/compress/archivers/zip/ZipOutputStream.java commons/sandbox/compress/trunk/src/test/java/org/apache/commons/compress/archivers/JarTestCase.java commons/sandbox/compress/trunk/src/test/java/org/apache/commons/compress/archivers/ZipTestCase.java commons/sandbox/compress/trunk/src/test/java/org/apache/commons/compress/changes/ChangeSetTestCase.java Modified: commons/sandbox/compress/trunk/src/main/java/org/apache/commons/compress/archivers/jar/JarArchiveEntry.java URL: http://svn.apache.org/viewvc/commons/sandbox/compress/trunk/src/main/java/org/apache/commons/compress/archivers/jar/JarArchiveEntry.java?rev=741637r1=741636r2=741637view=diff == --- commons/sandbox/compress/trunk/src/main/java/org/apache/commons/compress/archivers/jar/JarArchiveEntry.java (original) +++ commons/sandbox/compress/trunk/src/main/java/org/apache/commons/compress/archivers/jar/JarArchiveEntry.java Fri Feb 6 17:11:40 2009 @@ -21,17 +21,18 @@ import java.security.cert.Certificate; import java.util.jar.Attributes; import java.util.jar.JarEntry; +import java.util.zip.ZipEntry; import java.util.zip.ZipException; import org.apache.commons.compress.archivers.ArchiveEntry; -import org.apache.commons.compress.archivers.zip.ZipEntry; +import org.apache.commons.compress.archivers.zip.ZipArchiveEntry; -public class JarArchiveEntry extends ZipEntry implements ArchiveEntry { +public class JarArchiveEntry extends ZipArchiveEntry implements ArchiveEntry { private Attributes manifestAttributes = null; private Certificate[] certificates = null; - public JarArchiveEntry(java.util.zip.ZipEntry entry) throws ZipException { + public JarArchiveEntry(ZipEntry entry) throws ZipException { super(entry); } @@ -39,7 +40,7 @@ super(name); } - public JarArchiveEntry(ZipEntry entry) throws ZipException { + public JarArchiveEntry(ZipArchiveEntry entry) throws ZipException { super(entry); } Modified: commons/sandbox/compress/trunk/src/main/java/org/apache/commons/compress/archivers/jar/JarArchiveInputStream.java URL: http://svn.apache.org/viewvc/commons/sandbox/compress/trunk/src/main/java/org/apache/commons/compress/archivers/jar/JarArchiveInputStream.java?rev=741637r1=741636r2=741637view=diff == --- commons/sandbox/compress/trunk/src/main/java/org/apache/commons/compress/archivers/jar/JarArchiveInputStream.java (original) +++ commons/sandbox/compress/trunk/src/main/java/org/apache/commons/compress/archivers/jar/JarArchiveInputStream.java Fri Feb 6 17:11:40 2009 @@ -22,7 +22,7 @@ import java.io.InputStream; import org.apache.commons.compress.archivers.ArchiveEntry; -import org.apache.commons.compress.archivers.zip.ZipEntry; +import org.apache.commons.compress.archivers.zip.ZipArchiveEntry; import org.apache.commons.compress.archivers.zip.ZipArchiveInputStream; public class JarArchiveInputStream extends ZipArchiveInputStream { @@ -32,7 +32,7 @@ } public ArchiveEntry getNextEntry() throws IOException { -ZipEntry entry = (ZipEntry)super.getNextEntry(); +ZipArchiveEntry entry = (ZipArchiveEntry)super.getNextEntry(); if(entry == null) { return null; } else { Modified: commons/sandbox/compress/trunk/src/main/java/org/apache/commons/compress/archivers/jar/JarArchiveOutputStream.java URL: http://svn.apache.org/viewvc/commons/sandbox/compress/trunk/src/main/java
svn commit: r741641 - in /commons/sandbox/compress/trunk/src/main/java/org/apache/commons/compress/archivers: ./ ar/ cpio/ jar/ tar/ zip/
Author: bodewig Date: Fri Feb 6 17:24:01 2009 New Revision: 741641 URL: http://svn.apache.org/viewvc?rev=741641view=rev Log: merge ZipArchiveOutputStream and ZipOutputStream Removed: commons/sandbox/compress/trunk/src/main/java/org/apache/commons/compress/archivers/zip/ZipArchiveOutputStream.java Modified: commons/sandbox/compress/trunk/src/main/java/org/apache/commons/compress/archivers/ArchiveOutputStream.java commons/sandbox/compress/trunk/src/main/java/org/apache/commons/compress/archivers/ArchiveStreamFactory.java commons/sandbox/compress/trunk/src/main/java/org/apache/commons/compress/archivers/ar/ArArchiveOutputStream.java commons/sandbox/compress/trunk/src/main/java/org/apache/commons/compress/archivers/cpio/CpioArchiveOutputStream.java commons/sandbox/compress/trunk/src/main/java/org/apache/commons/compress/archivers/jar/JarArchiveOutputStream.java commons/sandbox/compress/trunk/src/main/java/org/apache/commons/compress/archivers/tar/TarArchiveOutputStream.java commons/sandbox/compress/trunk/src/main/java/org/apache/commons/compress/archivers/zip/ZipOutputStream.java Modified: commons/sandbox/compress/trunk/src/main/java/org/apache/commons/compress/archivers/ArchiveOutputStream.java URL: http://svn.apache.org/viewvc/commons/sandbox/compress/trunk/src/main/java/org/apache/commons/compress/archivers/ArchiveOutputStream.java?rev=741641r1=741640r2=741641view=diff == --- commons/sandbox/compress/trunk/src/main/java/org/apache/commons/compress/archivers/ArchiveOutputStream.java (original) +++ commons/sandbox/compress/trunk/src/main/java/org/apache/commons/compress/archivers/ArchiveOutputStream.java Fri Feb 6 17:24:01 2009 @@ -19,11 +19,16 @@ package org.apache.commons.compress.archivers; import java.io.IOException; +import java.io.FilterOutputStream; import java.io.OutputStream; -public abstract class ArchiveOutputStream extends OutputStream { +public abstract class ArchiveOutputStream extends FilterOutputStream { - public abstract void putArchiveEntry(ArchiveEntry entry) throws IOException; +protected ArchiveOutputStream(OutputStream other) { +super(other); +} + +public abstract void putArchiveEntry(ArchiveEntry entry) throws IOException; public abstract void closeArchiveEntry() throws IOException; } Modified: commons/sandbox/compress/trunk/src/main/java/org/apache/commons/compress/archivers/ArchiveStreamFactory.java URL: http://svn.apache.org/viewvc/commons/sandbox/compress/trunk/src/main/java/org/apache/commons/compress/archivers/ArchiveStreamFactory.java?rev=741641r1=741640r2=741641view=diff == --- commons/sandbox/compress/trunk/src/main/java/org/apache/commons/compress/archivers/ArchiveStreamFactory.java (original) +++ commons/sandbox/compress/trunk/src/main/java/org/apache/commons/compress/archivers/ArchiveStreamFactory.java Fri Feb 6 17:24:01 2009 @@ -31,7 +31,7 @@ import org.apache.commons.compress.archivers.tar.TarArchiveInputStream; 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.archivers.zip.ZipOutputStream; /** * Factory to create Archive[In|Out]putStreams from names @@ -65,7 +65,7 @@ if (ar.equalsIgnoreCase(archiverName)) { return new ArArchiveOutputStream(out); } else if(zip.equalsIgnoreCase(archiverName)) { -return new ZipArchiveOutputStream(out); +return new ZipOutputStream(out); } else if(tar.equalsIgnoreCase(archiverName)) { return new TarArchiveOutputStream(out); } else if(jar.equalsIgnoreCase(archiverName)) { Modified: commons/sandbox/compress/trunk/src/main/java/org/apache/commons/compress/archivers/ar/ArArchiveOutputStream.java URL: http://svn.apache.org/viewvc/commons/sandbox/compress/trunk/src/main/java/org/apache/commons/compress/archivers/ar/ArArchiveOutputStream.java?rev=741641r1=741640r2=741641view=diff == --- commons/sandbox/compress/trunk/src/main/java/org/apache/commons/compress/archivers/ar/ArArchiveOutputStream.java (original) +++ commons/sandbox/compress/trunk/src/main/java/org/apache/commons/compress/archivers/ar/ArArchiveOutputStream.java Fri Feb 6 17:24:01 2009 @@ -26,13 +26,12 @@ public class ArArchiveOutputStream extends ArchiveOutputStream { - private final OutputStream out; private long archiveOffset = 0; private long entryOffset = 0; private ArArchiveEntry prevEntry; public ArArchiveOutputStream( final OutputStream pOut ) { - out = pOut; +super(pOut
svn commit: r742977 - in /commons/sandbox/compress/trunk/src/main/java/org/apache/commons/compress: archivers/ archivers/ar/ archivers/cpio/ archivers/jar/ archivers/tar/ archivers/zip/ compressors/ c
Author: bodewig Date: Tue Feb 10 14:20:05 2009 New Revision: 742977 URL: http://svn.apache.org/viewvc?rev=742977view=rev Log: fix whitespace Modified: commons/sandbox/compress/trunk/src/main/java/org/apache/commons/compress/archivers/ArchiveInputStream.java commons/sandbox/compress/trunk/src/main/java/org/apache/commons/compress/archivers/ArchiveOutputStream.java commons/sandbox/compress/trunk/src/main/java/org/apache/commons/compress/archivers/ar/ArArchiveInputStream.java commons/sandbox/compress/trunk/src/main/java/org/apache/commons/compress/archivers/ar/ArArchiveOutputStream.java commons/sandbox/compress/trunk/src/main/java/org/apache/commons/compress/archivers/cpio/CpioArchiveInputStream.java commons/sandbox/compress/trunk/src/main/java/org/apache/commons/compress/archivers/cpio/CpioArchiveOutputStream.java commons/sandbox/compress/trunk/src/main/java/org/apache/commons/compress/archivers/jar/JarArchiveInputStream.java commons/sandbox/compress/trunk/src/main/java/org/apache/commons/compress/archivers/jar/JarArchiveOutputStream.java commons/sandbox/compress/trunk/src/main/java/org/apache/commons/compress/archivers/tar/TarInputStream.java commons/sandbox/compress/trunk/src/main/java/org/apache/commons/compress/archivers/tar/TarOutputStream.java commons/sandbox/compress/trunk/src/main/java/org/apache/commons/compress/archivers/zip/ZipArchiveInputStream.java commons/sandbox/compress/trunk/src/main/java/org/apache/commons/compress/archivers/zip/ZipArchiveOutputStream.java commons/sandbox/compress/trunk/src/main/java/org/apache/commons/compress/compressors/CompressorInputStream.java commons/sandbox/compress/trunk/src/main/java/org/apache/commons/compress/compressors/CompressorOutputStream.java commons/sandbox/compress/trunk/src/main/java/org/apache/commons/compress/compressors/bzip2/BZip2CompressorOutputStream.java commons/sandbox/compress/trunk/src/main/java/org/apache/commons/compress/compressors/gzip/GzipCompressorInputStream.java commons/sandbox/compress/trunk/src/main/java/org/apache/commons/compress/compressors/gzip/GzipCompressorOutputStream.java Modified: commons/sandbox/compress/trunk/src/main/java/org/apache/commons/compress/archivers/ArchiveInputStream.java URL: http://svn.apache.org/viewvc/commons/sandbox/compress/trunk/src/main/java/org/apache/commons/compress/archivers/ArchiveInputStream.java?rev=742977r1=742976r2=742977view=diff == --- commons/sandbox/compress/trunk/src/main/java/org/apache/commons/compress/archivers/ArchiveInputStream.java (original) +++ commons/sandbox/compress/trunk/src/main/java/org/apache/commons/compress/archivers/ArchiveInputStream.java Tue Feb 10 14:20:05 2009 @@ -23,11 +23,11 @@ public abstract class ArchiveInputStream extends InputStream { - /** +/** * Returns the next Archive Entry in this Stream. * @return the next entry * @throws IOException if the next entry could not be read */ public abstract ArchiveEntry getNextEntry() throws IOException; - + } Modified: commons/sandbox/compress/trunk/src/main/java/org/apache/commons/compress/archivers/ArchiveOutputStream.java URL: http://svn.apache.org/viewvc/commons/sandbox/compress/trunk/src/main/java/org/apache/commons/compress/archivers/ArchiveOutputStream.java?rev=742977r1=742976r2=742977view=diff == --- commons/sandbox/compress/trunk/src/main/java/org/apache/commons/compress/archivers/ArchiveOutputStream.java (original) +++ commons/sandbox/compress/trunk/src/main/java/org/apache/commons/compress/archivers/ArchiveOutputStream.java Tue Feb 10 14:20:05 2009 @@ -29,6 +29,6 @@ } public abstract void putArchiveEntry(ArchiveEntry entry) throws IOException; - + public abstract void closeArchiveEntry() throws IOException; } Modified: commons/sandbox/compress/trunk/src/main/java/org/apache/commons/compress/archivers/ar/ArArchiveInputStream.java URL: http://svn.apache.org/viewvc/commons/sandbox/compress/trunk/src/main/java/org/apache/commons/compress/archivers/ar/ArArchiveInputStream.java?rev=742977r1=742976r2=742977view=diff == --- commons/sandbox/compress/trunk/src/main/java/org/apache/commons/compress/archivers/ar/ArArchiveInputStream.java (original) +++ commons/sandbox/compress/trunk/src/main/java/org/apache/commons/compress/archivers/ar/ArArchiveInputStream.java Tue Feb 10 14:20:05 2009 @@ -28,15 +28,15 @@ private final InputStream input; private long offset = 0; - + public ArArchiveInputStream( final InputStream pInput ) { input = pInput; } - + public ArchiveEntry getNextEntry() throws IOException { - + if (offset == 0) { -final
svn commit: r742984 - in /commons/sandbox/compress/trunk/src/main/java/org/apache/commons/compress/archivers: ar/ArArchiveOutputStream.java cpio/CpioArchiveOutputStream.java tar/TarOutputStream.java z
Author: bodewig Date: Tue Feb 10 14:37:00 2009 New Revision: 742984 URL: http://svn.apache.org/viewvc?rev=742984view=rev Log: take advantage of FilterOutputStream Modified: commons/sandbox/compress/trunk/src/main/java/org/apache/commons/compress/archivers/ar/ArArchiveOutputStream.java commons/sandbox/compress/trunk/src/main/java/org/apache/commons/compress/archivers/cpio/CpioArchiveOutputStream.java commons/sandbox/compress/trunk/src/main/java/org/apache/commons/compress/archivers/tar/TarOutputStream.java commons/sandbox/compress/trunk/src/main/java/org/apache/commons/compress/archivers/zip/ZipArchiveOutputStream.java Modified: commons/sandbox/compress/trunk/src/main/java/org/apache/commons/compress/archivers/ar/ArArchiveOutputStream.java URL: http://svn.apache.org/viewvc/commons/sandbox/compress/trunk/src/main/java/org/apache/commons/compress/archivers/ar/ArArchiveOutputStream.java?rev=742984r1=742983r2=742984view=diff == --- commons/sandbox/compress/trunk/src/main/java/org/apache/commons/compress/archivers/ar/ArArchiveOutputStream.java (original) +++ commons/sandbox/compress/trunk/src/main/java/org/apache/commons/compress/archivers/ar/ArArchiveOutputStream.java Tue Feb 10 14:37:00 2009 @@ -146,11 +146,6 @@ entryOffset += len; } -public void write(byte[] b) throws IOException { -out.write(b); -entryOffset += b.length; -} - public void close() throws IOException { closeArchiveEntry(); out.close(); Modified: commons/sandbox/compress/trunk/src/main/java/org/apache/commons/compress/archivers/cpio/CpioArchiveOutputStream.java URL: http://svn.apache.org/viewvc/commons/sandbox/compress/trunk/src/main/java/org/apache/commons/compress/archivers/cpio/CpioArchiveOutputStream.java?rev=742984r1=742983r2=742984view=diff == --- commons/sandbox/compress/trunk/src/main/java/org/apache/commons/compress/archivers/cpio/CpioArchiveOutputStream.java (original) +++ commons/sandbox/compress/trunk/src/main/java/org/apache/commons/compress/archivers/cpio/CpioArchiveOutputStream.java Tue Feb 10 14:37:00 2009 @@ -422,10 +422,4 @@ this.putNextEntry((CpioArchiveEntry)entry); } -/* (non-Javadoc) - * @see java.io.OutputStream#write(int) - */ -public void write(int b) throws IOException { -out.write(b); -} } Modified: commons/sandbox/compress/trunk/src/main/java/org/apache/commons/compress/archivers/tar/TarOutputStream.java URL: http://svn.apache.org/viewvc/commons/sandbox/compress/trunk/src/main/java/org/apache/commons/compress/archivers/tar/TarOutputStream.java?rev=742984r1=742983r2=742984view=diff == --- commons/sandbox/compress/trunk/src/main/java/org/apache/commons/compress/archivers/tar/TarOutputStream.java (original) +++ commons/sandbox/compress/trunk/src/main/java/org/apache/commons/compress/archivers/tar/TarOutputStream.java Tue Feb 10 14:37:00 2009 @@ -244,18 +244,6 @@ } /** - * Writes bytes to the current tar archive entry. - * - * This method simply calls write( byte[], int, int ). - * - * @param wBuf The buffer to write to the archive. - * @throws IOException on error - */ -public void write(byte[] wBuf) throws IOException { -write(wBuf, 0, wBuf.length); -} - -/** * Writes bytes to the current tar archive entry. This method * is aware of the current entry and will throw an exception if * you attempt to write bytes past the length specified for the Modified: commons/sandbox/compress/trunk/src/main/java/org/apache/commons/compress/archivers/zip/ZipArchiveOutputStream.java URL: http://svn.apache.org/viewvc/commons/sandbox/compress/trunk/src/main/java/org/apache/commons/compress/archivers/zip/ZipArchiveOutputStream.java?rev=742984r1=742983r2=742984view=diff == --- commons/sandbox/compress/trunk/src/main/java/org/apache/commons/compress/archivers/zip/ZipArchiveOutputStream.java (original) +++ commons/sandbox/compress/trunk/src/main/java/org/apache/commons/compress/archivers/zip/ZipArchiveOutputStream.java Tue Feb 10 14:37:00 2009 @@ -552,19 +552,6 @@ } } -/** - * Flushes this output stream and forces any buffered output bytes - * to be written out to the stream. - * - * @exception IOException if an I/O error occurs. - * @since 1.14 - */ -public void flush() throws IOException { -if (out != null) { -out.flush(); -} -} - public void putArchiveEntry(ArchiveEntry entry) throws IOException { putNextEntry((ZipArchiveEntry) entry); }
svn commit: r742985 - in /commons/sandbox/compress/trunk/src/main/java/org/apache/commons/compress/compressors: CompressorOutputStream.java bzip2/BZip2CompressorOutputStream.java gzip/GzipCompressorOu
Author: bodewig Date: Tue Feb 10 14:45:08 2009 New Revision: 742985 URL: http://svn.apache.org/viewvc?rev=742985view=rev Log: Make CompressorOutputStream extend FilterStream Modified: commons/sandbox/compress/trunk/src/main/java/org/apache/commons/compress/compressors/CompressorOutputStream.java commons/sandbox/compress/trunk/src/main/java/org/apache/commons/compress/compressors/bzip2/BZip2CompressorOutputStream.java commons/sandbox/compress/trunk/src/main/java/org/apache/commons/compress/compressors/gzip/GzipCompressorOutputStream.java Modified: commons/sandbox/compress/trunk/src/main/java/org/apache/commons/compress/compressors/CompressorOutputStream.java URL: http://svn.apache.org/viewvc/commons/sandbox/compress/trunk/src/main/java/org/apache/commons/compress/compressors/CompressorOutputStream.java?rev=742985r1=742984r2=742985view=diff == --- commons/sandbox/compress/trunk/src/main/java/org/apache/commons/compress/compressors/CompressorOutputStream.java (original) +++ commons/sandbox/compress/trunk/src/main/java/org/apache/commons/compress/compressors/CompressorOutputStream.java Tue Feb 10 14:45:08 2009 @@ -18,8 +18,12 @@ */ package org.apache.commons.compress.compressors; +import java.io.FilterOutputStream; import java.io.OutputStream; -public abstract class CompressorOutputStream extends OutputStream { +public abstract class CompressorOutputStream extends FilterOutputStream { // TODO +protected CompressorOutputStream(final OutputStream o) { +super(o); +} } Modified: commons/sandbox/compress/trunk/src/main/java/org/apache/commons/compress/compressors/bzip2/BZip2CompressorOutputStream.java URL: http://svn.apache.org/viewvc/commons/sandbox/compress/trunk/src/main/java/org/apache/commons/compress/compressors/bzip2/BZip2CompressorOutputStream.java?rev=742985r1=742984r2=742985view=diff == --- commons/sandbox/compress/trunk/src/main/java/org/apache/commons/compress/compressors/bzip2/BZip2CompressorOutputStream.java (original) +++ commons/sandbox/compress/trunk/src/main/java/org/apache/commons/compress/compressors/bzip2/BZip2CompressorOutputStream.java Tue Feb 10 14:45:08 2009 @@ -272,6 +272,7 @@ public BZip2CompressorOutputStream(OutputStream inStream, int inBlockSize) throws IOException { +super(inStream); block = null; quadrant = null; zptr = null; @@ -377,7 +378,7 @@ } finish(); super.close(); -bsStream.close(); +out.close(); closed = true; } @@ -396,7 +397,7 @@ public void flush() throws IOException { super.flush(); -bsStream.flush(); +out.flush(); } private int blockCRC, combinedCRC; @@ -516,7 +517,7 @@ } private void bsSetStream(OutputStream f) { -bsStream = f; +out = f; bsLive = 0; bsBuff = 0; bytesOut = 0; @@ -526,7 +527,7 @@ while (bsLive 0) { int ch = (bsBuff 24); try { -bsStream.write(ch); // write 8-bit +out.write(ch); // write 8-bit } catch (IOException e) { throw e; } @@ -540,7 +541,7 @@ while (bsLive = 8) { int ch = (bsBuff 24); try { -bsStream.write(ch); // write 8-bit +out.write(ch); // write 8-bit } catch (IOException e) { throw e; } @@ -887,8 +888,6 @@ sendMTFValues(); } -private OutputStream bsStream; - private void simpleSort(int lo, int hi, int d) { int i, j, h, bigN, hp; int v; Modified: commons/sandbox/compress/trunk/src/main/java/org/apache/commons/compress/compressors/gzip/GzipCompressorOutputStream.java URL: http://svn.apache.org/viewvc/commons/sandbox/compress/trunk/src/main/java/org/apache/commons/compress/compressors/gzip/GzipCompressorOutputStream.java?rev=742985r1=742984r2=742985view=diff == --- commons/sandbox/compress/trunk/src/main/java/org/apache/commons/compress/compressors/gzip/GzipCompressorOutputStream.java (original) +++ commons/sandbox/compress/trunk/src/main/java/org/apache/commons/compress/compressors/gzip/GzipCompressorOutputStream.java Tue Feb 10 14:45:08 2009 @@ -26,18 +26,8 @@ public class GzipCompressorOutputStream extends CompressorOutputStream { -private final GZIPOutputStream out; - public GzipCompressorOutputStream( final OutputStream outputStream ) throws IOException { -out = new GZIPOutputStream(outputStream); -} - -public void write(int b) throws IOException { -out.write(b); -} - -public void close() throws IOException { -out.close
svn commit: r742987 - in /commons/sandbox/compress/trunk/src/main/java/org/apache/commons/compress/compressors: CompressorInputStream.java bzip2/BZip2CompressorInputStream.java gzip/GzipCompressorInpu
Author: bodewig Date: Tue Feb 10 14:53:54 2009 New Revision: 742987 URL: http://svn.apache.org/viewvc?rev=742987view=rev Log: Make CompressorInputStream extend FilterInputStream Modified: commons/sandbox/compress/trunk/src/main/java/org/apache/commons/compress/compressors/CompressorInputStream.java commons/sandbox/compress/trunk/src/main/java/org/apache/commons/compress/compressors/bzip2/BZip2CompressorInputStream.java commons/sandbox/compress/trunk/src/main/java/org/apache/commons/compress/compressors/gzip/GzipCompressorInputStream.java Modified: commons/sandbox/compress/trunk/src/main/java/org/apache/commons/compress/compressors/CompressorInputStream.java URL: http://svn.apache.org/viewvc/commons/sandbox/compress/trunk/src/main/java/org/apache/commons/compress/compressors/CompressorInputStream.java?rev=742987r1=742986r2=742987view=diff == --- commons/sandbox/compress/trunk/src/main/java/org/apache/commons/compress/compressors/CompressorInputStream.java (original) +++ commons/sandbox/compress/trunk/src/main/java/org/apache/commons/compress/compressors/CompressorInputStream.java Tue Feb 10 14:53:54 2009 @@ -18,8 +18,12 @@ */ package org.apache.commons.compress.compressors; +import java.io.FilterInputStream; import java.io.InputStream; -public abstract class CompressorInputStream extends InputStream { +public abstract class CompressorInputStream extends FilterInputStream { // TODO +protected CompressorInputStream(final InputStream i) { +super(i); +} } Modified: commons/sandbox/compress/trunk/src/main/java/org/apache/commons/compress/compressors/bzip2/BZip2CompressorInputStream.java URL: http://svn.apache.org/viewvc/commons/sandbox/compress/trunk/src/main/java/org/apache/commons/compress/compressors/bzip2/BZip2CompressorInputStream.java?rev=742987r1=742986r2=742987view=diff == --- commons/sandbox/compress/trunk/src/main/java/org/apache/commons/compress/compressors/bzip2/BZip2CompressorInputStream.java (original) +++ commons/sandbox/compress/trunk/src/main/java/org/apache/commons/compress/compressors/bzip2/BZip2CompressorInputStream.java Tue Feb 10 14:53:54 2009 @@ -80,8 +80,6 @@ private int nInUse; -private InputStream in; - private int currentChar = -1; private static final int EOF = 0; @@ -132,9 +130,8 @@ * if ttin == null/tt */ public BZip2CompressorInputStream(final InputStream in) throws IOException { -super(); +super(in); -this.in = in; init(); } Modified: commons/sandbox/compress/trunk/src/main/java/org/apache/commons/compress/compressors/gzip/GzipCompressorInputStream.java URL: http://svn.apache.org/viewvc/commons/sandbox/compress/trunk/src/main/java/org/apache/commons/compress/compressors/gzip/GzipCompressorInputStream.java?rev=742987r1=742986r2=742987view=diff == --- commons/sandbox/compress/trunk/src/main/java/org/apache/commons/compress/compressors/gzip/GzipCompressorInputStream.java (original) +++ commons/sandbox/compress/trunk/src/main/java/org/apache/commons/compress/compressors/gzip/GzipCompressorInputStream.java Tue Feb 10 14:53:54 2009 @@ -26,14 +26,8 @@ public class GzipCompressorInputStream extends CompressorInputStream { -private final GZIPInputStream in; - public GzipCompressorInputStream(InputStream inputStream) throws IOException { -in = new GZIPInputStream(inputStream); -} - -public int read() throws IOException { -return in.read(); +super(new GZIPInputStream(inputStream)); } }
svn commit: r742990 - in /commons/sandbox/compress/trunk/src/main/java/org/apache/commons/compress: archivers/ar/ archivers/cpio/ archivers/tar/ archivers/zip/ compressors/ compressors/bzip2/ compress
Author: bodewig Date: Tue Feb 10 15:11:22 2009 New Revision: 742990 URL: http://svn.apache.org/viewvc?rev=742990view=rev Log: revert Filter*Stream patches since they do more harm than help Modified: commons/sandbox/compress/trunk/src/main/java/org/apache/commons/compress/archivers/ar/ArArchiveOutputStream.java commons/sandbox/compress/trunk/src/main/java/org/apache/commons/compress/archivers/cpio/CpioArchiveOutputStream.java commons/sandbox/compress/trunk/src/main/java/org/apache/commons/compress/archivers/tar/TarOutputStream.java commons/sandbox/compress/trunk/src/main/java/org/apache/commons/compress/archivers/zip/ZipArchiveOutputStream.java commons/sandbox/compress/trunk/src/main/java/org/apache/commons/compress/compressors/CompressorInputStream.java commons/sandbox/compress/trunk/src/main/java/org/apache/commons/compress/compressors/CompressorOutputStream.java commons/sandbox/compress/trunk/src/main/java/org/apache/commons/compress/compressors/bzip2/BZip2CompressorInputStream.java commons/sandbox/compress/trunk/src/main/java/org/apache/commons/compress/compressors/bzip2/BZip2CompressorOutputStream.java commons/sandbox/compress/trunk/src/main/java/org/apache/commons/compress/compressors/gzip/GzipCompressorInputStream.java commons/sandbox/compress/trunk/src/main/java/org/apache/commons/compress/compressors/gzip/GzipCompressorOutputStream.java Modified: commons/sandbox/compress/trunk/src/main/java/org/apache/commons/compress/archivers/ar/ArArchiveOutputStream.java URL: http://svn.apache.org/viewvc/commons/sandbox/compress/trunk/src/main/java/org/apache/commons/compress/archivers/ar/ArArchiveOutputStream.java?rev=742990r1=742989r2=742990view=diff == --- commons/sandbox/compress/trunk/src/main/java/org/apache/commons/compress/archivers/ar/ArArchiveOutputStream.java (original) +++ commons/sandbox/compress/trunk/src/main/java/org/apache/commons/compress/archivers/ar/ArArchiveOutputStream.java Tue Feb 10 15:11:22 2009 @@ -146,6 +146,11 @@ entryOffset += len; } +public void write(byte[] b) throws IOException { +out.write(b); +entryOffset += b.length; +} + public void close() throws IOException { closeArchiveEntry(); out.close(); Modified: commons/sandbox/compress/trunk/src/main/java/org/apache/commons/compress/archivers/cpio/CpioArchiveOutputStream.java URL: http://svn.apache.org/viewvc/commons/sandbox/compress/trunk/src/main/java/org/apache/commons/compress/archivers/cpio/CpioArchiveOutputStream.java?rev=742990r1=742989r2=742990view=diff == --- commons/sandbox/compress/trunk/src/main/java/org/apache/commons/compress/archivers/cpio/CpioArchiveOutputStream.java (original) +++ commons/sandbox/compress/trunk/src/main/java/org/apache/commons/compress/archivers/cpio/CpioArchiveOutputStream.java Tue Feb 10 15:11:22 2009 @@ -422,4 +422,10 @@ this.putNextEntry((CpioArchiveEntry)entry); } +/* (non-Javadoc) + * @see java.io.OutputStream#write(int) + */ +public void write(int b) throws IOException { +out.write(b); +} } Modified: commons/sandbox/compress/trunk/src/main/java/org/apache/commons/compress/archivers/tar/TarOutputStream.java URL: http://svn.apache.org/viewvc/commons/sandbox/compress/trunk/src/main/java/org/apache/commons/compress/archivers/tar/TarOutputStream.java?rev=742990r1=742989r2=742990view=diff == --- commons/sandbox/compress/trunk/src/main/java/org/apache/commons/compress/archivers/tar/TarOutputStream.java (original) +++ commons/sandbox/compress/trunk/src/main/java/org/apache/commons/compress/archivers/tar/TarOutputStream.java Tue Feb 10 15:11:22 2009 @@ -244,6 +244,18 @@ } /** + * Writes bytes to the current tar archive entry. + * + * This method simply calls write( byte[], int, int ). + * + * @param wBuf The buffer to write to the archive. + * @throws IOException on error + */ +public void write(byte[] wBuf) throws IOException { +write(wBuf, 0, wBuf.length); +} + +/** * Writes bytes to the current tar archive entry. This method * is aware of the current entry and will throw an exception if * you attempt to write bytes past the length specified for the Modified: commons/sandbox/compress/trunk/src/main/java/org/apache/commons/compress/archivers/zip/ZipArchiveOutputStream.java URL: http://svn.apache.org/viewvc/commons/sandbox/compress/trunk/src/main/java/org/apache/commons/compress/archivers/zip/ZipArchiveOutputStream.java?rev=742990r1=742989r2=742990view=diff == --- commons/sandbox/compress/trunk/src/main/java/org/apache/commons/compress/archivers
svn commit: r742997 - in /commons/sandbox/compress/trunk/src/main/java/org/apache/commons/compress/archivers: ./ ar/ cpio/ tar/ zip/
Author: bodewig Date: Tue Feb 10 15:35:35 2009 New Revision: 742997 URL: http://svn.apache.org/viewvc?rev=742997view=rev Log: no longer extende FilterOutputStream in ArchiveOutputStream Modified: commons/sandbox/compress/trunk/src/main/java/org/apache/commons/compress/archivers/ArchiveOutputStream.java commons/sandbox/compress/trunk/src/main/java/org/apache/commons/compress/archivers/ar/ArArchiveOutputStream.java commons/sandbox/compress/trunk/src/main/java/org/apache/commons/compress/archivers/cpio/CpioArchiveOutputStream.java commons/sandbox/compress/trunk/src/main/java/org/apache/commons/compress/archivers/tar/TarArchiveOutputStream.java commons/sandbox/compress/trunk/src/main/java/org/apache/commons/compress/archivers/zip/ZipArchiveOutputStream.java Modified: commons/sandbox/compress/trunk/src/main/java/org/apache/commons/compress/archivers/ArchiveOutputStream.java URL: http://svn.apache.org/viewvc/commons/sandbox/compress/trunk/src/main/java/org/apache/commons/compress/archivers/ArchiveOutputStream.java?rev=742997r1=742996r2=742997view=diff == --- commons/sandbox/compress/trunk/src/main/java/org/apache/commons/compress/archivers/ArchiveOutputStream.java (original) +++ commons/sandbox/compress/trunk/src/main/java/org/apache/commons/compress/archivers/ArchiveOutputStream.java Tue Feb 10 15:35:35 2009 @@ -19,14 +19,9 @@ package org.apache.commons.compress.archivers; import java.io.IOException; -import java.io.FilterOutputStream; import java.io.OutputStream; -public abstract class ArchiveOutputStream extends FilterOutputStream { - -protected ArchiveOutputStream(OutputStream other) { -super(other); -} +public abstract class ArchiveOutputStream extends OutputStream { public abstract void putArchiveEntry(ArchiveEntry entry) throws IOException; Modified: commons/sandbox/compress/trunk/src/main/java/org/apache/commons/compress/archivers/ar/ArArchiveOutputStream.java URL: http://svn.apache.org/viewvc/commons/sandbox/compress/trunk/src/main/java/org/apache/commons/compress/archivers/ar/ArArchiveOutputStream.java?rev=742997r1=742996r2=742997view=diff == --- commons/sandbox/compress/trunk/src/main/java/org/apache/commons/compress/archivers/ar/ArArchiveOutputStream.java (original) +++ commons/sandbox/compress/trunk/src/main/java/org/apache/commons/compress/archivers/ar/ArArchiveOutputStream.java Tue Feb 10 15:35:35 2009 @@ -26,12 +26,13 @@ public class ArArchiveOutputStream extends ArchiveOutputStream { +private final OutputStream out; private long archiveOffset = 0; private long entryOffset = 0; private ArArchiveEntry prevEntry; public ArArchiveOutputStream( final OutputStream pOut ) { -super(pOut); +this.out = pOut; } private long writeArchiveHeader() throws IOException { Modified: commons/sandbox/compress/trunk/src/main/java/org/apache/commons/compress/archivers/cpio/CpioArchiveOutputStream.java URL: http://svn.apache.org/viewvc/commons/sandbox/compress/trunk/src/main/java/org/apache/commons/compress/archivers/cpio/CpioArchiveOutputStream.java?rev=742997r1=742996r2=742997view=diff == --- commons/sandbox/compress/trunk/src/main/java/org/apache/commons/compress/archivers/cpio/CpioArchiveOutputStream.java (original) +++ commons/sandbox/compress/trunk/src/main/java/org/apache/commons/compress/archivers/cpio/CpioArchiveOutputStream.java Tue Feb 10 15:35:35 2009 @@ -70,6 +70,8 @@ private long written; +private final OutputStream out; + /** * Check to make sure that this stream has not been closed * @@ -88,7 +90,7 @@ * @param format The format of the stream */ public CpioArchiveOutputStream(final OutputStream out, final short format) { -super(out); +this.out = new FilterOutputStream(out); setFormat(format); } Modified: commons/sandbox/compress/trunk/src/main/java/org/apache/commons/compress/archivers/tar/TarArchiveOutputStream.java URL: http://svn.apache.org/viewvc/commons/sandbox/compress/trunk/src/main/java/org/apache/commons/compress/archivers/tar/TarArchiveOutputStream.java?rev=742997r1=742996r2=742997view=diff == --- commons/sandbox/compress/trunk/src/main/java/org/apache/commons/compress/archivers/tar/TarArchiveOutputStream.java (original) +++ commons/sandbox/compress/trunk/src/main/java/org/apache/commons/compress/archivers/tar/TarArchiveOutputStream.java Tue Feb 10 15:35:35 2009 @@ -26,8 +26,10 @@ public class TarArchiveOutputStream extends ArchiveOutputStream { +private final TarOutputStream out; + public TarArchiveOutputStream(OutputStream out) { -super(new
svn commit: r743003 - in /commons/sandbox/compress/trunk/src: main/java/org/apache/commons/compress/archivers/ main/java/org/apache/commons/compress/archivers/tar/ test/java/org/apache/commons/compres
Author: bodewig Date: Tue Feb 10 15:57:46 2009 New Revision: 743003 URL: http://svn.apache.org/viewvc?rev=743003view=rev Log: merge TarArchive*Stream with Tar*Stream Removed: commons/sandbox/compress/trunk/src/main/java/org/apache/commons/compress/archivers/tar/TarArchiveInputStream.java commons/sandbox/compress/trunk/src/main/java/org/apache/commons/compress/archivers/tar/TarArchiveOutputStream.java Modified: commons/sandbox/compress/trunk/src/main/java/org/apache/commons/compress/archivers/ArchiveStreamFactory.java commons/sandbox/compress/trunk/src/main/java/org/apache/commons/compress/archivers/tar/TarInputStream.java commons/sandbox/compress/trunk/src/main/java/org/apache/commons/compress/archivers/tar/TarOutputStream.java commons/sandbox/compress/trunk/src/test/java/org/apache/commons/compress/DetectArchiverTestCase.java Modified: commons/sandbox/compress/trunk/src/main/java/org/apache/commons/compress/archivers/ArchiveStreamFactory.java URL: http://svn.apache.org/viewvc/commons/sandbox/compress/trunk/src/main/java/org/apache/commons/compress/archivers/ArchiveStreamFactory.java?rev=743003r1=743002r2=743003view=diff == --- commons/sandbox/compress/trunk/src/main/java/org/apache/commons/compress/archivers/ArchiveStreamFactory.java (original) +++ commons/sandbox/compress/trunk/src/main/java/org/apache/commons/compress/archivers/ArchiveStreamFactory.java Tue Feb 10 15:57:46 2009 @@ -28,8 +28,8 @@ import org.apache.commons.compress.archivers.cpio.CpioArchiveOutputStream; import org.apache.commons.compress.archivers.jar.JarArchiveInputStream; import org.apache.commons.compress.archivers.jar.JarArchiveOutputStream; -import org.apache.commons.compress.archivers.tar.TarArchiveInputStream; -import org.apache.commons.compress.archivers.tar.TarArchiveOutputStream; +import org.apache.commons.compress.archivers.tar.TarInputStream; +import org.apache.commons.compress.archivers.tar.TarOutputStream; import org.apache.commons.compress.archivers.zip.ZipArchiveInputStream; import org.apache.commons.compress.archivers.zip.ZipArchiveOutputStream; @@ -52,7 +52,7 @@ } else if(zip.equalsIgnoreCase(archiverName)) { return new ZipArchiveInputStream(in); } else if(tar.equalsIgnoreCase(archiverName)) { -return new TarArchiveInputStream(in); +return new TarInputStream(in); } else if(jar.equalsIgnoreCase(archiverName)) { return new JarArchiveInputStream(in); } else if(cpio.equalsIgnoreCase(archiverName)) { @@ -67,7 +67,7 @@ } else if(zip.equalsIgnoreCase(archiverName)) { return new ZipArchiveOutputStream(out); } else if(tar.equalsIgnoreCase(archiverName)) { -return new TarArchiveOutputStream(out); +return new TarOutputStream(out); } else if(jar.equalsIgnoreCase(archiverName)) { return new JarArchiveOutputStream(out); } else if(cpio.equalsIgnoreCase(archiverName)) { @@ -88,8 +88,8 @@ return new ZipArchiveInputStream(input); } else if(JarArchiveInputStream.matches(signature, signatureLength)) { return new JarArchiveInputStream(input); -} else if(TarArchiveInputStream.matches(signature, signatureLength)) { -return new TarArchiveInputStream(input); +} else if(TarInputStream.matches(signature, signatureLength)) { +return new TarInputStream(input); } else if(ArArchiveInputStream.matches(signature, signatureLength)) { return new ArArchiveInputStream(input); } else if(CpioArchiveInputStream.matches(signature, signatureLength)) { Modified: commons/sandbox/compress/trunk/src/main/java/org/apache/commons/compress/archivers/tar/TarInputStream.java URL: http://svn.apache.org/viewvc/commons/sandbox/compress/trunk/src/main/java/org/apache/commons/compress/archivers/tar/TarInputStream.java?rev=743003r1=743002r2=743003view=diff == --- commons/sandbox/compress/trunk/src/main/java/org/apache/commons/compress/archivers/tar/TarInputStream.java (original) +++ commons/sandbox/compress/trunk/src/main/java/org/apache/commons/compress/archivers/tar/TarInputStream.java Tue Feb 10 15:57:46 2009 @@ -23,10 +23,11 @@ package org.apache.commons.compress.archivers.tar; -import java.io.FilterInputStream; import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; +import org.apache.commons.compress.archivers.ArchiveEntry; +import org.apache.commons.compress.archivers.ArchiveInputStream; /** * The TarInputStream reads a UNIX tar archive as an InputStream. @@ -35,7 +36,7 @@ * using read(). * */ -public class TarInputStream extends FilterInputStream { +public class TarInputStream extends ArchiveInputStream { private static final int
svn commit: r743006 - in /commons/sandbox/compress/trunk/src: main/java/org/apache/commons/compress/archivers/ main/java/org/apache/commons/compress/archivers/tar/ test/java/org/apache/commons/compres
Author: bodewig Date: Tue Feb 10 16:10:45 2009 New Revision: 743006 URL: http://svn.apache.org/viewvc?rev=743006view=rev Log: rename Tar*Stream Added: commons/sandbox/compress/trunk/src/main/java/org/apache/commons/compress/archivers/tar/TarArchiveInputStream.java commons/sandbox/compress/trunk/src/main/java/org/apache/commons/compress/archivers/tar/TarArchiveOutputStream.java Removed: commons/sandbox/compress/trunk/src/main/java/org/apache/commons/compress/archivers/tar/TarInputStream.java commons/sandbox/compress/trunk/src/main/java/org/apache/commons/compress/archivers/tar/TarOutputStream.java Modified: commons/sandbox/compress/trunk/src/main/java/org/apache/commons/compress/archivers/ArchiveStreamFactory.java commons/sandbox/compress/trunk/src/test/java/org/apache/commons/compress/DetectArchiverTestCase.java Modified: commons/sandbox/compress/trunk/src/main/java/org/apache/commons/compress/archivers/ArchiveStreamFactory.java URL: http://svn.apache.org/viewvc/commons/sandbox/compress/trunk/src/main/java/org/apache/commons/compress/archivers/ArchiveStreamFactory.java?rev=743006r1=743005r2=743006view=diff == --- commons/sandbox/compress/trunk/src/main/java/org/apache/commons/compress/archivers/ArchiveStreamFactory.java (original) +++ commons/sandbox/compress/trunk/src/main/java/org/apache/commons/compress/archivers/ArchiveStreamFactory.java Tue Feb 10 16:10:45 2009 @@ -28,8 +28,8 @@ import org.apache.commons.compress.archivers.cpio.CpioArchiveOutputStream; import org.apache.commons.compress.archivers.jar.JarArchiveInputStream; import org.apache.commons.compress.archivers.jar.JarArchiveOutputStream; -import org.apache.commons.compress.archivers.tar.TarInputStream; -import org.apache.commons.compress.archivers.tar.TarOutputStream; +import org.apache.commons.compress.archivers.tar.TarArchiveInputStream; +import org.apache.commons.compress.archivers.tar.TarArchiveOutputStream; import org.apache.commons.compress.archivers.zip.ZipArchiveInputStream; import org.apache.commons.compress.archivers.zip.ZipArchiveOutputStream; @@ -52,7 +52,7 @@ } else if(zip.equalsIgnoreCase(archiverName)) { return new ZipArchiveInputStream(in); } else if(tar.equalsIgnoreCase(archiverName)) { -return new TarInputStream(in); +return new TarArchiveInputStream(in); } else if(jar.equalsIgnoreCase(archiverName)) { return new JarArchiveInputStream(in); } else if(cpio.equalsIgnoreCase(archiverName)) { @@ -67,7 +67,7 @@ } else if(zip.equalsIgnoreCase(archiverName)) { return new ZipArchiveOutputStream(out); } else if(tar.equalsIgnoreCase(archiverName)) { -return new TarOutputStream(out); +return new TarArchiveOutputStream(out); } else if(jar.equalsIgnoreCase(archiverName)) { return new JarArchiveOutputStream(out); } else if(cpio.equalsIgnoreCase(archiverName)) { @@ -88,8 +88,8 @@ return new ZipArchiveInputStream(input); } else if(JarArchiveInputStream.matches(signature, signatureLength)) { return new JarArchiveInputStream(input); -} else if(TarInputStream.matches(signature, signatureLength)) { -return new TarInputStream(input); +} else if(TarArchiveInputStream.matches(signature, signatureLength)) { +return new TarArchiveInputStream(input); } else if(ArArchiveInputStream.matches(signature, signatureLength)) { return new ArArchiveInputStream(input); } else if(CpioArchiveInputStream.matches(signature, signatureLength)) { Added: commons/sandbox/compress/trunk/src/main/java/org/apache/commons/compress/archivers/tar/TarArchiveInputStream.java URL: http://svn.apache.org/viewvc/commons/sandbox/compress/trunk/src/main/java/org/apache/commons/compress/archivers/tar/TarArchiveInputStream.java?rev=743006view=auto == --- commons/sandbox/compress/trunk/src/main/java/org/apache/commons/compress/archivers/tar/TarArchiveInputStream.java (added) +++ commons/sandbox/compress/trunk/src/main/java/org/apache/commons/compress/archivers/tar/TarArchiveInputStream.java Tue Feb 10 16:10:45 2009 @@ -0,0 +1,431 @@ +/* + * 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
svn commit: r743014 - /commons/sandbox/compress/trunk/src/main/java/org/apache/commons/compress/archivers/zip/ZipArchiveOutputStream.java
Author: bodewig Date: Tue Feb 10 16:51:22 2009 New Revision: 743014 URL: http://svn.apache.org/viewvc?rev=743014view=rev Log: reduce accessibilty of constant byte-arrays. Findbugs issue, SANDBOX-246 Modified: commons/sandbox/compress/trunk/src/main/java/org/apache/commons/compress/archivers/zip/ZipArchiveOutputStream.java Modified: commons/sandbox/compress/trunk/src/main/java/org/apache/commons/compress/archivers/zip/ZipArchiveOutputStream.java URL: http://svn.apache.org/viewvc/commons/sandbox/compress/trunk/src/main/java/org/apache/commons/compress/archivers/zip/ZipArchiveOutputStream.java?rev=743014r1=743013r2=743014view=diff == --- commons/sandbox/compress/trunk/src/main/java/org/apache/commons/compress/archivers/zip/ZipArchiveOutputStream.java (original) +++ commons/sandbox/compress/trunk/src/main/java/org/apache/commons/compress/archivers/zip/ZipArchiveOutputStream.java Tue Feb 10 16:51:22 2009 @@ -591,25 +591,25 @@ * * @since 1.1 */ -protected static final byte[] LFH_SIG = ZipLong.getBytes(0X04034B50L); +static final byte[] LFH_SIG = ZipLong.getBytes(0X04034B50L); /** * data descriptor signature * * @since 1.1 */ -protected static final byte[] DD_SIG = ZipLong.getBytes(0X08074B50L); +static final byte[] DD_SIG = ZipLong.getBytes(0X08074B50L); /** * central file header signature * * @since 1.1 */ -protected static final byte[] CFH_SIG = ZipLong.getBytes(0X02014B50L); +static final byte[] CFH_SIG = ZipLong.getBytes(0X02014B50L); /** * end of central dir signature * * @since 1.1 */ -protected static final byte[] EOCD_SIG = ZipLong.getBytes(0X06054B50L); +static final byte[] EOCD_SIG = ZipLong.getBytes(0X06054B50L); /** * Writes next block of compressed data to the output stream.
svn commit: r743259 - in /commons/sandbox/compress/trunk/src/main/java/org/apache/commons/compress/archivers: ar/ cpio/ jar/ tar/ zip/
Author: bodewig Date: Wed Feb 11 07:44:00 2009 New Revision: 743259 URL: http://svn.apache.org/viewvc?rev=743259view=rev Log: provide convenience getNext*Entry methods to ArchiveInputStream subclasses Modified: commons/sandbox/compress/trunk/src/main/java/org/apache/commons/compress/archivers/ar/ArArchiveInputStream.java commons/sandbox/compress/trunk/src/main/java/org/apache/commons/compress/archivers/cpio/CpioArchiveInputStream.java commons/sandbox/compress/trunk/src/main/java/org/apache/commons/compress/archivers/jar/JarArchiveInputStream.java commons/sandbox/compress/trunk/src/main/java/org/apache/commons/compress/archivers/tar/TarArchiveInputStream.java commons/sandbox/compress/trunk/src/main/java/org/apache/commons/compress/archivers/zip/ZipArchiveInputStream.java Modified: commons/sandbox/compress/trunk/src/main/java/org/apache/commons/compress/archivers/ar/ArArchiveInputStream.java URL: http://svn.apache.org/viewvc/commons/sandbox/compress/trunk/src/main/java/org/apache/commons/compress/archivers/ar/ArArchiveInputStream.java?rev=743259r1=743258r2=743259view=diff == --- commons/sandbox/compress/trunk/src/main/java/org/apache/commons/compress/archivers/ar/ArArchiveInputStream.java (original) +++ commons/sandbox/compress/trunk/src/main/java/org/apache/commons/compress/archivers/ar/ArArchiveInputStream.java Wed Feb 11 07:44:00 2009 @@ -33,7 +33,7 @@ input = pInput; } -public ArchiveEntry getNextEntry() throws IOException { +public ArArchiveEntry getNextArEntry() throws IOException { if (offset == 0) { final byte[] expected = !arch\n.getBytes(); @@ -90,6 +90,10 @@ } +public ArchiveEntry getNextEntry() throws IOException { +return getNextArEntry(); +} + public int read() throws IOException { final int ret = input.read(); offset++; Modified: commons/sandbox/compress/trunk/src/main/java/org/apache/commons/compress/archivers/cpio/CpioArchiveInputStream.java URL: http://svn.apache.org/viewvc/commons/sandbox/compress/trunk/src/main/java/org/apache/commons/compress/archivers/cpio/CpioArchiveInputStream.java?rev=743259r1=743258r2=743259view=diff == --- commons/sandbox/compress/trunk/src/main/java/org/apache/commons/compress/archivers/cpio/CpioArchiveInputStream.java (original) +++ commons/sandbox/compress/trunk/src/main/java/org/apache/commons/compress/archivers/cpio/CpioArchiveInputStream.java Wed Feb 11 07:44:00 2009 @@ -435,11 +435,7 @@ } public ArchiveEntry getNextEntry() throws IOException { -CpioArchiveEntry entry = this.getNextCPIOEntry(); -if(entry == null) { -return null; -} -return (ArchiveEntry)entry; +return getNextCPIOEntry(); } public static boolean matches(byte[] signature, int length) { Modified: commons/sandbox/compress/trunk/src/main/java/org/apache/commons/compress/archivers/jar/JarArchiveInputStream.java URL: http://svn.apache.org/viewvc/commons/sandbox/compress/trunk/src/main/java/org/apache/commons/compress/archivers/jar/JarArchiveInputStream.java?rev=743259r1=743258r2=743259view=diff == --- commons/sandbox/compress/trunk/src/main/java/org/apache/commons/compress/archivers/jar/JarArchiveInputStream.java (original) +++ commons/sandbox/compress/trunk/src/main/java/org/apache/commons/compress/archivers/jar/JarArchiveInputStream.java Wed Feb 11 07:44:00 2009 @@ -31,13 +31,13 @@ super(inputStream); } +public JarArchiveEntry getNextJarEntry() throws IOException { +ZipArchiveEntry entry = getNextZipEntry(); +return entry == null ? null : new JarArchiveEntry(entry); +} + public ArchiveEntry getNextEntry() throws IOException { -ZipArchiveEntry entry = (ZipArchiveEntry)super.getNextEntry(); -if(entry == null) { -return null; -} else { -return (ArchiveEntry)new JarArchiveEntry(entry); -} +return getNextJarEntry(); } public static boolean matches(byte[] signature, int length ) { Modified: commons/sandbox/compress/trunk/src/main/java/org/apache/commons/compress/archivers/tar/TarArchiveInputStream.java URL: http://svn.apache.org/viewvc/commons/sandbox/compress/trunk/src/main/java/org/apache/commons/compress/archivers/tar/TarArchiveInputStream.java?rev=743259r1=743258r2=743259view=diff == --- commons/sandbox/compress/trunk/src/main/java/org/apache/commons/compress/archivers/tar/TarArchiveInputStream.java (original) +++ commons/sandbox/compress/trunk/src/main/java/org/apache/commons/compress/archivers/tar/TarArchiveInputStream.java Wed Feb 11 07:44:00 2009
svn commit: r743608 - in /commons/sandbox/compress/trunk/src/main/java/org/apache/commons/compress/archivers/tar: TarArchiveInputStream.java TarArchiveOutputStream.java
Author: bodewig Date: Thu Feb 12 03:13:10 2009 New Revision: 743608 URL: http://svn.apache.org/viewvc?rev=743608view=rev Log: fix linefeeds, thanks to Sebb for spotting this Modified: commons/sandbox/compress/trunk/src/main/java/org/apache/commons/compress/archivers/tar/TarArchiveInputStream.java (contents, props changed) commons/sandbox/compress/trunk/src/main/java/org/apache/commons/compress/archivers/tar/TarArchiveOutputStream.java (contents, props changed) Modified: commons/sandbox/compress/trunk/src/main/java/org/apache/commons/compress/archivers/tar/TarArchiveInputStream.java URL: http://svn.apache.org/viewvc/commons/sandbox/compress/trunk/src/main/java/org/apache/commons/compress/archivers/tar/TarArchiveInputStream.java?rev=743608r1=743607r2=743608view=diff == --- commons/sandbox/compress/trunk/src/main/java/org/apache/commons/compress/archivers/tar/TarArchiveInputStream.java (original) +++ commons/sandbox/compress/trunk/src/main/java/org/apache/commons/compress/archivers/tar/TarArchiveInputStream.java Thu Feb 12 03:13:10 2009 @@ -1,435 +1,435 @@ -/* - * 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. - * - */ - -/* - * This package is based on the work done by Timothy Gerard Endres - * (t...@ice.com) to whom the Ant project is very grateful for his great code. - */ - -package org.apache.commons.compress.archivers.tar; - -import java.io.IOException; -import java.io.InputStream; -import java.io.OutputStream; -import org.apache.commons.compress.archivers.ArchiveEntry; -import org.apache.commons.compress.archivers.ArchiveInputStream; - -/** - * The TarInputStream reads a UNIX tar archive as an InputStream. - * methods are provided to position at each successive entry in - * the archive, and the read each entry as a normal input stream - * using read(). - * - */ -public class TarArchiveInputStream extends ArchiveInputStream { -private static final int SMALL_BUFFER_SIZE = 256; -private static final int BUFFER_SIZE = 8 * 1024; -private static final int LARGE_BUFFER_SIZE = 32 * 1024; -private static final int BYTE_MASK = 0xFF; - -// CheckStyle:VisibilityModifier OFF - bc -protected boolean debug; -protected boolean hasHitEOF; -protected long entrySize; -protected long entryOffset; -protected byte[] readBuf; -protected TarBuffer buffer; -protected TarArchiveEntry currEntry; - -/** - * This contents of this array is not used at all in this class, - * it is only here to avoid repreated object creation during calls - * to the no-arg read method. - */ -protected byte[] oneBuf; - -// CheckStyle:VisibilityModifier ON - -private final InputStream in; - -/** - * Constructor for TarInputStream. - * @param is the input stream to use - */ -public TarArchiveInputStream(InputStream is) { -this(is, TarBuffer.DEFAULT_BLKSIZE, TarBuffer.DEFAULT_RCDSIZE); -} - -/** - * Constructor for TarInputStream. - * @param is the input stream to use - * @param blockSize the block size to use - */ -public TarArchiveInputStream(InputStream is, int blockSize) { -this(is, blockSize, TarBuffer.DEFAULT_RCDSIZE); -} - -/** - * Constructor for TarInputStream. - * @param is the input stream to use - * @param blockSize the block size to use - * @param recordSize the record size to use - */ -public TarArchiveInputStream(InputStream is, int blockSize, int recordSize) { -this.in = is; - -this.buffer = new TarBuffer(is, blockSize, recordSize); -this.readBuf = null; -this.oneBuf = new byte[1]; -this.debug = false; -this.hasHitEOF = false; -} - -/** - * Sets the debugging flag. - * - * @param debug True to turn on debugging. - */ -public void setDebug(boolean debug) { -this.debug = debug; -buffer.setDebug(debug); -} - -/** - * Closes this stream. Calls the TarBuffer's close() method. - * @throws IOException on error - */ -public void close() throws IOException { -buffer.close
svn commit: r743676 - /commons/sandbox/compress/trunk/pom.xml
Author: bodewig Date: Thu Feb 12 10:03:44 2009 New Revision: 743676 URL: http://svn.apache.org/viewvc?rev=743676view=rev Log: Explicitly set javac source and target to 1.4, submitted by Christian Grobmeier, SANDBOX-288 Modified: commons/sandbox/compress/trunk/pom.xml Modified: commons/sandbox/compress/trunk/pom.xml URL: http://svn.apache.org/viewvc/commons/sandbox/compress/trunk/pom.xml?rev=743676r1=743675r2=743676view=diff == --- commons/sandbox/compress/trunk/pom.xml (original) +++ commons/sandbox/compress/trunk/pom.xml Thu Feb 12 10:03:44 2009 @@ -85,9 +85,17 @@ /properties build -!-- turn off cobertura until we figure out why it's hanging -- plugins plugin +groupIdorg.apache.maven.plugins/groupId +artifactIdmaven-compiler-plugin/artifactId +configuration + source1.4/source + target1.4/target +/configuration + /plugin + !-- turn off cobertura until we figure out why it's hanging -- + plugin groupIdorg.codehaus.mojo/groupId artifactIdcobertura-maven-plugin/artifactId configuration
svn commit: r743678 - in /commons/sandbox/compress/trunk/src: main/java/org/apache/commons/compress/compressors/bzip2/ test/resources/
Author: bodewig Date: Thu Feb 12 10:27:10 2009 New Revision: 743678 URL: http://svn.apache.org/viewvc?rev=743678view=rev Log: use proper BZip2 signature, SANDBOX-285 Modified: commons/sandbox/compress/trunk/src/main/java/org/apache/commons/compress/compressors/bzip2/BZip2CompressorInputStream.java commons/sandbox/compress/trunk/src/main/java/org/apache/commons/compress/compressors/bzip2/BZip2CompressorOutputStream.java commons/sandbox/compress/trunk/src/test/resources/bla.txt.bz2 Modified: commons/sandbox/compress/trunk/src/main/java/org/apache/commons/compress/compressors/bzip2/BZip2CompressorInputStream.java URL: http://svn.apache.org/viewvc/commons/sandbox/compress/trunk/src/main/java/org/apache/commons/compress/compressors/bzip2/BZip2CompressorInputStream.java?rev=743678r1=743677r2=743678view=diff == --- commons/sandbox/compress/trunk/src/main/java/org/apache/commons/compress/compressors/bzip2/BZip2CompressorInputStream.java (original) +++ commons/sandbox/compress/trunk/src/main/java/org/apache/commons/compress/compressors/bzip2/BZip2CompressorInputStream.java Thu Feb 12 10:27:10 2009 @@ -218,12 +218,9 @@ if (in.available() == 0) { throw new IOException(Empty InputStream); } -int magic2 = this.in.read(); -if (magic2 != 'h') { -throw new IOException(Stream is not BZip2 formatted: expected 'h' - + as first byte but got ' + (char) magic2 - + '); -} +checkMagicChar('B', first); +checkMagicChar('Z', second); +checkMagicChar('h', third); int blockSize = this.in.read(); if ((blockSize '1') || (blockSize '9')) { @@ -237,6 +234,17 @@ setupBlock(); } +private void checkMagicChar(char expected, String position) +throws IOException { +int magic = this.in.read(); +if (magic != expected) { +throw new IOException(Stream is not BZip2 formatted: expected ' + + expected + ' as + position + + byte but got ' + (char) magic + + '); +} +} + private void initBlock() throws IOException { char magic0 = bsGetUByte(); char magic1 = bsGetUByte(); Modified: commons/sandbox/compress/trunk/src/main/java/org/apache/commons/compress/compressors/bzip2/BZip2CompressorOutputStream.java URL: http://svn.apache.org/viewvc/commons/sandbox/compress/trunk/src/main/java/org/apache/commons/compress/compressors/bzip2/BZip2CompressorOutputStream.java?rev=743678r1=743677r2=743678view=diff == --- commons/sandbox/compress/trunk/src/main/java/org/apache/commons/compress/compressors/bzip2/BZip2CompressorOutputStream.java (original) +++ commons/sandbox/compress/trunk/src/main/java/org/apache/commons/compress/compressors/bzip2/BZip2CompressorOutputStream.java Thu Feb 12 10:27:10 2009 @@ -405,6 +405,8 @@ bytesOut = 0; nBlocksRandomised = 0; +bsPutUChar('B'); +bsPutUChar('Z'); /* Write `magic' bytes h indicating file-format == huffmanised, followed by a digit indicating blockSize100k. */ Modified: commons/sandbox/compress/trunk/src/test/resources/bla.txt.bz2 URL: http://svn.apache.org/viewvc/commons/sandbox/compress/trunk/src/test/resources/bla.txt.bz2?rev=743678r1=743677r2=743678view=diff == Binary files - no diff available.
svn commit: r744922 - in /commons/sandbox/compress/trunk/src: main/java/org/apache/commons/compress/changes/ test/java/org/apache/commons/compress/ test/java/org/apache/commons/compress/archivers/ tes
Author: bodewig Date: Mon Feb 16 14:19:43 2009 New Revision: 744922 URL: http://svn.apache.org/viewvc?rev=744922view=rev Log: new testcases by Christian Grobmeier - SANDBOX-183 Added: commons/sandbox/compress/trunk/src/test/resources/test with spaces.txt (with props) commons/sandbox/compress/trunk/src/test/resources/test3.xml (with props) commons/sandbox/compress/trunk/src/test/resources/test4.xml (with props) Modified: commons/sandbox/compress/trunk/src/main/java/org/apache/commons/compress/changes/ChangeSet.java commons/sandbox/compress/trunk/src/test/java/org/apache/commons/compress/AbstractTestCase.java commons/sandbox/compress/trunk/src/test/java/org/apache/commons/compress/DetectArchiverTestCase.java commons/sandbox/compress/trunk/src/test/java/org/apache/commons/compress/archivers/ZipTestCase.java commons/sandbox/compress/trunk/src/test/java/org/apache/commons/compress/changes/ChangeSetTestCase.java Modified: commons/sandbox/compress/trunk/src/main/java/org/apache/commons/compress/changes/ChangeSet.java URL: http://svn.apache.org/viewvc/commons/sandbox/compress/trunk/src/main/java/org/apache/commons/compress/changes/ChangeSet.java?rev=744922r1=744921r2=744922view=diff == --- commons/sandbox/compress/trunk/src/main/java/org/apache/commons/compress/changes/ChangeSet.java (original) +++ commons/sandbox/compress/trunk/src/main/java/org/apache/commons/compress/changes/ChangeSet.java Mon Feb 16 14:19:43 2009 @@ -66,7 +66,6 @@ if( change.type() == Change.TYPE_DELETE entry.getName() != null entry.getName().equals(change.targetFile())) { - System.out.println(Delete: + entry.getName()); copy = false; it.remove(); break; @@ -83,7 +82,5 @@ out.putArchiveEntry(entry); IOUtils.copy(in, out); out.closeArchiveEntry(); - System.out.println(Copy: + entry.getName()); } - } Modified: commons/sandbox/compress/trunk/src/test/java/org/apache/commons/compress/AbstractTestCase.java URL: http://svn.apache.org/viewvc/commons/sandbox/compress/trunk/src/test/java/org/apache/commons/compress/AbstractTestCase.java?rev=744922r1=744921r2=744922view=diff == --- commons/sandbox/compress/trunk/src/test/java/org/apache/commons/compress/AbstractTestCase.java (original) +++ commons/sandbox/compress/trunk/src/test/java/org/apache/commons/compress/AbstractTestCase.java Mon Feb 16 14:19:43 2009 @@ -18,10 +18,26 @@ */ package org.apache.commons.compress; +import java.io.BufferedInputStream; import java.io.File; +import java.io.FileInputStream; +import java.io.FileOutputStream; +import java.io.InputStream; +import java.io.OutputStream; +import java.lang.reflect.Method; +import java.net.URL; +import java.net.URLClassLoader; +import java.util.List; import junit.framework.TestCase; +import org.apache.commons.compress.archivers.ArchiveEntry; +import org.apache.commons.compress.archivers.ArchiveInputStream; +import org.apache.commons.compress.archivers.ArchiveOutputStream; +import org.apache.commons.compress.archivers.ArchiveStreamFactory; +import org.apache.commons.compress.archivers.zip.ZipArchiveEntry; +import org.apache.commons.compress.utils.IOUtils; + public abstract class AbstractTestCase extends TestCase { protected File dir; @@ -30,6 +46,8 @@ dir = File.createTempFile(dir, ); dir.delete(); dir.mkdir(); + + addURL(new File(src/test/resources).toURL()); } protected File getFile( String path ) { @@ -41,5 +59,126 @@ dir = null; } + /** +* Adds a URL to the classpath. This method is necessary when running +* junit tests from within eclipse. +* @param url the url to add +* @throws Exception if an error occurs +*/ + public void addURL(URL url) throws Exception { + URLClassLoader classLoader = (URLClassLoader) ClassLoader.getSystemClassLoader(); + Class clazz = URLClassLoader.class; + + Method method= clazz.getDeclaredMethod(addURL, new Class[] { URL.class }); + method.setAccessible(true); + method.invoke(classLoader, new Object[] { url }); + } + /** +* Creates an archive of 5 textbased files in several directories. +* The archivername is the factory identifier for the archiver, for example +* zip, tar, cpio, jar, ar. +* The archive is created as a temp file. +* +* The archive contains
svn commit: r744923 - in /commons/sandbox/compress/trunk/src/test/java/org/apache/commons/compress: AbstractTestCase.java DetectArchiverTestCase.java archivers/ZipTestCase.java changes/ChangeSetTestCa
Author: bodewig Date: Mon Feb 16 14:21:12 2009 New Revision: 744923 URL: http://svn.apache.org/viewvc?rev=744923view=rev Log: fix whitespace Modified: commons/sandbox/compress/trunk/src/test/java/org/apache/commons/compress/AbstractTestCase.java commons/sandbox/compress/trunk/src/test/java/org/apache/commons/compress/DetectArchiverTestCase.java commons/sandbox/compress/trunk/src/test/java/org/apache/commons/compress/archivers/ZipTestCase.java commons/sandbox/compress/trunk/src/test/java/org/apache/commons/compress/changes/ChangeSetTestCase.java Modified: commons/sandbox/compress/trunk/src/test/java/org/apache/commons/compress/AbstractTestCase.java URL: http://svn.apache.org/viewvc/commons/sandbox/compress/trunk/src/test/java/org/apache/commons/compress/AbstractTestCase.java?rev=744923r1=744922r2=744923view=diff == --- commons/sandbox/compress/trunk/src/test/java/org/apache/commons/compress/AbstractTestCase.java (original) +++ commons/sandbox/compress/trunk/src/test/java/org/apache/commons/compress/AbstractTestCase.java Mon Feb 16 14:21:12 2009 @@ -40,145 +40,145 @@ public abstract class AbstractTestCase extends TestCase { - protected File dir; - - protected void setUp() throws Exception { - dir = File.createTempFile(dir, ); - dir.delete(); - dir.mkdir(); - - addURL(new File(src/test/resources).toURL()); - } - - protected File getFile( String path ) { - return new File(getClass().getClassLoader().getResource(path).getFile()); - } - - protected void tearDown() throws Exception { - dir.delete(); - dir = null; - } - - /** -* Adds a URL to the classpath. This method is necessary when running -* junit tests from within eclipse. -* @param url the url to add -* @throws Exception if an error occurs -*/ - public void addURL(URL url) throws Exception { - URLClassLoader classLoader = (URLClassLoader) ClassLoader.getSystemClassLoader(); - Class clazz = URLClassLoader.class; - - Method method= clazz.getDeclaredMethod(addURL, new Class[] { URL.class }); - method.setAccessible(true); - method.invoke(classLoader, new Object[] { url }); - } - - /** -* Creates an archive of 5 textbased files in several directories. -* The archivername is the factory identifier for the archiver, for example -* zip, tar, cpio, jar, ar. -* The archive is created as a temp file. -* -* The archive contains the following files: -* ul -* litestdata/test1.xml/li -* litestdata/test2.xml/li -* litest/test3.xml/li -* libla/test4.xml/li -* litest.txt/li -* lisomething/bla/li -* litest with spaces.txt/li -* /ul -* -* @param archivename the identifier of this archive -* @return the newly created file -* @throws Exception in case something goes wrong -*/ - protected File createArchive(String archivename) throws Exception { - ArchiveOutputStream out = null; - ArchiveInputStream ais = null; - try { - File temp = File.createTempFile(test, . + archivename); - - final OutputStream stream = new FileOutputStream(temp); - out = new ArchiveStreamFactory().createArchiveOutputStream(archivename, stream); - - final File file1 = getFile(test1.xml); - final File file2 = getFile(test2.xml); - final File file3 = getFile(test3.xml); - final File file4 = getFile(test4.xml); - final File file5 = getFile(test.txt); - final File file6 = getFile(test with spaces.txt); - - ZipArchiveEntry entry = new ZipArchiveEntry(testdata/test1.xml); - entry.setSize(file1.length()); - out.putArchiveEntry(entry); - IOUtils.copy(new FileInputStream(file1), out); - out.closeArchiveEntry(); - - out.putArchiveEntry(new ZipArchiveEntry(testdata/test2.xml)); - IOUtils.copy(new FileInputStream(file2), out); - out.closeArchiveEntry(); - - out.putArchiveEntry(new ZipArchiveEntry(test/test3.xml)); - IOUtils.copy(new FileInputStream(file3), out); - out.closeArchiveEntry(); - - out.putArchiveEntry(new ZipArchiveEntry(bla/test4.xml)); - IOUtils.copy(new FileInputStream(file4), out
svn commit: r745036 - /commons/sandbox/compress/trunk/src/test/java/org/apache/commons/compress/archivers/zip/
Author: bodewig Date: Tue Feb 17 13:08:58 2009 New Revision: 745036 URL: http://svn.apache.org/viewvc?rev=745036view=rev Log: Add directory for ZIP specific tests Added: commons/sandbox/compress/trunk/src/test/java/org/apache/commons/compress/archivers/zip/
svn commit: r745046 - in /commons/sandbox/compress/trunk/src/test/java/org/apache/commons/compress/archivers/zip: AsiExtraFieldTest.java ExtraFieldUtilsTest.java ZipArchiveEntryTest.java ZipArchiveOut
Author: bodewig Date: Tue Feb 17 13:30:20 2009 New Revision: 745046 URL: http://svn.apache.org/viewvc?rev=745046view=rev Log: copy Ant's zip tests Added: commons/sandbox/compress/trunk/src/test/java/org/apache/commons/compress/archivers/zip/AsiExtraFieldTest.java - copied, changed from r745042, ant/core/trunk/src/tests/junit/org/apache/tools/zip/AsiExtraFieldTest.java commons/sandbox/compress/trunk/src/test/java/org/apache/commons/compress/archivers/zip/ExtraFieldUtilsTest.java - copied, changed from r745042, ant/core/trunk/src/tests/junit/org/apache/tools/zip/ExtraFieldUtilsTest.java commons/sandbox/compress/trunk/src/test/java/org/apache/commons/compress/archivers/zip/ZipArchiveEntryTest.java - copied, changed from r745042, ant/core/trunk/src/tests/junit/org/apache/tools/zip/ZipEntryTest.java commons/sandbox/compress/trunk/src/test/java/org/apache/commons/compress/archivers/zip/ZipArchiveOutputStreamTest.java - copied, changed from r745042, ant/core/trunk/src/tests/junit/org/apache/tools/zip/ZipOutputStreamTest.java commons/sandbox/compress/trunk/src/test/java/org/apache/commons/compress/archivers/zip/ZipLongTest.java - copied, changed from r745042, ant/core/trunk/src/tests/junit/org/apache/tools/zip/ZipLongTest.java commons/sandbox/compress/trunk/src/test/java/org/apache/commons/compress/archivers/zip/ZipShortTest.java - copied, changed from r745042, ant/core/trunk/src/tests/junit/org/apache/tools/zip/ZipShortTest.java Copied: commons/sandbox/compress/trunk/src/test/java/org/apache/commons/compress/archivers/zip/AsiExtraFieldTest.java (from r745042, ant/core/trunk/src/tests/junit/org/apache/tools/zip/AsiExtraFieldTest.java) URL: http://svn.apache.org/viewvc/commons/sandbox/compress/trunk/src/test/java/org/apache/commons/compress/archivers/zip/AsiExtraFieldTest.java?p2=commons/sandbox/compress/trunk/src/test/java/org/apache/commons/compress/archivers/zip/AsiExtraFieldTest.javap1=ant/core/trunk/src/tests/junit/org/apache/tools/zip/AsiExtraFieldTest.javar1=745042r2=745046rev=745046view=diff == --- ant/core/trunk/src/tests/junit/org/apache/tools/zip/AsiExtraFieldTest.java (original) +++ commons/sandbox/compress/trunk/src/test/java/org/apache/commons/compress/archivers/zip/AsiExtraFieldTest.java Tue Feb 17 13:30:20 2009 @@ -16,12 +16,12 @@ * */ -package org.apache.tools.zip; +package org.apache.commons.compress.archivers.zip; import junit.framework.TestCase; /** - * JUnit 3 testcases for org.apache.tools.zip.AsiExtraField. + * JUnit 3 testcases for org.apache.commons.compress.archivers.zip.AsiExtraField. * */ public class AsiExtraFieldTest extends TestCase implements UnixStat { Copied: commons/sandbox/compress/trunk/src/test/java/org/apache/commons/compress/archivers/zip/ExtraFieldUtilsTest.java (from r745042, ant/core/trunk/src/tests/junit/org/apache/tools/zip/ExtraFieldUtilsTest.java) URL: http://svn.apache.org/viewvc/commons/sandbox/compress/trunk/src/test/java/org/apache/commons/compress/archivers/zip/ExtraFieldUtilsTest.java?p2=commons/sandbox/compress/trunk/src/test/java/org/apache/commons/compress/archivers/zip/ExtraFieldUtilsTest.javap1=ant/core/trunk/src/tests/junit/org/apache/tools/zip/ExtraFieldUtilsTest.javar1=745042r2=745046rev=745046view=diff == --- ant/core/trunk/src/tests/junit/org/apache/tools/zip/ExtraFieldUtilsTest.java (original) +++ commons/sandbox/compress/trunk/src/test/java/org/apache/commons/compress/archivers/zip/ExtraFieldUtilsTest.java Tue Feb 17 13:30:20 2009 @@ -16,12 +16,12 @@ * */ -package org.apache.tools.zip; +package org.apache.commons.compress.archivers.zip; import junit.framework.TestCase; /** - * JUnit 3 testcases for org.apache.tools.zip.ExtraFieldUtils. + * JUnit 3 testcases for org.apache.commons.compress.archivers.zip.ExtraFieldUtils. * */ public class ExtraFieldUtilsTest extends TestCase implements UnixStat { Copied: commons/sandbox/compress/trunk/src/test/java/org/apache/commons/compress/archivers/zip/ZipArchiveEntryTest.java (from r745042, ant/core/trunk/src/tests/junit/org/apache/tools/zip/ZipEntryTest.java) URL: http://svn.apache.org/viewvc/commons/sandbox/compress/trunk/src/test/java/org/apache/commons/compress/archivers/zip/ZipArchiveEntryTest.java?p2=commons/sandbox/compress/trunk/src/test/java/org/apache/commons/compress/archivers/zip/ZipArchiveEntryTest.javap1=ant/core/trunk/src/tests/junit/org/apache/tools/zip/ZipEntryTest.javar1=745042r2=745046rev=745046view=diff == --- ant/core/trunk/src/tests/junit/org/apache/tools/zip/ZipEntryTest.java (original) +++ commons/sandbox/compress/trunk/src/test/java/org/apache/commons/compress/archivers/zip/ZipArchiveEntryTest.java Tue Feb 17 13:30:20 2009 @@ -16,17
svn commit: r745488 - in /commons/sandbox/compress/trunk/src/main/java/org/apache/commons/compress/archivers: jar/JarArchiveOutputStream.java zip/ZipArchiveOutputStream.java zip/ZipFile.java
Author: bodewig Date: Wed Feb 18 12:12:54 2009 New Revision: 745488 URL: http://svn.apache.org/viewvc?rev=745488view=rev Log: make ZipArchiveOutputStream and ZipFile use UTF-8 by default Modified: commons/sandbox/compress/trunk/src/main/java/org/apache/commons/compress/archivers/jar/JarArchiveOutputStream.java commons/sandbox/compress/trunk/src/main/java/org/apache/commons/compress/archivers/zip/ZipArchiveOutputStream.java commons/sandbox/compress/trunk/src/main/java/org/apache/commons/compress/archivers/zip/ZipFile.java Modified: commons/sandbox/compress/trunk/src/main/java/org/apache/commons/compress/archivers/jar/JarArchiveOutputStream.java URL: http://svn.apache.org/viewvc/commons/sandbox/compress/trunk/src/main/java/org/apache/commons/compress/archivers/jar/JarArchiveOutputStream.java?rev=745488r1=745487r2=745488view=diff == --- commons/sandbox/compress/trunk/src/main/java/org/apache/commons/compress/archivers/jar/JarArchiveOutputStream.java (original) +++ commons/sandbox/compress/trunk/src/main/java/org/apache/commons/compress/archivers/jar/JarArchiveOutputStream.java Wed Feb 18 12:12:54 2009 @@ -29,7 +29,6 @@ public JarArchiveOutputStream( final OutputStream out ) { super(out); -setEncoding(UTF8); } public void putArchiveEntry(ArchiveEntry entry) throws IOException { Modified: commons/sandbox/compress/trunk/src/main/java/org/apache/commons/compress/archivers/zip/ZipArchiveOutputStream.java URL: http://svn.apache.org/viewvc/commons/sandbox/compress/trunk/src/main/java/org/apache/commons/compress/archivers/zip/ZipArchiveOutputStream.java?rev=745488r1=745487r2=745488view=diff == --- commons/sandbox/compress/trunk/src/main/java/org/apache/commons/compress/archivers/zip/ZipArchiveOutputStream.java (original) +++ commons/sandbox/compress/trunk/src/main/java/org/apache/commons/compress/archivers/zip/ZipArchiveOutputStream.java Wed Feb 18 12:12:54 2009 @@ -94,6 +94,11 @@ public static final int STORED = java.util.zip.ZipEntry.STORED; /** + * default encoding for file names and comment. + */ +static final String DEFAULT_ENCODING = UTF8; + +/** * Current entry. * * @since 1.1 @@ -205,11 +210,11 @@ * * pFor a list of possible values see a * href=http://java.sun.com/j2se/1.5.0/docs/guide/intl/encoding.doc.html;http://java.sun.com/j2se/1.5.0/docs/guide/intl/encoding.doc.html/a. - * Defaults to the platform's default character encoding./p + * Defaults to UTF-8./p * * @since 1.3 */ -private String encoding = null; +private String encoding = DEFAULT_ENCODING; // CheckStyle:VisibilityModifier OFF - bc @@ -302,8 +307,9 @@ * * pFor a list of possible values see a * href=http://java.sun.com/j2se/1.5.0/docs/guide/intl/encoding.doc.html;http://java.sun.com/j2se/1.5.0/docs/guide/intl/encoding.doc.html/a. - * Defaults to the platform's default character encoding./p - * @param encoding the encoding value + * Defaults to UTF-8./p + * @param encoding the encoding to use for file names, use null + * for the platform's default encoding * @since 1.3 */ public void setEncoding(String encoding) { Modified: commons/sandbox/compress/trunk/src/main/java/org/apache/commons/compress/archivers/zip/ZipFile.java URL: http://svn.apache.org/viewvc/commons/sandbox/compress/trunk/src/main/java/org/apache/commons/compress/archivers/zip/ZipFile.java?rev=745488r1=745487r2=745488view=diff == --- commons/sandbox/compress/trunk/src/main/java/org/apache/commons/compress/archivers/zip/ZipFile.java (original) +++ commons/sandbox/compress/trunk/src/main/java/org/apache/commons/compress/archivers/zip/ZipFile.java Wed Feb 18 12:12:54 2009 @@ -91,9 +91,9 @@ * * pFor a list of possible values see a * href=http://java.sun.com/j2se/1.5.0/docs/guide/intl/encoding.doc.html;http://java.sun.com/j2se/1.5.0/docs/guide/intl/encoding.doc.html/a. - * Defaults to the platform's default character encoding./p + * Defaults to UTF-8./p */ -private String encoding = null; +private final String encoding; /** * The actual data source. @@ -101,27 +101,25 @@ private RandomAccessFile archive; /** - * Opens the given file for reading, assuming the platform's - * native encoding for file names. + * Opens the given file for reading, assuming UTF8 for file names. * * @param f the archive. * * @throws IOException if an error occurs while reading the file. */ public ZipFile(File f) throws IOException { -this(f, null); +this(f, ZipArchiveOutputStream.DEFAULT_ENCODING); } /** - * Opens
svn commit: r745528 - in /commons/sandbox/compress/trunk/src/main/java/org/apache/commons/compress/archivers/zip: AbstractUnicodeExtraField.java ExtraFieldUtils.java UnicodeCommentExtraField.java Unic
Author: bodewig Date: Wed Feb 18 14:51:10 2009 New Revision: 745528 URL: http://svn.apache.org/viewvc?rev=745528view=rev Log: Add support for extra fields introduced by InfoZIP in order to store UTF-8 filenames in ZIPs. Submitted by Wolfgang Glas. SANDBOX-176 Added: commons/sandbox/compress/trunk/src/main/java/org/apache/commons/compress/archivers/zip/AbstractUnicodeExtraField.java (with props) commons/sandbox/compress/trunk/src/main/java/org/apache/commons/compress/archivers/zip/UnicodeCommentExtraField.java (with props) commons/sandbox/compress/trunk/src/main/java/org/apache/commons/compress/archivers/zip/UnicodePathExtraField.java (with props) commons/sandbox/compress/trunk/src/main/java/org/apache/commons/compress/archivers/zip/ZipEncodingHelper.java (with props) Modified: commons/sandbox/compress/trunk/src/main/java/org/apache/commons/compress/archivers/zip/ExtraFieldUtils.java Added: commons/sandbox/compress/trunk/src/main/java/org/apache/commons/compress/archivers/zip/AbstractUnicodeExtraField.java URL: http://svn.apache.org/viewvc/commons/sandbox/compress/trunk/src/main/java/org/apache/commons/compress/archivers/zip/AbstractUnicodeExtraField.java?rev=745528view=auto == --- commons/sandbox/compress/trunk/src/main/java/org/apache/commons/compress/archivers/zip/AbstractUnicodeExtraField.java (added) +++ commons/sandbox/compress/trunk/src/main/java/org/apache/commons/compress/archivers/zip/AbstractUnicodeExtraField.java Wed Feb 18 14:51:10 2009 @@ -0,0 +1,147 @@ +/* + * 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.zip; + +import java.io.UnsupportedEncodingException; +import java.util.zip.CRC32; +import java.util.zip.ZipException; + +/** + * A common base class for Unicode extra information extra fields. + */ +public abstract class AbstractUnicodeExtraField implements ZipExtraField { +private long nameCRC32; +private byte[] unicodeName; +private byte[] data; + +protected AbstractUnicodeExtraField() { +} + +/** + * Assemble as unicode path extension form the name and encoding + * of the orginal zip entry. + * + * @param name The file name or comment. + * @param zipEncoding The encoding of the filenames in the zip + * file, usually codeCP437/code. + */ +protected AbstractUnicodeExtraField(String name, String zipEncoding) { + +byte[] filename = ZipEncodingHelper.encodeName(name, zipEncoding); + +CRC32 crc32 = new CRC32(); +crc32.update(filename); +nameCRC32 = crc32.getValue(); + +try { +unicodeName = name.getBytes(UTF-8); +} catch (UnsupportedEncodingException e) { +throw new RuntimeException(FATAL: UTF-8 encoding not supported., + e); +} +} + +private void assembleData() { +if (unicodeName == null) { +return; +} + +data = new byte[5 + unicodeName.length]; +// version 1 +data[0] = 0x01; +System.arraycopy(ZipLong.getBytes(nameCRC32), 0, data, 1, 4); +System.arraycopy(unicodeName, 0, data, 5, unicodeName.length); +} + +/** + * @return The CRC32 checksum of the filename or comment as + * encoded in the central directory of the zip file. + */ +public long getNameCRC32() { +return nameCRC32; +} + +/** + * @param nameCRC32 The CRC32 checksum of the filename as encoded + * in the central directory of the zip file to set. + */ +public void setNameCRC32(long nameCRC32) { +nameCRC32 = nameCRC32; +data = null; +} + +/** + * @return The utf-8 encoded name. + */ +public byte[] getUnicodeName() { +return unicodeName; +} + +/** + * @param unicodeName The utf-8 encoded name to set. + */ +public void setUnicodeName(byte[] unicodeName) { +unicodeName = unicodeName; +data = null; +} + +public byte[] getCentralDirectoryData() { +if (data == null) { +this.assembleData
svn commit: r745846 - /commons/sandbox/compress/trunk/src/test/java/org/apache/commons/compress/changes/ChangeSetTestCase.java
Author: bodewig Date: Thu Feb 19 12:59:53 2009 New Revision: 745846 URL: http://svn.apache.org/viewvc?rev=745846view=rev Log: disable test that fails in Gump Modified: commons/sandbox/compress/trunk/src/test/java/org/apache/commons/compress/changes/ChangeSetTestCase.java Modified: commons/sandbox/compress/trunk/src/test/java/org/apache/commons/compress/changes/ChangeSetTestCase.java URL: http://svn.apache.org/viewvc/commons/sandbox/compress/trunk/src/test/java/org/apache/commons/compress/changes/ChangeSetTestCase.java?rev=745846r1=745845r2=745846view=diff == --- commons/sandbox/compress/trunk/src/test/java/org/apache/commons/compress/changes/ChangeSetTestCase.java (original) +++ commons/sandbox/compress/trunk/src/test/java/org/apache/commons/compress/changes/ChangeSetTestCase.java Thu Feb 19 12:59:53 2009 @@ -131,7 +131,7 @@ * Adds a file to a zip archive. Deletes an other file. * @throws Exception */ -public void testDeleteFromAndAddToZip() throws Exception { +public void XtestDeleteFromAndAddToZip() throws Exception { File input = this.createArchive(zip); ArchiveOutputStream out = null;
svn commit: r745855 - in /commons/sandbox/compress/trunk: pom.xml src/test/java/org/apache/commons/compress/archivers/zip/UTF8ZipFilesTest.java
Author: bodewig Date: Thu Feb 19 13:36:59 2009 New Revision: 745855 URL: http://svn.apache.org/viewvc?rev=745855view=rev Log: TestCase for new Unicode extra fields, based on submission by Wolfgang Glas, SANDBOX-176 Added: commons/sandbox/compress/trunk/src/test/java/org/apache/commons/compress/archivers/zip/UTF8ZipFilesTest.java (with props) Modified: commons/sandbox/compress/trunk/pom.xml Modified: commons/sandbox/compress/trunk/pom.xml URL: http://svn.apache.org/viewvc/commons/sandbox/compress/trunk/pom.xml?rev=745855r1=745854r2=745855view=diff == --- commons/sandbox/compress/trunk/pom.xml (original) +++ commons/sandbox/compress/trunk/pom.xml Thu Feb 19 13:36:59 2009 @@ -63,6 +63,10 @@ nameChristian Grobmeier/name emailgrobmeier at gmail.com/email /contributor +contributor + nameWolfgang Glas/name + emailwolfgang.glas at ev-i.at/email +/contributor /contributors scm Added: commons/sandbox/compress/trunk/src/test/java/org/apache/commons/compress/archivers/zip/UTF8ZipFilesTest.java URL: http://svn.apache.org/viewvc/commons/sandbox/compress/trunk/src/test/java/org/apache/commons/compress/archivers/zip/UTF8ZipFilesTest.java?rev=745855view=auto == --- commons/sandbox/compress/trunk/src/test/java/org/apache/commons/compress/archivers/zip/UTF8ZipFilesTest.java (added) +++ commons/sandbox/compress/trunk/src/test/java/org/apache/commons/compress/archivers/zip/UTF8ZipFilesTest.java Thu Feb 19 13:36:59 2009 @@ -0,0 +1,187 @@ +/* + * 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.zip; + +import java.io.File; +import java.io.FileInputStream; +import java.io.IOException; +import java.io.UnsupportedEncodingException; +import java.nio.charset.Charset; +import java.nio.charset.UnsupportedCharsetException; +import java.util.Enumeration; +import junit.framework.TestCase; + +public class UTF8ZipFilesTest extends TestCase { + +private static final String UTF_8 = utf-8; +private static final String CP437 = cp437; +private static final String US_ASCII = US-ASCII; +private static final String ASCII_TXT = ascii.txt; +private static final String EURO_FOR_DOLLAR_TXT = \u20AC_for_Dollar.txt; +private static final String OIL_BARREL_TXT = \u00D6lf\u00E4sser.txt; + +public void testUtf8FileRoundtrip() throws IOException { +testFileRoundtrip(UTF_8); +} + + +public void testCP437FileRoundtrip() throws IOException { +testFileRoundtrip(CP437); +} + +public void testASCIIFileRoundtrip() throws IOException { +testFileRoundtrip(US_ASCII); +} + +private static void testFileRoundtrip(String encoding) +throws IOException { + +try { +Charset.forName(encoding); +} catch (UnsupportedCharsetException use) { +System.err.println(Skipping testFileRoundtrip for unsupported + + encoding + encoding); +return; +} + +File file = File.createTempFile(encoding + -test, .zip); +try { +createTestFile(file, encoding); +testFile(file, encoding); +} finally { +if (file.exists()) { +file.delete(); +} +} +} + +private static void createTestFile(File file, String encoding) +throws UnsupportedEncodingException, IOException { + +ZipArchiveOutputStream zos = null; +try { +zos = new ZipArchiveOutputStream(file); +zos.setEncoding(encoding); + +ZipArchiveEntry ze = new ZipArchiveEntry(OIL_BARREL_TXT); +if (!ZipEncodingHelper.canEncodeName(ze.getName(), + zos.getEncoding())) { +ze.addExtraField(new UnicodePathExtraField(ze.getName(), + zos.getEncoding())); +} + +zos.putNextEntry(ze); +zos.write(Hello, world!.getBytes(US-ASCII
svn commit: r745920 - in /commons/sandbox/compress/trunk/src/main/java/org/apache/commons/compress/archivers/zip: ZipArchiveOutputStream.java ZipFile.java
Author: bodewig Date: Thu Feb 19 16:42:16 2009 New Revision: 745920 URL: http://svn.apache.org/viewvc?rev=745920view=rev Log: SANDBOX-176 - use and detect the EFS flag. Based on submissions made by Wolfgang Glas to commons-compress and TAMURA Kent to Ant. Modified: commons/sandbox/compress/trunk/src/main/java/org/apache/commons/compress/archivers/zip/ZipArchiveOutputStream.java commons/sandbox/compress/trunk/src/main/java/org/apache/commons/compress/archivers/zip/ZipFile.java Modified: commons/sandbox/compress/trunk/src/main/java/org/apache/commons/compress/archivers/zip/ZipArchiveOutputStream.java URL: http://svn.apache.org/viewvc/commons/sandbox/compress/trunk/src/main/java/org/apache/commons/compress/archivers/zip/ZipArchiveOutputStream.java?rev=745920r1=745919r2=745920view=diff == --- commons/sandbox/compress/trunk/src/main/java/org/apache/commons/compress/archivers/zip/ZipArchiveOutputStream.java (original) +++ commons/sandbox/compress/trunk/src/main/java/org/apache/commons/compress/archivers/zip/ZipArchiveOutputStream.java Thu Feb 19 16:42:16 2009 @@ -94,9 +94,20 @@ public static final int STORED = java.util.zip.ZipEntry.STORED; /** + * name of the encoding UTF-8 + */ +static final String UTF8 = UTF8; + +/** * default encoding for file names and comment. */ -static final String DEFAULT_ENCODING = UTF8; +static final String DEFAULT_ENCODING = UTF8; + + /** + * General purpose flag, which indicates that filenames are + * written in utf-8. + */ +public static final int EFS_FLAG = 1 11; /** * Current entry. @@ -254,6 +265,11 @@ private final OutputStream out; /** + * whether to use the EFS flag when writing UTF-8 filenames or not. + */ +private boolean useEFS = true; + +/** * Creates a new ZIP OutputStream filtering the underlying stream. * @param out the outputstream to zip * @since 1.1 @@ -312,8 +328,9 @@ * for the platform's default encoding * @since 1.3 */ -public void setEncoding(String encoding) { +public void setEncoding(final String encoding) { this.encoding = encoding; +useEFS = isUTF8(encoding); } /** @@ -328,6 +345,15 @@ } /** + * Whether to set the EFS flag if the file name encoding is UTF-8. + * + * pDefaults to true./p + */ +public void setUseEFS(boolean b) { +useEFS = b isUTF8(encoding); +} + +/** * Finishs writing the contents and closes this as well as the * underlying stream. * @@ -646,21 +672,7 @@ //store method in local variable to prevent multiple method calls final int zipMethod = ze.getMethod(); -// version needed to extract -// general purpose bit flag -// CheckStyle:MagicNumber OFF -if (zipMethod == DEFLATED raf == null) { -// requires version 2 as we are going to store length info -// in the data descriptor -writeOut(ZipShort.getBytes(20)); - -// bit3 set to signal, we use a data descriptor -writeOut(ZipShort.getBytes(8)); -} else { -writeOut(ZipShort.getBytes(10)); -writeOut(ZERO); -} -// CheckStyle:MagicNumber ON +writeVersionNeededToExtractAndGeneralPurposeBits(zipMethod); written += WORD; // compression method @@ -745,24 +757,12 @@ writeOut(ZipShort.getBytes((ze.getPlatform() 8) | 20)); written += SHORT; -// version needed to extract -// general purpose bit flag -if (ze.getMethod() == DEFLATED raf == null) { -// requires version 2 as we are going to store length info -// in the data descriptor -writeOut(ZipShort.getBytes(20)); - -// bit3 set to signal, we use a data descriptor -writeOut(ZipShort.getBytes(8)); -} else { -writeOut(ZipShort.getBytes(10)); -writeOut(ZERO); -} -// CheckStyle:MagicNumber ON +final int zipMethod = ze.getMethod(); +writeVersionNeededToExtractAndGeneralPurposeBits(zipMethod); written += WORD; // compression method -writeOut(ZipShort.getBytes(ze.getMethod())); +writeOut(ZipShort.getBytes(zipMethod)); written += SHORT; // last mod. time and date @@ -904,19 +904,14 @@ * this Stream. * @param name the string to get bytes from * @return the bytes as a byte array - * @throws ZipException on error * * @since 1.3 */ -protected byte[] getBytes(String name) throws ZipException { +protected byte[] getBytes(String name) { if (encoding == null) { return name.getBytes(); } else { -try { -return name.getBytes
svn commit: r745933 - /commons/sandbox/compress/trunk/src/main/java/org/apache/commons/compress/archivers/zip/ZipArchiveOutputStream.java
Author: bodewig Date: Thu Feb 19 17:23:05 2009 New Revision: 745933 URL: http://svn.apache.org/viewvc?rev=745933view=rev Log: NIO doesn't recognize all encoding names that String.getBytes does, strange. At least it fails for 'UnicodeBig' on my Java 1.4 installation Modified: commons/sandbox/compress/trunk/src/main/java/org/apache/commons/compress/archivers/zip/ZipArchiveOutputStream.java Modified: commons/sandbox/compress/trunk/src/main/java/org/apache/commons/compress/archivers/zip/ZipArchiveOutputStream.java URL: http://svn.apache.org/viewvc/commons/sandbox/compress/trunk/src/main/java/org/apache/commons/compress/archivers/zip/ZipArchiveOutputStream.java?rev=745933r1=745932r2=745933view=diff == --- commons/sandbox/compress/trunk/src/main/java/org/apache/commons/compress/archivers/zip/ZipArchiveOutputStream.java (original) +++ commons/sandbox/compress/trunk/src/main/java/org/apache/commons/compress/archivers/zip/ZipArchiveOutputStream.java Thu Feb 19 17:23:05 2009 @@ -904,14 +904,25 @@ * this Stream. * @param name the string to get bytes from * @return the bytes as a byte array + * @throws ZipException on error * * @since 1.3 */ -protected byte[] getBytes(String name) { +protected byte[] getBytes(String name) throws ZipException { if (encoding == null) { return name.getBytes(); } else { -return ZipEncodingHelper.encodeName(name, encoding); +try { +return ZipEncodingHelper.encodeName(name, encoding); +} catch (java.nio.charset.UnsupportedCharsetException ex) { +// Java 1.4's NIO doesn't recognize a few names that +// String.getBytes does +try { +return name.getBytes(encoding); +} catch (UnsupportedEncodingException uee) { +throw new ZipException(uee.getMessage()); +} +} } }
svn commit: r746291 - /commons/sandbox/compress/trunk/src/test/java/org/apache/commons/compress/archivers/zip/UTF8ZipFilesTest.java
Author: bodewig Date: Fri Feb 20 16:46:37 2009 New Revision: 746291 URL: http://svn.apache.org/viewvc?rev=746291view=rev Log: separate unicode tests with and without EFS flag Modified: commons/sandbox/compress/trunk/src/test/java/org/apache/commons/compress/archivers/zip/UTF8ZipFilesTest.java Modified: commons/sandbox/compress/trunk/src/test/java/org/apache/commons/compress/archivers/zip/UTF8ZipFilesTest.java URL: http://svn.apache.org/viewvc/commons/sandbox/compress/trunk/src/test/java/org/apache/commons/compress/archivers/zip/UTF8ZipFilesTest.java?rev=746291r1=746290r2=746291view=diff == --- commons/sandbox/compress/trunk/src/test/java/org/apache/commons/compress/archivers/zip/UTF8ZipFilesTest.java (original) +++ commons/sandbox/compress/trunk/src/test/java/org/apache/commons/compress/archivers/zip/UTF8ZipFilesTest.java Fri Feb 20 16:46:37 2009 @@ -37,19 +37,22 @@ private static final String OIL_BARREL_TXT = \u00D6lf\u00E4sser.txt; public void testUtf8FileRoundtrip() throws IOException { -testFileRoundtrip(UTF_8); +testFileRoundtrip(UTF_8, true); } +public void testUtf8FileRoundtripNoEFS() throws IOException { +testFileRoundtrip(UTF_8, false); +} public void testCP437FileRoundtrip() throws IOException { -testFileRoundtrip(CP437); +testFileRoundtrip(CP437, false); } public void testASCIIFileRoundtrip() throws IOException { -testFileRoundtrip(US_ASCII); +testFileRoundtrip(US_ASCII, false); } -private static void testFileRoundtrip(String encoding) +private static void testFileRoundtrip(String encoding, boolean withEFS) throws IOException { try { @@ -62,7 +65,7 @@ File file = File.createTempFile(encoding + -test, .zip); try { -createTestFile(file, encoding); +createTestFile(file, encoding, withEFS); testFile(file, encoding); } finally { if (file.exists()) { @@ -71,13 +74,15 @@ } } -private static void createTestFile(File file, String encoding) +private static void createTestFile(File file, String encoding, + boolean withEFS) throws UnsupportedEncodingException, IOException { ZipArchiveOutputStream zos = null; try { zos = new ZipArchiveOutputStream(file); zos.setEncoding(encoding); +zos.setUseEFS(withEFS); ZipArchiveEntry ze = new ZipArchiveEntry(OIL_BARREL_TXT); if (!ZipEncodingHelper.canEncodeName(ze.getName(),
svn commit: r746917 - in /commons/sandbox/compress/trunk/src/test: java/org/apache/commons/compress/archivers/zip/UTF8ZipFilesTest.java resources/utf8-7zip-test.zip resources/utf8-winzip-test.zip
Author: bodewig Date: Mon Feb 23 08:21:40 2009 New Revision: 746917 URL: http://svn.apache.org/viewvc?rev=746917view=rev Log: EFS-Flag interop test using 7-Zip created file submitted by wolfgang Glas. SANDBOX-176 Added: commons/sandbox/compress/trunk/src/test/resources/utf8-7zip-test.zip (with props) commons/sandbox/compress/trunk/src/test/resources/utf8-winzip-test.zip (with props) Modified: commons/sandbox/compress/trunk/src/test/java/org/apache/commons/compress/archivers/zip/UTF8ZipFilesTest.java Modified: commons/sandbox/compress/trunk/src/test/java/org/apache/commons/compress/archivers/zip/UTF8ZipFilesTest.java URL: http://svn.apache.org/viewvc/commons/sandbox/compress/trunk/src/test/java/org/apache/commons/compress/archivers/zip/UTF8ZipFilesTest.java?rev=746917r1=746916r2=746917view=diff == --- commons/sandbox/compress/trunk/src/test/java/org/apache/commons/compress/archivers/zip/UTF8ZipFilesTest.java (original) +++ commons/sandbox/compress/trunk/src/test/java/org/apache/commons/compress/archivers/zip/UTF8ZipFilesTest.java Mon Feb 23 08:21:40 2009 @@ -22,6 +22,9 @@ import java.io.FileInputStream; import java.io.IOException; import java.io.UnsupportedEncodingException; +import java.net.URI; +import java.net.URL; +import java.net.URISyntaxException; import java.nio.charset.Charset; import java.nio.charset.UnsupportedCharsetException; import java.util.Enumeration; @@ -36,22 +39,38 @@ private static final String EURO_FOR_DOLLAR_TXT = \u20AC_for_Dollar.txt; private static final String OIL_BARREL_TXT = \u00D6lf\u00E4sser.txt; -public void testUtf8FileRoundtrip() throws IOException { +public void xtestUtf8FileRoundtrip() throws IOException { testFileRoundtrip(UTF_8, true); } -public void testUtf8FileRoundtripNoEFS() throws IOException { +public void xtestUtf8FileRoundtripNoEFS() throws IOException { testFileRoundtrip(UTF_8, false); } -public void testCP437FileRoundtrip() throws IOException { +public void xtestCP437FileRoundtrip() throws IOException { testFileRoundtrip(CP437, false); } -public void testASCIIFileRoundtrip() throws IOException { +public void xtestASCIIFileRoundtrip() throws IOException { testFileRoundtrip(US_ASCII, false); } +/** + * 7-ZIP created archive, uses EFS to signal UTF-8 filenames. + */ +public void testReadEFS() throws IOException, URISyntaxException { +URL zip = getClass().getResource(/utf8-7zip-test.zip); +File archive = new File(new URI(zip.toString())); +ZipFile zf = null; +try { +zf = new ZipFile(archive); +assertNotNull(zf.getEntry(ASCII_TXT)); +assertNotNull(zf.getEntry(EURO_FOR_DOLLAR_TXT)); +} finally { +ZipFile.closeQuietly(zf); +} +} + private static void testFileRoundtrip(String encoding, boolean withEFS) throws IOException { Added: commons/sandbox/compress/trunk/src/test/resources/utf8-7zip-test.zip URL: http://svn.apache.org/viewvc/commons/sandbox/compress/trunk/src/test/resources/utf8-7zip-test.zip?rev=746917view=auto == Binary file - no diff available. Propchange: commons/sandbox/compress/trunk/src/test/resources/utf8-7zip-test.zip -- svn:mime-type = application/octet-stream Added: commons/sandbox/compress/trunk/src/test/resources/utf8-winzip-test.zip URL: http://svn.apache.org/viewvc/commons/sandbox/compress/trunk/src/test/resources/utf8-winzip-test.zip?rev=746917view=auto == Binary file - no diff available. Propchange: commons/sandbox/compress/trunk/src/test/resources/utf8-winzip-test.zip -- svn:mime-type = application/octet-stream
svn commit: r746933 - in /commons/sandbox/compress/trunk/src/main/java/org/apache/commons/compress/archivers/zip: ZipEncodingHelper.java ZipFile.java
Author: bodewig Date: Mon Feb 23 09:01:59 2009 New Revision: 746933 URL: http://svn.apache.org/viewvc?rev=746933view=rev Log: use NIO to decode names as well Modified: commons/sandbox/compress/trunk/src/main/java/org/apache/commons/compress/archivers/zip/ZipEncodingHelper.java commons/sandbox/compress/trunk/src/main/java/org/apache/commons/compress/archivers/zip/ZipFile.java Modified: commons/sandbox/compress/trunk/src/main/java/org/apache/commons/compress/archivers/zip/ZipEncodingHelper.java URL: http://svn.apache.org/viewvc/commons/sandbox/compress/trunk/src/main/java/org/apache/commons/compress/archivers/zip/ZipEncodingHelper.java?rev=746933r1=746932r2=746933view=diff == --- commons/sandbox/compress/trunk/src/main/java/org/apache/commons/compress/archivers/zip/ZipEncodingHelper.java (original) +++ commons/sandbox/compress/trunk/src/main/java/org/apache/commons/compress/archivers/zip/ZipEncodingHelper.java Mon Feb 23 09:01:59 2009 @@ -168,4 +168,18 @@ return enc.canEncode(name); } + +/** + * Decode a filename or a comment from a byte array. + * + * @param name The filename or comment. + * @param encoding A valid encoding name. The standard zip + * encoding is codeCP437/code, + * codeUTF-8/code is supported in ZIP file + * version code6.3/code or later. + */ +static final String decodeName(byte[] name, String encoding) { +Charset cs = Charset.forName(encoding); +return cs.decode(ByteBuffer.wrap(name)).toString(); +} } Modified: commons/sandbox/compress/trunk/src/main/java/org/apache/commons/compress/archivers/zip/ZipFile.java URL: http://svn.apache.org/viewvc/commons/sandbox/compress/trunk/src/main/java/org/apache/commons/compress/archivers/zip/ZipFile.java?rev=746933r1=746932r2=746933view=diff == --- commons/sandbox/compress/trunk/src/main/java/org/apache/commons/compress/archivers/zip/ZipFile.java (original) +++ commons/sandbox/compress/trunk/src/main/java/org/apache/commons/compress/archivers/zip/ZipFile.java Mon Feb 23 09:01:59 2009 @@ -538,9 +538,15 @@ return new String(bytes); } else { try { -return new String(bytes, enc); -} catch (UnsupportedEncodingException uee) { -throw new ZipException(uee.getMessage()); +return ZipEncodingHelper.decodeName(bytes, encoding); +} catch (java.nio.charset.UnsupportedCharsetException ex) { +// Java 1.4's NIO doesn't recognize a few names that +// String.getBytes does +try { +return new String(bytes, enc); +} catch (UnsupportedEncodingException uee) { +throw new ZipException(uee.getMessage()); +} } } }
svn commit: r746940 - /commons/sandbox/compress/trunk/src/test/java/org/apache/commons/compress/archivers/zip/UTF8ZipFilesTest.java
Author: bodewig Date: Mon Feb 23 09:22:00 2009 New Revision: 746940 URL: http://svn.apache.org/viewvc?rev=746940view=rev Log: re-enable tests disabled by accident. 7ZIP uses CP437 by default Modified: commons/sandbox/compress/trunk/src/test/java/org/apache/commons/compress/archivers/zip/UTF8ZipFilesTest.java Modified: commons/sandbox/compress/trunk/src/test/java/org/apache/commons/compress/archivers/zip/UTF8ZipFilesTest.java URL: http://svn.apache.org/viewvc/commons/sandbox/compress/trunk/src/test/java/org/apache/commons/compress/archivers/zip/UTF8ZipFilesTest.java?rev=746940r1=746939r2=746940view=diff == --- commons/sandbox/compress/trunk/src/test/java/org/apache/commons/compress/archivers/zip/UTF8ZipFilesTest.java (original) +++ commons/sandbox/compress/trunk/src/test/java/org/apache/commons/compress/archivers/zip/UTF8ZipFilesTest.java Mon Feb 23 09:22:00 2009 @@ -43,29 +43,33 @@ testFileRoundtrip(UTF_8, true); } -public void xtestUtf8FileRoundtripNoEFS() throws IOException { +public void testUtf8FileRoundtripNoEFS() throws IOException { testFileRoundtrip(UTF_8, false); } -public void xtestCP437FileRoundtrip() throws IOException { +public void testCP437FileRoundtrip() throws IOException { testFileRoundtrip(CP437, false); } -public void xtestASCIIFileRoundtrip() throws IOException { +public void testASCIIFileRoundtrip() throws IOException { testFileRoundtrip(US_ASCII, false); } -/** +/* * 7-ZIP created archive, uses EFS to signal UTF-8 filenames. + * + * 7-ZIP doesn't use EFS for strings that can be encoded in CP437 + * - which is true for OIL_BARREL_TXT. */ -public void testReadEFS() throws IOException, URISyntaxException { +public void testRead7ZipArchive() throws IOException, URISyntaxException { URL zip = getClass().getResource(/utf8-7zip-test.zip); File archive = new File(new URI(zip.toString())); ZipFile zf = null; try { -zf = new ZipFile(archive); +zf = new ZipFile(archive, CP437); assertNotNull(zf.getEntry(ASCII_TXT)); assertNotNull(zf.getEntry(EURO_FOR_DOLLAR_TXT)); +assertNotNull(zf.getEntry(OIL_BARREL_TXT)); } finally { ZipFile.closeQuietly(zf); }
svn commit: r747005 - /commons/sandbox/compress/trunk/src/main/java/org/apache/commons/compress/archivers/zip/ZipFile.java
Author: bodewig Date: Mon Feb 23 13:14:39 2009 New Revision: 747005 URL: http://svn.apache.org/viewvc?rev=747005view=rev Log: use desired encoding when decoding a file name Modified: commons/sandbox/compress/trunk/src/main/java/org/apache/commons/compress/archivers/zip/ZipFile.java (contents, props changed) Modified: commons/sandbox/compress/trunk/src/main/java/org/apache/commons/compress/archivers/zip/ZipFile.java URL: http://svn.apache.org/viewvc/commons/sandbox/compress/trunk/src/main/java/org/apache/commons/compress/archivers/zip/ZipFile.java?rev=747005r1=747004r2=747005view=diff == --- commons/sandbox/compress/trunk/src/main/java/org/apache/commons/compress/archivers/zip/ZipFile.java (original) +++ commons/sandbox/compress/trunk/src/main/java/org/apache/commons/compress/archivers/zip/ZipFile.java Mon Feb 23 13:14:39 2009 @@ -538,7 +538,7 @@ return new String(bytes); } else { try { -return ZipEncodingHelper.decodeName(bytes, encoding); +return ZipEncodingHelper.decodeName(bytes, enc); } catch (java.nio.charset.UnsupportedCharsetException ex) { // Java 1.4's NIO doesn't recognize a few names that // String.getBytes does Propchange: commons/sandbox/compress/trunk/src/main/java/org/apache/commons/compress/archivers/zip/ZipFile.java -- --- svn:mergeinfo (original) +++ svn:mergeinfo Mon Feb 23 13:14:39 2009 @@ -1 +1 @@ -/ant/core/trunk/src/main/org/apache/tools/zip/ZipFile.java:738844,738853,739300,741089 +/ant/core/trunk/src/main/org/apache/tools/zip/ZipFile.java:738844,738853,739300,741089,747002
svn commit: r747071 - /commons/sandbox/compress/trunk/src/main/java/org/apache/commons/compress/utils/CompressUtils.java
Author: bodewig Date: Mon Feb 23 16:33:10 2009 New Revision: 747071 URL: http://svn.apache.org/viewvc?rev=747071view=rev Log: remove unused class. SANDBOX-287 Removed: commons/sandbox/compress/trunk/src/main/java/org/apache/commons/compress/utils/CompressUtils.java
svn commit: r747810 - in /commons/sandbox/compress/trunk/src: main/java/org/apache/commons/compress/archivers/zip/ZipArchiveOutputStream.java test/java/org/apache/commons/compress/archivers/zip/UTF8Zi
Author: bodewig Date: Wed Feb 25 15:05:53 2009 New Revision: 747810 URL: http://svn.apache.org/viewvc?rev=747810view=rev Log: Use a less technical name for method Modified: commons/sandbox/compress/trunk/src/main/java/org/apache/commons/compress/archivers/zip/ZipArchiveOutputStream.java commons/sandbox/compress/trunk/src/test/java/org/apache/commons/compress/archivers/zip/UTF8ZipFilesTest.java Modified: commons/sandbox/compress/trunk/src/main/java/org/apache/commons/compress/archivers/zip/ZipArchiveOutputStream.java URL: http://svn.apache.org/viewvc/commons/sandbox/compress/trunk/src/main/java/org/apache/commons/compress/archivers/zip/ZipArchiveOutputStream.java?rev=747810r1=747809r2=747810view=diff == --- commons/sandbox/compress/trunk/src/main/java/org/apache/commons/compress/archivers/zip/ZipArchiveOutputStream.java (original) +++ commons/sandbox/compress/trunk/src/main/java/org/apache/commons/compress/archivers/zip/ZipArchiveOutputStream.java Wed Feb 25 15:05:53 2009 @@ -345,11 +345,12 @@ } /** - * Whether to set the EFS flag if the file name encoding is UTF-8. + * Whether to set the language encoding flag if the file name + * encoding is UTF-8. * * pDefaults to true./p */ -public void setUseEFS(boolean b) { +public void setUseLanguageEncodingFlag(boolean b) { useEFS = b isUTF8(encoding); } Modified: commons/sandbox/compress/trunk/src/test/java/org/apache/commons/compress/archivers/zip/UTF8ZipFilesTest.java URL: http://svn.apache.org/viewvc/commons/sandbox/compress/trunk/src/test/java/org/apache/commons/compress/archivers/zip/UTF8ZipFilesTest.java?rev=747810r1=747809r2=747810view=diff == --- commons/sandbox/compress/trunk/src/test/java/org/apache/commons/compress/archivers/zip/UTF8ZipFilesTest.java (original) +++ commons/sandbox/compress/trunk/src/test/java/org/apache/commons/compress/archivers/zip/UTF8ZipFilesTest.java Wed Feb 25 15:05:53 2009 @@ -105,7 +105,7 @@ try { zos = new ZipArchiveOutputStream(file); zos.setEncoding(encoding); -zos.setUseEFS(withEFS); +zos.setUseLanguageEncodingFlag(withEFS); ZipArchiveEntry ze = new ZipArchiveEntry(OIL_BARREL_TXT); if (!ZipEncodingHelper.canEncodeName(ze.getName(),
svn commit: r747841 - in /commons/sandbox/compress/trunk/src: main/java/org/apache/commons/compress/archivers/zip/ test/java/org/apache/commons/compress/archivers/zip/
Author: bodewig Date: Wed Feb 25 16:09:12 2009 New Revision: 747841 URL: http://svn.apache.org/viewvc?rev=747841view=rev Log: add an option to implicitly create Unicode Extra Fields in ZiparchiveOutputStream Modified: commons/sandbox/compress/trunk/src/main/java/org/apache/commons/compress/archivers/zip/ZipArchiveOutputStream.java commons/sandbox/compress/trunk/src/main/java/org/apache/commons/compress/archivers/zip/ZipEncodingHelper.java commons/sandbox/compress/trunk/src/test/java/org/apache/commons/compress/archivers/zip/UTF8ZipFilesTest.java Modified: commons/sandbox/compress/trunk/src/main/java/org/apache/commons/compress/archivers/zip/ZipArchiveOutputStream.java URL: http://svn.apache.org/viewvc/commons/sandbox/compress/trunk/src/main/java/org/apache/commons/compress/archivers/zip/ZipArchiveOutputStream.java?rev=747841r1=747840r2=747841view=diff == --- commons/sandbox/compress/trunk/src/main/java/org/apache/commons/compress/archivers/zip/ZipArchiveOutputStream.java (original) +++ commons/sandbox/compress/trunk/src/main/java/org/apache/commons/compress/archivers/zip/ZipArchiveOutputStream.java Wed Feb 25 16:09:12 2009 @@ -270,6 +270,11 @@ private boolean useEFS = true; /** + * whether to create UnicodePathExtraField-s for each entry. + */ +private boolean createUnicodeExtraFields = false; + +/** * Creates a new ZIP OutputStream filtering the underlying stream. * @param out the outputstream to zip * @since 1.1 @@ -355,6 +360,15 @@ } /** + * Whether to create Unicode Extra Fields for all entries. + * + * pDefaults to false./p + */ +public void setCreateUnicodeExtraFields(boolean b) { +createUnicodeExtraFields = b; +} + +/** * Finishs writing the contents and closes this as well as the * underlying stream. * @@ -450,6 +464,14 @@ closeEntry(); entry = ze; +if (createUnicodeExtraFields) { +ze.addExtraField(new UnicodePathExtraField(ze.getName(), + encoding)); +if (ze.getComment() != null) { +ze.addExtraField(new UnicodeCommentExtraField(ze.getComment(), + encoding)); +} +} entries.add(entry); if (entry.getMethod() == -1) { // not specified Modified: commons/sandbox/compress/trunk/src/main/java/org/apache/commons/compress/archivers/zip/ZipEncodingHelper.java URL: http://svn.apache.org/viewvc/commons/sandbox/compress/trunk/src/main/java/org/apache/commons/compress/archivers/zip/ZipEncodingHelper.java?rev=747841r1=747840r2=747841view=diff == --- commons/sandbox/compress/trunk/src/main/java/org/apache/commons/compress/archivers/zip/ZipEncodingHelper.java (original) +++ commons/sandbox/compress/trunk/src/main/java/org/apache/commons/compress/archivers/zip/ZipEncodingHelper.java Wed Feb 25 16:09:12 2009 @@ -75,17 +75,23 @@ * /pre * * @param name The filename or comment with possible non-ASCII - * unicode characters. + * unicode characters. Must not be null. * @param encoding A valid encoding name. The standard zip * encoding is codeCP437/code, * codeUTF-8/code is supported in ZIP file - * version code6.3/code or later. + * version code6.3/code or later. If null, + * will use the platform's {...@link + * java.lang.String#getBytes default encoding}. * @return A byte array containing the mapped file * name. Unmappable characters or malformed character * sequences are mapped to a sequence of utf-16 words * encoded in the format code%U/code. */ static final byte[] encodeName(String name, String encoding) { +if (encoding == null) { +return name.getBytes(); +} + Charset cs = Charset.forName(encoding); CharsetEncoder enc = cs.newEncoder(); Modified: commons/sandbox/compress/trunk/src/test/java/org/apache/commons/compress/archivers/zip/UTF8ZipFilesTest.java URL: http://svn.apache.org/viewvc/commons/sandbox/compress/trunk/src/test/java/org/apache/commons/compress/archivers/zip/UTF8ZipFilesTest.java?rev=747841r1=747840r2=747841view=diff == --- commons/sandbox/compress/trunk/src/test/java/org/apache/commons/compress/archivers/zip/UTF8ZipFilesTest.java (original) +++ commons/sandbox/compress/trunk/src/test/java/org/apache/commons/compress/archivers/zip/UTF8ZipFilesTest.java Wed Feb 25 16:09:12 2009 @@ -39,20 +39,44 @@ private static final String
svn commit: r748063 - in /commons/sandbox/compress/trunk/src/main/java/org/apache/commons/compress/archivers/zip: AbstractUnicodeExtraField.java UnicodeCommentExtraField.java UnicodePathExtraField.jav
Author: bodewig Date: Thu Feb 26 09:07:23 2009 New Revision: 748063 URL: http://svn.apache.org/viewvc?rev=748063view=rev Log: make sure UnicodeField sees the same bytes that are actually written to the archive when calculating the CRC Modified: commons/sandbox/compress/trunk/src/main/java/org/apache/commons/compress/archivers/zip/AbstractUnicodeExtraField.java commons/sandbox/compress/trunk/src/main/java/org/apache/commons/compress/archivers/zip/UnicodeCommentExtraField.java commons/sandbox/compress/trunk/src/main/java/org/apache/commons/compress/archivers/zip/UnicodePathExtraField.java commons/sandbox/compress/trunk/src/main/java/org/apache/commons/compress/archivers/zip/ZipArchiveOutputStream.java Modified: commons/sandbox/compress/trunk/src/main/java/org/apache/commons/compress/archivers/zip/AbstractUnicodeExtraField.java URL: http://svn.apache.org/viewvc/commons/sandbox/compress/trunk/src/main/java/org/apache/commons/compress/archivers/zip/AbstractUnicodeExtraField.java?rev=748063r1=748062r2=748063view=diff == --- commons/sandbox/compress/trunk/src/main/java/org/apache/commons/compress/archivers/zip/AbstractUnicodeExtraField.java (original) +++ commons/sandbox/compress/trunk/src/main/java/org/apache/commons/compress/archivers/zip/AbstractUnicodeExtraField.java Thu Feb 26 09:07:23 2009 @@ -34,23 +34,32 @@ } /** - * Assemble as unicode path extension form the name and encoding - * of the orginal zip entry. + * Assemble as unicode extension from the name/comment and + * encoding of the orginal zip entry. * - * @param name The file name or comment. + * @param text The file name or comment. * @param zipEncoding The encoding of the filenames in the zip * file, usually codeCP437/code. */ -protected AbstractUnicodeExtraField(String name, String zipEncoding) { - -byte[] filename = ZipEncodingHelper.encodeName(name, zipEncoding); +protected AbstractUnicodeExtraField(String text, String zipEncoding) { +this(text, ZipEncodingHelper.encodeName(text, zipEncoding)); +} +/** + * Assemble as unicode extension from the name/comment and + * encoding of the orginal zip entry. + * + * @param text The file name or comment. + * @param zipEncoding The encoding of the filenames in the zip + * file, usually codeCP437/code. + */ +protected AbstractUnicodeExtraField(String text, byte[] bytes) { CRC32 crc32 = new CRC32(); -crc32.update(filename); +crc32.update(bytes); nameCRC32 = crc32.getValue(); try { -unicodeName = name.getBytes(UTF-8); +unicodeName = text.getBytes(UTF-8); } catch (UnsupportedEncodingException e) { throw new RuntimeException(FATAL: UTF-8 encoding not supported., e); Modified: commons/sandbox/compress/trunk/src/main/java/org/apache/commons/compress/archivers/zip/UnicodeCommentExtraField.java URL: http://svn.apache.org/viewvc/commons/sandbox/compress/trunk/src/main/java/org/apache/commons/compress/archivers/zip/UnicodeCommentExtraField.java?rev=748063r1=748062r2=748063view=diff == --- commons/sandbox/compress/trunk/src/main/java/org/apache/commons/compress/archivers/zip/UnicodeCommentExtraField.java (original) +++ commons/sandbox/compress/trunk/src/main/java/org/apache/commons/compress/archivers/zip/UnicodeCommentExtraField.java Thu Feb 26 09:07:23 2009 @@ -42,15 +42,26 @@ } /** - * Assemble as unicode comment extension form the comment and + * Assemble as unicode comment extension from the comment and * encoding of the orginal zip entry. * - * @param name The file name + * @param comment The file comment * @param zipEncoding The encoding of the comment in the zip file, * usually codeCP437/code. */ -public UnicodeCommentExtraField(String name, String zipEncoding) { -super(name, zipEncoding); +public UnicodeCommentExtraField(String comment, String zipEncoding) { +super(comment, zipEncoding); +} + +/** + * Assemble as unicode comment extension from the comment given as + * text as well as the bytes actually written to the archive. + * + * @param comment The file comment + * @param bytes the bytes actually written to the archive + */ +public UnicodeCommentExtraField(String comment, byte[] bytes) { +super(comment, bytes); } public ZipShort getHeaderId() { Modified: commons/sandbox/compress/trunk/src/main/java/org/apache/commons/compress/archivers/zip/UnicodePathExtraField.java URL: http://svn.apache.org/viewvc/commons/sandbox/compress/trunk/src/main/java/org/apache/commons/compress/archivers/zip/UnicodePathExtraField.java?rev=748063r1
svn commit: r748067 - in /commons/sandbox/compress/trunk/src: main/java/org/apache/commons/compress/archivers/jar/ main/java/org/apache/commons/compress/archivers/zip/ test/java/org/apache/commons/com
Author: bodewig Date: Thu Feb 26 09:31:43 2009 New Revision: 748067 URL: http://svn.apache.org/viewvc?rev=748067view=rev Log: correct signature detection of ZIP archives. Modified: commons/sandbox/compress/trunk/src/main/java/org/apache/commons/compress/archivers/jar/JarArchiveInputStream.java commons/sandbox/compress/trunk/src/main/java/org/apache/commons/compress/archivers/zip/ZipArchiveInputStream.java commons/sandbox/compress/trunk/src/test/java/org/apache/commons/compress/DetectArchiverTestCase.java Modified: commons/sandbox/compress/trunk/src/main/java/org/apache/commons/compress/archivers/jar/JarArchiveInputStream.java URL: http://svn.apache.org/viewvc/commons/sandbox/compress/trunk/src/main/java/org/apache/commons/compress/archivers/jar/JarArchiveInputStream.java?rev=748067r1=748066r2=748067view=diff == --- commons/sandbox/compress/trunk/src/main/java/org/apache/commons/compress/archivers/jar/JarArchiveInputStream.java (original) +++ commons/sandbox/compress/trunk/src/main/java/org/apache/commons/compress/archivers/jar/JarArchiveInputStream.java Thu Feb 26 09:31:43 2009 @@ -41,37 +41,6 @@ } public static boolean matches(byte[] signature, int length ) { -// 4b50 0403 0014 0008 - -if (length 8) { -return false; -} - -if (signature[0] != 0x50) { -return false; -} -if (signature[1] != 0x4b) { -return false; -} -if (signature[2] != 0x03) { -return false; -} -if (signature[3] != 0x04) { -return false; -} -if (signature[4] != 0x14) { -return false; -} -if (signature[5] != 0x00) { -return false; -} -if (signature[6] != 0x08) { -return false; -} -if (signature[7] != 0x00) { -return false; -} - -return true; +return ZipArchiveInputStream.matches(signature, length); } } Modified: commons/sandbox/compress/trunk/src/main/java/org/apache/commons/compress/archivers/zip/ZipArchiveInputStream.java URL: http://svn.apache.org/viewvc/commons/sandbox/compress/trunk/src/main/java/org/apache/commons/compress/archivers/zip/ZipArchiveInputStream.java?rev=748067r1=748066r2=748067view=diff == --- commons/sandbox/compress/trunk/src/main/java/org/apache/commons/compress/archivers/zip/ZipArchiveInputStream.java (original) +++ commons/sandbox/compress/trunk/src/main/java/org/apache/commons/compress/archivers/zip/ZipArchiveInputStream.java Thu Feb 26 09:31:43 2009 @@ -54,36 +54,15 @@ } -public static boolean matches( byte[] signature, int length ) { -// 4b50 0403 0014 - -if (length 8) { +public static boolean matches(byte[] signature, int length) { +if (length ZipArchiveOutputStream.LFH_SIG.length) { return false; } -if (signature[0] != 0x50) { -return false; -} -if (signature[1] != 0x4b) { -return false; -} -if (signature[2] != 0x03) { -return false; -} -if (signature[3] != 0x04) { -return false; -} -if (signature[4] != 0x14) { -return false; -} -if (signature[5] != 0x00) { -return false; -} -if (signature[6] != 0x00) { -return false; -} -if (signature[7] != 0x00) { -return false; +for (int i = 0; i ZipArchiveOutputStream.LFH_SIG.length; i++) { +if (signature[i] != ZipArchiveOutputStream.LFH_SIG[i]) { +return false; +} } return true; Modified: commons/sandbox/compress/trunk/src/test/java/org/apache/commons/compress/DetectArchiverTestCase.java URL: http://svn.apache.org/viewvc/commons/sandbox/compress/trunk/src/test/java/org/apache/commons/compress/DetectArchiverTestCase.java?rev=748067r1=748066r2=748067view=diff == --- commons/sandbox/compress/trunk/src/test/java/org/apache/commons/compress/DetectArchiverTestCase.java (original) +++ commons/sandbox/compress/trunk/src/test/java/org/apache/commons/compress/DetectArchiverTestCase.java Thu Feb 26 09:31:43 2009 @@ -58,7 +58,7 @@ new BufferedInputStream(new FileInputStream( new File(getClass().getClassLoader().getResource(bla.jar).getFile(); assertNotNull(jar); -assertTrue(jar instanceof JarArchiveInputStream); +assertTrue(jar instanceof ZipArchiveInputStream
svn commit: r748133 - in /commons/sandbox/compress/trunk/src: main/java/org/apache/commons/compress/archivers/zip/ test/java/org/apache/commons/compress/archivers/zip/
Author: bodewig Date: Thu Feb 26 13:15:14 2009 New Revision: 748133 URL: http://svn.apache.org/viewvc?rev=748133view=rev Log: optionally use UnicodeExtraFields to set names and comments of entries when reading. SANDBOX-176 Modified: commons/sandbox/compress/trunk/src/main/java/org/apache/commons/compress/archivers/zip/ZipEncodingHelper.java commons/sandbox/compress/trunk/src/main/java/org/apache/commons/compress/archivers/zip/ZipFile.java commons/sandbox/compress/trunk/src/test/java/org/apache/commons/compress/archivers/zip/UTF8ZipFilesTest.java Modified: commons/sandbox/compress/trunk/src/main/java/org/apache/commons/compress/archivers/zip/ZipEncodingHelper.java URL: http://svn.apache.org/viewvc/commons/sandbox/compress/trunk/src/main/java/org/apache/commons/compress/archivers/zip/ZipEncodingHelper.java?rev=748133r1=748132r2=748133view=diff == --- commons/sandbox/compress/trunk/src/main/java/org/apache/commons/compress/archivers/zip/ZipEncodingHelper.java (original) +++ commons/sandbox/compress/trunk/src/main/java/org/apache/commons/compress/archivers/zip/ZipEncodingHelper.java Thu Feb 26 13:15:14 2009 @@ -184,8 +184,12 @@ * codeUTF-8/code is supported in ZIP file * version code6.3/code or later. */ -static final String decodeName(byte[] name, String encoding) { +static final String decodeName(byte[] name, String encoding) +throws java.nio.charset.CharacterCodingException { Charset cs = Charset.forName(encoding); -return cs.decode(ByteBuffer.wrap(name)).toString(); +return cs.newDecoder() +.onMalformedInput(CodingErrorAction.REPORT) +.onUnmappableCharacter(CodingErrorAction.REPORT) +.decode(ByteBuffer.wrap(name)).toString(); } } Modified: commons/sandbox/compress/trunk/src/main/java/org/apache/commons/compress/archivers/zip/ZipFile.java URL: http://svn.apache.org/viewvc/commons/sandbox/compress/trunk/src/main/java/org/apache/commons/compress/archivers/zip/ZipFile.java?rev=748133r1=748132r2=748133view=diff == --- commons/sandbox/compress/trunk/src/main/java/org/apache/commons/compress/archivers/zip/ZipFile.java (original) +++ commons/sandbox/compress/trunk/src/main/java/org/apache/commons/compress/archivers/zip/ZipFile.java Thu Feb 26 13:15:14 2009 @@ -22,12 +22,14 @@ import java.io.InputStream; import java.io.RandomAccessFile; import java.io.UnsupportedEncodingException; +import java.nio.charset.CharacterCodingException; import java.util.Calendar; import java.util.Collections; import java.util.Date; import java.util.Enumeration; import java.util.HashMap; import java.util.Map; +import java.util.zip.CRC32; import java.util.zip.Inflater; import java.util.zip.InflaterInputStream; import java.util.zip.ZipException; @@ -101,6 +103,11 @@ private RandomAccessFile archive; /** + * Whether to look for and use Unicode extra fields. + */ +private final boolean useUnicodeExtraFields; + +/** * Opens the given file for reading, assuming UTF8 for file names. * * @param f the archive. @@ -124,7 +131,7 @@ /** * Opens the given file for reading, assuming the specified - * encoding for file names. + * encoding for file names and ignoring unicode extra fields. * * @param name name of the archive. * @param encoding the encoding to use for file names, use null @@ -133,12 +140,12 @@ * @throws IOException if an error occurs while reading the file. */ public ZipFile(String name, String encoding) throws IOException { -this(new File(name), encoding); +this(new File(name), encoding, false); } /** * Opens the given file for reading, assuming the specified - * encoding for file names. + * encoding for file names and ignoring unicode extra fields. * * @param f the archive. * @param encoding the encoding to use for file names, use null @@ -147,12 +154,30 @@ * @throws IOException if an error occurs while reading the file. */ public ZipFile(File f, String encoding) throws IOException { +this(f, encoding, false); +} + +/** + * Opens the given file for reading, assuming the specified + * encoding for file names. + * + * @param f the archive. + * @param encoding the encoding to use for file names, use null + * for the platform's default encoding + * @param whether to use InfoZIP Unicode Extra Fields (if present) + * to set the file names. + * + * @throws IOException if an error occurs while reading the file. + */ +public ZipFile(File f, String encoding, boolean useUnicodeExtraFields) +throws IOException { this.encoding = encoding
svn commit: r748556 - in /commons/sandbox/compress/trunk/src: main/java/org/apache/commons/compress/archivers/zip/ZipFile.java test/java/org/apache/commons/compress/archivers/zip/UTF8ZipFilesTest.java
Author: bodewig Date: Fri Feb 27 15:29:25 2009 New Revision: 748556 URL: http://svn.apache.org/viewvc?rev=748556view=rev Log: look for Unicode extra fields by default Modified: commons/sandbox/compress/trunk/src/main/java/org/apache/commons/compress/archivers/zip/ZipFile.java commons/sandbox/compress/trunk/src/test/java/org/apache/commons/compress/archivers/zip/UTF8ZipFilesTest.java Modified: commons/sandbox/compress/trunk/src/main/java/org/apache/commons/compress/archivers/zip/ZipFile.java URL: http://svn.apache.org/viewvc/commons/sandbox/compress/trunk/src/main/java/org/apache/commons/compress/archivers/zip/ZipFile.java?rev=748556r1=748555r2=748556view=diff == --- commons/sandbox/compress/trunk/src/main/java/org/apache/commons/compress/archivers/zip/ZipFile.java (original) +++ commons/sandbox/compress/trunk/src/main/java/org/apache/commons/compress/archivers/zip/ZipFile.java Fri Feb 27 15:29:25 2009 @@ -132,7 +132,7 @@ /** * Opens the given file for reading, assuming the specified - * encoding for file names and ignoring unicode extra fields. + * encoding for file names, scanning unicode extra fields. * * @param name name of the archive. * @param encoding the encoding to use for file names, use null @@ -141,12 +141,12 @@ * @throws IOException if an error occurs while reading the file. */ public ZipFile(String name, String encoding) throws IOException { -this(new File(name), encoding, false); +this(new File(name), encoding, true); } /** * Opens the given file for reading, assuming the specified - * encoding for file names and ignoring unicode extra fields. + * encoding for file names and scanning for unicode extra fields. * * @param f the archive. * @param encoding the encoding to use for file names, use null @@ -155,7 +155,7 @@ * @throws IOException if an error occurs while reading the file. */ public ZipFile(File f, String encoding) throws IOException { -this(f, encoding, false); +this(f, encoding, true); } /** Modified: commons/sandbox/compress/trunk/src/test/java/org/apache/commons/compress/archivers/zip/UTF8ZipFilesTest.java URL: http://svn.apache.org/viewvc/commons/sandbox/compress/trunk/src/test/java/org/apache/commons/compress/archivers/zip/UTF8ZipFilesTest.java?rev=748556r1=748555r2=748556view=diff == --- commons/sandbox/compress/trunk/src/test/java/org/apache/commons/compress/archivers/zip/UTF8ZipFilesTest.java (original) +++ commons/sandbox/compress/trunk/src/test/java/org/apache/commons/compress/archivers/zip/UTF8ZipFilesTest.java Fri Feb 27 15:29:25 2009 @@ -89,7 +89,7 @@ File archive = new File(new URI(zip.toString())); ZipFile zf = null; try { -zf = new ZipFile(archive, CP437); +zf = new ZipFile(archive, CP437, false); assertNotNull(zf.getEntry(ASCII_TXT)); assertNotNull(zf.getEntry(EURO_FOR_DOLLAR_TXT)); assertNotNull(zf.getEntry(OIL_BARREL_TXT)); @@ -199,7 +199,7 @@ throws IOException { ZipFile zf = null; try { -zf = new ZipFile(file, encoding); +zf = new ZipFile(file, encoding, false); Enumeration e = zf.getEntries(); while (e.hasMoreElements()) {
svn commit: r749344 - in /commons/sandbox/compress/trunk/src/main/java/org/apache/commons/compress/archivers/zip: Simple8BitZipEncoding.java Simple8BitZipEnoding.java ZipEncodingHelper.java
Author: bodewig Date: Mon Mar 2 16:21:30 2009 New Revision: 749344 URL: http://svn.apache.org/viewvc?rev=749344view=rev Log: typo in class name Added: commons/sandbox/compress/trunk/src/main/java/org/apache/commons/compress/archivers/zip/Simple8BitZipEncoding.java (contents, props changed) - copied, changed from r749342, commons/sandbox/compress/trunk/src/main/java/org/apache/commons/compress/archivers/zip/Simple8BitZipEnoding.java Removed: commons/sandbox/compress/trunk/src/main/java/org/apache/commons/compress/archivers/zip/Simple8BitZipEnoding.java Modified: commons/sandbox/compress/trunk/src/main/java/org/apache/commons/compress/archivers/zip/ZipEncodingHelper.java Copied: commons/sandbox/compress/trunk/src/main/java/org/apache/commons/compress/archivers/zip/Simple8BitZipEncoding.java (from r749342, commons/sandbox/compress/trunk/src/main/java/org/apache/commons/compress/archivers/zip/Simple8BitZipEnoding.java) URL: http://svn.apache.org/viewvc/commons/sandbox/compress/trunk/src/main/java/org/apache/commons/compress/archivers/zip/Simple8BitZipEncoding.java?p2=commons/sandbox/compress/trunk/src/main/java/org/apache/commons/compress/archivers/zip/Simple8BitZipEncoding.javap1=commons/sandbox/compress/trunk/src/main/java/org/apache/commons/compress/archivers/zip/Simple8BitZipEnoding.javar1=749342r2=749344rev=749344view=diff == --- commons/sandbox/compress/trunk/src/main/java/org/apache/commons/compress/archivers/zip/Simple8BitZipEnoding.java (original) +++ commons/sandbox/compress/trunk/src/main/java/org/apache/commons/compress/archivers/zip/Simple8BitZipEncoding.java Mon Mar 2 16:21:30 2009 @@ -44,7 +44,7 @@ * * pThe methods of this class are reentrant./p */ -class Simple8BitZipEnoding implements ZipEncoding { +class Simple8BitZipEncoding implements ZipEncoding { /** * A character entity, which is put to the reverse mapping table @@ -88,7 +88,7 @@ * @param highChars The characters for byte values of 128 to 255 * stored as an array of 128 chars. */ -public Simple8BitZipEnoding(char[] highChars) { +public Simple8BitZipEncoding(char[] highChars) { this.highChars = highChars; this.reverseMapping = new ArrayList(this.highChars.length); Propchange: commons/sandbox/compress/trunk/src/main/java/org/apache/commons/compress/archivers/zip/Simple8BitZipEncoding.java -- svn:eol-style = native Propchange: commons/sandbox/compress/trunk/src/main/java/org/apache/commons/compress/archivers/zip/Simple8BitZipEncoding.java -- svn:mergeinfo = Modified: commons/sandbox/compress/trunk/src/main/java/org/apache/commons/compress/archivers/zip/ZipEncodingHelper.java URL: http://svn.apache.org/viewvc/commons/sandbox/compress/trunk/src/main/java/org/apache/commons/compress/archivers/zip/ZipEncodingHelper.java?rev=749344r1=749343r2=749344view=diff == --- commons/sandbox/compress/trunk/src/main/java/org/apache/commons/compress/archivers/zip/ZipEncodingHelper.java (original) +++ commons/sandbox/compress/trunk/src/main/java/org/apache/commons/compress/archivers/zip/ZipEncodingHelper.java Mon Mar 2 16:21:30 2009 @@ -31,20 +31,20 @@ /** * A class, which holds the high characters of a simple encoding - * and lazily instantiates a Simple8BitZipEnoding instance in a + * and lazily instantiates a Simple8BitZipEncoding instance in a * thread-safe manner. */ private static class SimpleEncodingHolder { private final char [] highChars; -private Simple8BitZipEnoding encoding; +private Simple8BitZipEncoding encoding; /** * Instantiate a simple encoding holder. * * @param highChars The characters for byte codes 128 to 255. * - * @see Simple8BitZipEnoding#Simple8BitZipEnoding(char[]) + * @see Simple8BitZipEncoding#Simple8BitZipEncoding(char[]) */ SimpleEncodingHolder(char [] highChars) { this.highChars = highChars; @@ -54,9 +54,9 @@ * @return The associated {...@see Simple8BitZipEncoding}, which * is instantiated if not done so far. */ -public synchronized Simple8BitZipEnoding getEncoding() { +public synchronized Simple8BitZipEncoding getEncoding() { if (this.encoding == null) { -this.encoding = new Simple8BitZipEnoding(this.highChars); +this.encoding = new Simple8BitZipEncoding(this.highChars); } return this.encoding; }
svn commit: r749555 - /commons/sandbox/compress/trunk/src/main/java/org/apache/commons/compress/archivers/zip/UnrecognizedExtraField.java
Author: bodewig Date: Tue Mar 3 07:51:43 2009 New Revision: 749555 URL: http://svn.apache.org/viewvc?rev=749555view=rev Log: coding style Modified: commons/sandbox/compress/trunk/src/main/java/org/apache/commons/compress/archivers/zip/UnrecognizedExtraField.java Modified: commons/sandbox/compress/trunk/src/main/java/org/apache/commons/compress/archivers/zip/UnrecognizedExtraField.java URL: http://svn.apache.org/viewvc/commons/sandbox/compress/trunk/src/main/java/org/apache/commons/compress/archivers/zip/UnrecognizedExtraField.java?rev=749555r1=749554r2=749555view=diff == --- commons/sandbox/compress/trunk/src/main/java/org/apache/commons/compress/archivers/zip/UnrecognizedExtraField.java (original) +++ commons/sandbox/compress/trunk/src/main/java/org/apache/commons/compress/archivers/zip/UnrecognizedExtraField.java Tue Mar 3 07:51:43 2009 @@ -19,133 +19,114 @@ package org.apache.commons.compress.archivers.zip; /** - * Simple placeholder for all those extra fields we don't want to deal with. p + * Simple placeholder for all those extra fields we don't want to deal + * with. + * + * pAssumes local file data and central directory entries are + * identical - unless told the opposite./p * - * Assumes local file data and central directory entries are identical - unless - * told the opposite./p */ -public class UnrecognizedExtraField -implements ZipExtraField -{ -/** - * Extra field data in central directory - without Header-ID or length - * specifier. - */ -private byte[] m_centralData; +public class UnrecognizedExtraField implements ZipExtraField { /** * The Header-ID. */ -private ZipShort m_headerID; +private ZipShort headerId; /** - * Extra field data in local file data - without Header-ID or length - * specifier. + * Set the header id. + * @param headerId the header id to use */ -private byte[] m_localData; +public void setHeaderId(ZipShort headerId) { +this.headerId = headerId; +} /** - * Set the central directory data - * - * @param centralData the central directory data + * Get the header id. + * @return the header id */ -public void setCentralDirectoryData( final byte[] centralData ) -{ -m_centralData = copy(centralData); +public ZipShort getHeaderId() { +return headerId; } - /** - * Set the header ID. - * - * @param headerID the header ID +/** + * Extra field data in local file data - without + * Header-ID or length specifier. */ -public void setHeaderId( final ZipShort headerID ) -{ -m_headerID = headerID; -} +private byte[] localData; /** - * Set the local file data. - * - * @param localData the local file data + * Set the extra field data in the local file data - + * without Header-ID or length specifier. + * @param data the field data to use */ -public void setLocalFileDataData( final byte[] localData ) -{ -m_localData = copy(localData); +public void setLocalFileDataData(byte[] data) { +localData = copy(data); } /** - * Get the central directory data. - * - * @return the central directory data. + * Get the length of the local data. + * @return the length of the local data */ -public byte[] getCentralDirectoryData() -{ -if( m_centralData != null ) -{ -return copy(m_centralData); -} -return getLocalFileDataData(); +public ZipShort getLocalFileDataLength() { +return new ZipShort(localData.length); } /** - * Get the length of the central directory in bytes. - * - * @return the length of the central directory in bytes. - */ -public ZipShort getCentralDirectoryLength() -{ -if( m_centralData != null ) -{ -return new ZipShort( m_centralData.length ); -} -return getLocalFileDataLength(); + * Get the local data. + * @return the local data + */ +public byte[] getLocalFileDataData() { +return copy(localData); } /** - * Get the HeaderID. - * - * @return the HeaderID + * Extra field data in central directory - without + * Header-ID or length specifier. */ -public ZipShort getHeaderId() -{ -return m_headerID; -} +private byte[] centralData; /** - * Get the local file data. - * - * @return the local file data + * Set the extra field data in central directory. + * @param data the data to use */ -public byte[] getLocalFileDataData() -{ -return copy(m_localData); +public void setCentralDirectoryData(byte[] data) { +centralData = copy(data); } /** - * Get the length of local file data in bytes
svn commit: r749906 - in /commons/sandbox/compress/trunk/src: main/java/org/apache/commons/compress/archivers/zip/ZipArchiveOutputStream.java test/java/org/apache/commons/compress/archivers/zip/UTF8Zi
Author: bodewig Date: Wed Mar 4 05:07:25 2009 New Revision: 749906 URL: http://svn.apache.org/viewvc?rev=749906view=rev Log: Turn Unicode extra field handling into an enum since there are more than two options. SANDBOX-176 Modified: commons/sandbox/compress/trunk/src/main/java/org/apache/commons/compress/archivers/zip/ZipArchiveOutputStream.java commons/sandbox/compress/trunk/src/test/java/org/apache/commons/compress/archivers/zip/UTF8ZipFilesTest.java Modified: commons/sandbox/compress/trunk/src/main/java/org/apache/commons/compress/archivers/zip/ZipArchiveOutputStream.java URL: http://svn.apache.org/viewvc/commons/sandbox/compress/trunk/src/main/java/org/apache/commons/compress/archivers/zip/ZipArchiveOutputStream.java?rev=749906r1=749905r2=749906view=diff == --- commons/sandbox/compress/trunk/src/main/java/org/apache/commons/compress/archivers/zip/ZipArchiveOutputStream.java (original) +++ commons/sandbox/compress/trunk/src/main/java/org/apache/commons/compress/archivers/zip/ZipArchiveOutputStream.java Wed Mar 4 05:07:25 2009 @@ -231,7 +231,8 @@ /** * whether to create UnicodePathExtraField-s for each entry. */ -private boolean createUnicodeExtraFields = false; +private UnicodeExtraFieldPolicy createUnicodeExtraFields = +UnicodeExtraFieldPolicy.NEVER; /** * Creates a new ZIP OutputStream filtering the underlying stream. @@ -314,11 +315,11 @@ } /** - * Whether to create Unicode Extra Fields for all entries. + * Whether to create Unicode Extra Fields. * - * pDefaults to false./p + * pDefaults to NEVER./p */ -public void setCreateUnicodeExtraFields(boolean b) { +public void setCreateUnicodeExtraFields(UnicodeExtraFieldPolicy b) { createUnicodeExtraFields = b; } @@ -615,28 +616,30 @@ boolean encodable = this.zipEncoding.canEncode(ze.getName()); ByteBuffer name = this.zipEncoding.encode(ze.getName()); -if (createUnicodeExtraFields) { +if (createUnicodeExtraFields != UnicodeExtraFieldPolicy.NEVER) { -/*if (!encodable) { -- FIXME decide what to*/ +if (createUnicodeExtraFields == UnicodeExtraFieldPolicy.ALWAYS +|| !encodable) { ze.addExtraField(new UnicodePathExtraField(ze.getName(), name.array(), name.arrayOffset(), name.limit())); -/* } */ +} String comm = ze.getComment(); if (comm != null !.equals(comm)) { boolean commentEncodable = this.zipEncoding.canEncode(comm); -/*if (!commentEncodable) { -- FIXME decide what to*/ +if (createUnicodeExtraFields == UnicodeExtraFieldPolicy.ALWAYS +|| !commentEncodable) { ByteBuffer commentB = this.zipEncoding.encode(comm); ze.addExtraField(new UnicodeCommentExtraField(comm, commentB.array(), commentB.arrayOffset(), commentB.limit()) ); -/* } */ +} } } @@ -930,4 +933,35 @@ // general purpose bit flag writeOut(ZipShort.getBytes(generalPurposeFlag)); } + +/** + * enum that represents the possible policies for creating Unicode + * extra fields. + */ +public static final class UnicodeExtraFieldPolicy { +/** + * Always create Unicode extra fields. + */ +public static final UnicodeExtraFieldPolicy ALWAYS = +new UnicodeExtraFieldPolicy(always); +/** + * Never create Unicode extra fields. + */ +public static final UnicodeExtraFieldPolicy NEVER = +new UnicodeExtraFieldPolicy(never); +/** + * Create Unicode extra fields for filenames that cannot be + * encoded using the specified encoding. + */ +public static final UnicodeExtraFieldPolicy NOT_ENCODABLE = +new UnicodeExtraFieldPolicy(not encodable); + +private final String name; +private UnicodeExtraFieldPolicy(String n) { +name = n; +} +public String toString() { +return name; +} +} } Modified: commons/sandbox/compress/trunk/src/test/java/org/apache/commons/compress/archivers/zip/UTF8ZipFilesTest.java URL: http://svn.apache.org/viewvc/commons/sandbox/compress/trunk/src/test/java/org/apache/commons/compress/archivers/zip
svn commit: r749907 - /commons/sandbox/compress/trunk/src/main/java/org/apache/commons/compress/archivers/zip/ZipArchiveOutputStream.java
Author: bodewig Date: Wed Mar 4 05:21:19 2009 New Revision: 749907 URL: http://svn.apache.org/viewvc?rev=749907view=rev Log: Add option to use UTF-8 for non-encodable file names. SANDBOX-176 Modified: commons/sandbox/compress/trunk/src/main/java/org/apache/commons/compress/archivers/zip/ZipArchiveOutputStream.java Modified: commons/sandbox/compress/trunk/src/main/java/org/apache/commons/compress/archivers/zip/ZipArchiveOutputStream.java URL: http://svn.apache.org/viewvc/commons/sandbox/compress/trunk/src/main/java/org/apache/commons/compress/archivers/zip/ZipArchiveOutputStream.java?rev=749907r1=749906r2=749907view=diff == --- commons/sandbox/compress/trunk/src/main/java/org/apache/commons/compress/archivers/zip/ZipArchiveOutputStream.java (original) +++ commons/sandbox/compress/trunk/src/main/java/org/apache/commons/compress/archivers/zip/ZipArchiveOutputStream.java Wed Mar 4 05:21:19 2009 @@ -229,6 +229,11 @@ private boolean useEFS = true; /** + * Whether to encode non-encodable file names as UTF-8. + */ +private boolean fallbackToUTF8 = false; + +/** * whether to create UnicodePathExtraField-s for each entry. */ private UnicodeExtraFieldPolicy createUnicodeExtraFields = @@ -324,6 +329,16 @@ } /** + * Whether to fall back to UTF and the language encoding flag if + * the file name cannot be encoded using the specified encoding. + * + * pDefaults to false./p + */ +public void setFallbackToUTF8(boolean b) { +fallbackToUTF8 = b; +} + +/** * Finishs writing the contents and closes this as well as the * underlying stream. * @throws IOException on error @@ -613,8 +628,13 @@ */ protected void writeLocalFileHeader(ZipArchiveEntry ze) throws IOException { -boolean encodable = this.zipEncoding.canEncode(ze.getName()); -ByteBuffer name = this.zipEncoding.encode(ze.getName()); +boolean encodable = zipEncoding.canEncode(ze.getName()); +ByteBuffer name; +if (!encodable fallbackToUTF8) { +name = ZipEncodingHelper.UTF8_ZIP_ENCODING.encode(ze.getName()); +} else { +name = zipEncoding.encode(ze.getName()); +} if (createUnicodeExtraFields != UnicodeExtraFieldPolicy.NEVER) { @@ -651,7 +671,9 @@ //store method in local variable to prevent multiple method calls final int zipMethod = ze.getMethod(); -writeVersionNeededToExtractAndGeneralPurposeBits(zipMethod); +writeVersionNeededToExtractAndGeneralPurposeBits(zipMethod, + !encodable + fallbackToUTF8); written += WORD; // compression method @@ -732,7 +754,10 @@ written += SHORT; final int zipMethod = ze.getMethod(); -writeVersionNeededToExtractAndGeneralPurposeBits(zipMethod); +final boolean encodable = zipEncoding.canEncode(ze.getName()); +writeVersionNeededToExtractAndGeneralPurposeBits(zipMethod, + !encodable + fallbackToUTF8); written += WORD; // compression method @@ -754,7 +779,12 @@ // CheckStyle:MagicNumber ON // file name length -ByteBuffer name = this.zipEncoding.encode(ze.getName()); +ByteBuffer name; +if (!encodable fallbackToUTF8) { +name = ZipEncodingHelper.UTF8_ZIP_ENCODING.encode(ze.getName()); +} else { +name = zipEncoding.encode(ze.getName()); +} writeOut(ZipShort.getBytes(name.limit())); written += SHORT; @@ -768,7 +798,12 @@ if (comm == null) { comm = ; } -ByteBuffer commentB = this.zipEncoding.encode(comm); +ByteBuffer commentB; +if (!encodable fallbackToUTF8) { +commentB = ZipEncodingHelper.UTF8_ZIP_ENCODING.encode(comm); +} else { +commentB = zipEncoding.encode(comm); +} writeOut(ZipShort.getBytes(commentB.limit())); written += SHORT; @@ -913,12 +948,14 @@ } private void writeVersionNeededToExtractAndGeneralPurposeBits(final int - zipMethod) + zipMethod, + final boolean + utfFallback) throws IOException { // CheckStyle:MagicNumber OFF int versionNeededToExtract = 10; -int generalPurposeFlag = useEFS ? EFS_FLAG : 0; +int generalPurposeFlag = (useEFS || utfFallback) ? EFS_FLAG
svn commit: r750313 - /commons/sandbox/compress/trunk/src/test/java/org/apache/commons/compress/AbstractTestCase.java
Author: bodewig Date: Thu Mar 5 04:49:10 2009 New Revision: 750313 URL: http://svn.apache.org/viewvc?rev=750313view=rev Log: make tests pass on Linux Modified: commons/sandbox/compress/trunk/src/test/java/org/apache/commons/compress/AbstractTestCase.java Modified: commons/sandbox/compress/trunk/src/test/java/org/apache/commons/compress/AbstractTestCase.java URL: http://svn.apache.org/viewvc/commons/sandbox/compress/trunk/src/test/java/org/apache/commons/compress/AbstractTestCase.java?rev=750313r1=750312r2=750313view=diff == --- commons/sandbox/compress/trunk/src/test/java/org/apache/commons/compress/AbstractTestCase.java (original) +++ commons/sandbox/compress/trunk/src/test/java/org/apache/commons/compress/AbstractTestCase.java Thu Mar 5 04:49:10 2009 @@ -23,8 +23,10 @@ import java.io.FileInputStream; import java.io.FileOutputStream; import java.io.InputStream; +import java.io.IOException; import java.io.OutputStream; import java.lang.reflect.Method; +import java.net.URI; import java.net.URL; import java.net.URLClassLoader; import java.util.Iterator; @@ -51,8 +53,17 @@ addURL(new File(src/test/resources).toURL()); } -protected File getFile(String path) { -return new File(getClass().getClassLoader().getResource(path).getFile()); +protected File getFile(String path) throws IOException { +URL url = getClass().getResource(path); +if (url == null) { +throw new java.io.FileNotFoundException(path + doesn't exist); +} +try { +return new File(new URI(url.toString())); +} catch (java.net.URISyntaxException ex) { +// impossible since URL.toString() should always yield a valid URI +throw new IOException(ex.getMessage(), ex); +} } protected void tearDown() throws Exception { @@ -71,11 +82,11 @@ */ public void addURL(URL url) throws Exception { URLClassLoader classLoader = (URLClassLoader) ClassLoader -.getSystemClassLoader(); +.getSystemClassLoader(); Class clazz = URLClassLoader.class; Method method = clazz.getDeclaredMethod(addURL, -new Class[] { URL.class }); +new Class[] { URL.class }); method.setAccessible(true); method.invoke(classLoader, new Object[] { url }); } @@ -109,7 +120,7 @@ final OutputStream stream = new FileOutputStream(temp); out = new ArchiveStreamFactory().createArchiveOutputStream( -archivename, stream); + archivename, stream); final File file1 = getFile(test1.xml); final File file2 = getFile(test2.xml); @@ -189,16 +200,16 @@ * @throws Exception */ protected void checkArchiveContent(File archive, List expected) -throws Exception { +throws Exception { final InputStream is = new FileInputStream(archive); final BufferedInputStream buf = new BufferedInputStream(is); final ArchiveInputStream in = new ArchiveStreamFactory() -.createArchiveInputStream(buf); +.createArchiveInputStream(buf); this.checkArchiveContent(in, expected); } protected void checkArchiveContent(ArchiveInputStream in, List expected) -throws Exception { +throws Exception { File result = File.createTempFile(dir-result, ); result.delete(); result.mkdir(); @@ -206,7 +217,7 @@ ArchiveEntry entry = null; while ((entry = in.getNextEntry()) != null) { File outfile = new File(result.getCanonicalPath() + /result/ -+ entry.getName()); ++ entry.getName()); outfile.getParentFile().mkdirs(); OutputStream out = new FileOutputStream(outfile); IOUtils.copy(in, out);
svn commit: r750914 - /commons/sandbox/compress/trunk/src/test/java/org/apache/commons/compress/AbstractTestCase.java
Author: bodewig Date: Fri Mar 6 14:23:00 2009 New Revision: 750914 URL: http://svn.apache.org/viewvc?rev=750914view=rev Log: simplify location of test files Modified: commons/sandbox/compress/trunk/src/test/java/org/apache/commons/compress/AbstractTestCase.java Modified: commons/sandbox/compress/trunk/src/test/java/org/apache/commons/compress/AbstractTestCase.java URL: http://svn.apache.org/viewvc/commons/sandbox/compress/trunk/src/test/java/org/apache/commons/compress/AbstractTestCase.java?rev=750914r1=750913r2=750914view=diff == --- commons/sandbox/compress/trunk/src/test/java/org/apache/commons/compress/AbstractTestCase.java (original) +++ commons/sandbox/compress/trunk/src/test/java/org/apache/commons/compress/AbstractTestCase.java Fri Mar 6 14:23:00 2009 @@ -49,21 +49,10 @@ dir = File.createTempFile(dir, ); dir.delete(); dir.mkdir(); - -addURL(new File(src/test/resources).toURL()); } -protected File getFile(String path) throws IOException { -URL url = getClass().getResource(path); -if (url == null) { -throw new java.io.FileNotFoundException(path + doesn't exist); -} -try { -return new File(new URI(url.toString())); -} catch (java.net.URISyntaxException ex) { -// impossible since URL.toString() should always yield a valid URI -throw new IOException(ex.getMessage()); -} +protected File getFile(String path) { +return new File(src/test/resources, path); } protected void tearDown() throws Exception { @@ -72,26 +61,6 @@ } /** - * Adds a URL to the classpath. This method is necessary when running junit - * tests from within eclipse. - * - * @param url - *the url to add - * @throws Exception - * if an error occurs - */ -public void addURL(URL url) throws Exception { -URLClassLoader classLoader = (URLClassLoader) ClassLoader -.getSystemClassLoader(); -Class clazz = URLClassLoader.class; - -Method method = clazz.getDeclaredMethod(addURL, -new Class[] { URL.class }); -method.setAccessible(true); -method.invoke(classLoader, new Object[] { url }); -} - -/** * Creates an archive of 5 textbased files in several directories. The * archivername is the factory identifier for the archiver, for example zip, * tar, cpio, jar, ar. The archive is created as a temp file.
svn commit: r751739 - /commons/sandbox/compress/trunk/NOTICE.txt
Author: bodewig Date: Mon Mar 9 16:45:54 2009 New Revision: 751739 URL: http://svn.apache.org/viewvc?rev=751739view=rev Log: bump copyright Modified: commons/sandbox/compress/trunk/NOTICE.txt Modified: commons/sandbox/compress/trunk/NOTICE.txt URL: http://svn.apache.org/viewvc/commons/sandbox/compress/trunk/NOTICE.txt?rev=751739r1=751738r2=751739view=diff == --- commons/sandbox/compress/trunk/NOTICE.txt (original) +++ commons/sandbox/compress/trunk/NOTICE.txt Mon Mar 9 16:45:54 2009 @@ -1,5 +1,5 @@ Apache Commons Compress -Copyright 2002-2004 The Apache Software Foundation +Copyright 2002-2009 The Apache Software Foundation This product includes software developed by The Apache Software Foundation (http://www.apache.org/). @@ -7,4 +7,4 @@ Original BZip2 classes contributed by Keiron Liddle kei...@aftexsw.com, Aftex Software to the Apache Ant project Original Tar classes from contributors of the Apache Ant project Original Zip classes from contributors of the Apache Ant project -Original CPIO classes contributed by Markus Kuss and the jRPM project (jrpm.sourceforge.net) \ No newline at end of file +Original CPIO classes contributed by Markus Kuss and the jRPM project (jrpm.sourceforge.net)
svn commit: r752029 - /commons/sandbox/compress/trunk/NOTICE.txt
Author: bodewig Date: Tue Mar 10 09:34:08 2009 New Revision: 752029 URL: http://svn.apache.org/viewvc?rev=752029view=rev Log: standard NOTICE header, a bit of whitespace Modified: commons/sandbox/compress/trunk/NOTICE.txt Modified: commons/sandbox/compress/trunk/NOTICE.txt URL: http://svn.apache.org/viewvc/commons/sandbox/compress/trunk/NOTICE.txt?rev=752029r1=752028r2=752029view=diff == --- commons/sandbox/compress/trunk/NOTICE.txt (original) +++ commons/sandbox/compress/trunk/NOTICE.txt Tue Mar 10 09:34:08 2009 @@ -1,10 +1,21 @@ + = + == NOTICE file corresponding to the section 4 d of== + == the Apache License, Version 2.0, == + == in this case for the Apache Commons Compress distribution. == + = + Apache Commons Compress Copyright 2002-2009 The Apache Software Foundation This product includes software developed by The Apache Software Foundation (http://www.apache.org/). -Original BZip2 classes contributed by Keiron Liddle kei...@aftexsw.com, Aftex Software to the Apache Ant project +Original BZip2 classes contributed by Keiron Liddle +kei...@aftexsw.com, Aftex Software to the Apache Ant project + Original Tar classes from contributors of the Apache Ant project + Original Zip classes from contributors of the Apache Ant project -Original CPIO classes contributed by Markus Kuss and the jRPM project (jrpm.sourceforge.net) + +Original CPIO classes contributed by Markus Kuss and the jRPM project +(jrpm.sourceforge.net)
svn commit: r752113 - /commons/sandbox/compress/trunk/NOTICE.txt
Author: bodewig Date: Tue Mar 10 13:58:17 2009 New Revision: 752113 URL: http://svn.apache.org/viewvc?rev=752113view=rev Log: remove unneeded boilerplate text Modified: commons/sandbox/compress/trunk/NOTICE.txt Modified: commons/sandbox/compress/trunk/NOTICE.txt URL: http://svn.apache.org/viewvc/commons/sandbox/compress/trunk/NOTICE.txt?rev=752113r1=752112r2=752113view=diff == --- commons/sandbox/compress/trunk/NOTICE.txt (original) +++ commons/sandbox/compress/trunk/NOTICE.txt Tue Mar 10 13:58:17 2009 @@ -1,9 +1,3 @@ - = - == NOTICE file corresponding to the section 4 d of== - == the Apache License, Version 2.0, == - == in this case for the Apache Commons Compress distribution. == - = - Apache Commons Compress Copyright 2002-2009 The Apache Software Foundation
svn commit: r753102 - /commons/sandbox/compress/trunk/PROPOSAL.txt
Author: bodewig Date: Fri Mar 13 03:52:54 2009 New Revision: 753102 URL: http://svn.apache.org/viewvc?rev=753102view=rev Log: proposal text Added: commons/sandbox/compress/trunk/PROPOSAL.txt (with props) Added: commons/sandbox/compress/trunk/PROPOSAL.txt URL: http://svn.apache.org/viewvc/commons/sandbox/compress/trunk/PROPOSAL.txt?rev=753102view=auto == --- commons/sandbox/compress/trunk/PROPOSAL.txt (added) +++ commons/sandbox/compress/trunk/PROPOSAL.txt Fri Mar 13 03:52:54 2009 @@ -0,0 +1,54 @@ +Proposal for Compress Package + +(0) rationale + +Ant contains packages to deal with tar, bzip2 and zip archives that +have been reused in various projects in- and outside of Apache. + +Compress provides a focused home for these packages together with +new external contributions for the ar and cpio formats with a focus on +being a reusable library - unlike the code in Ant. + +(1) scope of the package + +The package provides a unified API for different archiving and +compression formats together with implementations for these +algorithms. + +(1.5) interaction with other packages + +No interactions planned ATM. + +(2) identify the initial source for the package + +Compress' code is already part of the sandbox. + +(2.1) identify the base name for the package + +org.apache.commons.compress + +(2.2) identify the coding conventions for this package + +The code uses the conventions from the Jakarta Turbine package. + +(3) identify any Commons resources to be created + +(3.1) mailing list + +No changes. + +(3.2) SVN repositories + +The package will need to move from the sandbox. + +(3.3) JIRA + +A new Commons Compress JIRA project shall be created and the issues of +the Compress Component of the Commons Sandbox project migrated to the +new project. + +(4) identify the initial set of committers to be listed in the Status File. + +Henri Yandell +Stefan Bodewig +Torsten Curdt Propchange: commons/sandbox/compress/trunk/PROPOSAL.txt -- svn:eol-style = native
svn commit: r753122 - in /commons/sandbox/compress/trunk/src/main/java/org/apache/commons/compress: archivers/ArchiveStreamFactory.java compressors/CompressorStreamFactory.java
Author: bodewig Date: Fri Mar 13 05:23:22 2009 New Revision: 753122 URL: http://svn.apache.org/viewvc?rev=753122view=rev Log: Improve and unify exception handling in StreamFactories. Submitted by Christian Grobmeier. SANDBOX-299 Modified: commons/sandbox/compress/trunk/src/main/java/org/apache/commons/compress/archivers/ArchiveStreamFactory.java commons/sandbox/compress/trunk/src/main/java/org/apache/commons/compress/compressors/CompressorStreamFactory.java Modified: commons/sandbox/compress/trunk/src/main/java/org/apache/commons/compress/archivers/ArchiveStreamFactory.java URL: http://svn.apache.org/viewvc/commons/sandbox/compress/trunk/src/main/java/org/apache/commons/compress/archivers/ArchiveStreamFactory.java?rev=753122r1=753121r2=753122view=diff == --- commons/sandbox/compress/trunk/src/main/java/org/apache/commons/compress/archivers/ArchiveStreamFactory.java (original) +++ commons/sandbox/compress/trunk/src/main/java/org/apache/commons/compress/archivers/ArchiveStreamFactory.java Fri Mar 13 05:23:22 2009 @@ -34,67 +34,94 @@ import org.apache.commons.compress.archivers.zip.ZipArchiveOutputStream; /** - * Factory to create Archive[In|Out]putStreams from names - * or the first bytes of the InputStream. In order add other - * implementations you should extend ArchiveStreamFactory - * and override the appropriate methods (and call their implementation - * from super of course) + * Factory to create Archive[In|Out]putStreams from names or the first bytes of + * the InputStream. In order add other implementations you should extend + * ArchiveStreamFactory and override the appropriate methods (and call their + * implementation from super of course) * - * TODO add example here + * TODO add example here * */ - public class ArchiveStreamFactory { -public ArchiveInputStream createArchiveInputStream( final String archiverName, final InputStream in ) throws ArchiveException { +public ArchiveInputStream createArchiveInputStream( +final String archiverName, final InputStream in) +throws ArchiveException { +if (archiverName == null || in == null) { +throw new IllegalArgumentException(Archivername must not be null.); +} + if (ar.equalsIgnoreCase(archiverName)) { return new ArArchiveInputStream(in); -} else if(zip.equalsIgnoreCase(archiverName)) { +} else if (zip.equalsIgnoreCase(archiverName)) { return new ZipArchiveInputStream(in); -} else if(tar.equalsIgnoreCase(archiverName)) { +} else if (tar.equalsIgnoreCase(archiverName)) { return new TarArchiveInputStream(in); -} else if(jar.equalsIgnoreCase(archiverName)) { +} else if (jar.equalsIgnoreCase(archiverName)) { return new JarArchiveInputStream(in); -} else if(cpio.equalsIgnoreCase(archiverName)) { +} else if (cpio.equalsIgnoreCase(archiverName)) { return new CpioArchiveInputStream(in); } -return null; +throw new ArchiveException(Archiver: + archiverName + not found.); } -public ArchiveOutputStream createArchiveOutputStream( final String archiverName, final OutputStream out ) throws ArchiveException { +public ArchiveOutputStream createArchiveOutputStream( +final String archiverName, final OutputStream out) +throws ArchiveException { +if (archiverName == null || out == null) { +throw new IllegalArgumentException( +Archivername and stream must not be null.); +} + if (ar.equalsIgnoreCase(archiverName)) { return new ArArchiveOutputStream(out); -} else if(zip.equalsIgnoreCase(archiverName)) { +} else if (zip.equalsIgnoreCase(archiverName)) { return new ZipArchiveOutputStream(out); -} else if(tar.equalsIgnoreCase(archiverName)) { +} else if (tar.equalsIgnoreCase(archiverName)) { return new TarArchiveOutputStream(out); -} else if(jar.equalsIgnoreCase(archiverName)) { +} else if (jar.equalsIgnoreCase(archiverName)) { return new JarArchiveOutputStream(out); -} else if(cpio.equalsIgnoreCase(archiverName)) { +} else if (cpio.equalsIgnoreCase(archiverName)) { return new CpioArchiveOutputStream(out); } -return null; +throw new ArchiveException(Archiver: + archiverName + not found.); } -public ArchiveInputStream createArchiveInputStream( final InputStream input ) throws IOException { +public ArchiveInputStream createArchiveInputStream(final InputStream in) +throws ArchiveException { +if (in == null) { +throw new IllegalArgumentException(Stream must not be null.); +} + +if (!in.markSupported()) { +throw new
svn commit: r753123 - /commons/sandbox/compress/trunk/src/test/java/org/apache/commons/compress/AbstractTestCase.java
Author: bodewig Date: Fri Mar 13 05:27:03 2009 New Revision: 753123 URL: http://svn.apache.org/viewvc?rev=753123view=rev Log: copy-paste error in test. Submitted by Christian Grobmeier. SANDBOX-297 Modified: commons/sandbox/compress/trunk/src/test/java/org/apache/commons/compress/AbstractTestCase.java Modified: commons/sandbox/compress/trunk/src/test/java/org/apache/commons/compress/AbstractTestCase.java URL: http://svn.apache.org/viewvc/commons/sandbox/compress/trunk/src/test/java/org/apache/commons/compress/AbstractTestCase.java?rev=753123r1=753122r2=753123view=diff == --- commons/sandbox/compress/trunk/src/test/java/org/apache/commons/compress/AbstractTestCase.java (original) +++ commons/sandbox/compress/trunk/src/test/java/org/apache/commons/compress/AbstractTestCase.java Fri Mar 13 05:27:03 2009 @@ -83,7 +83,8 @@ File temp = File.createTempFile(test, . + archivename); final OutputStream stream = new FileOutputStream(temp); -out = new ArchiveStreamFactory().createArchiveOutputStream(archivename, stream); +out = new ArchiveStreamFactory().createArchiveOutputStream( +archivename, stream); final File file1 = getFile(test1.xml); final File file2 = getFile(test2.xml); @@ -99,49 +100,49 @@ out.closeArchiveEntry(); entry = new ZipArchiveEntry(testdata/test2.xml); -entry.setSize(file1.length()); +entry.setSize(file2.length()); out.putArchiveEntry(entry); IOUtils.copy(new FileInputStream(file2), out); out.closeArchiveEntry(); entry = new ZipArchiveEntry(test/test3.xml); -entry.setSize(file1.length()); +entry.setSize(file3.length()); out.putArchiveEntry(entry); IOUtils.copy(new FileInputStream(file3), out); out.closeArchiveEntry(); entry = new ZipArchiveEntry(bla/test4.xml); -entry.setSize(file1.length()); +entry.setSize(file4.length()); out.putArchiveEntry(entry); IOUtils.copy(new FileInputStream(file4), out); out.closeArchiveEntry(); entry = new ZipArchiveEntry(bla/test5.xml); -entry.setSize(file1.length()); +entry.setSize(file4.length()); out.putArchiveEntry(entry); IOUtils.copy(new FileInputStream(file4), out); out.closeArchiveEntry(); entry = new ZipArchiveEntry(bla/blubber/test6.xml); -entry.setSize(file1.length()); +entry.setSize(file4.length()); out.putArchiveEntry(entry); IOUtils.copy(new FileInputStream(file4), out); out.closeArchiveEntry(); entry = new ZipArchiveEntry(test.txt); -entry.setSize(file1.length()); +entry.setSize(file5.length()); out.putArchiveEntry(entry); IOUtils.copy(new FileInputStream(file5), out); out.closeArchiveEntry(); entry = new ZipArchiveEntry(something/bla); -entry.setSize(file1.length()); +entry.setSize(file6.length()); out.putArchiveEntry(entry); IOUtils.copy(new FileInputStream(file6), out); out.closeArchiveEntry(); entry = new ZipArchiveEntry(test with spaces.txt); -entry.setSize(file1.length()); +entry.setSize(file6.length()); out.putArchiveEntry(entry); IOUtils.copy(new FileInputStream(file6), out); out.closeArchiveEntry(); @@ -163,16 +164,16 @@ * @throws Exception */ protected void checkArchiveContent(File archive, List expected) -throws Exception { +throws Exception { final InputStream is = new FileInputStream(archive); final BufferedInputStream buf = new BufferedInputStream(is); final ArchiveInputStream in = new ArchiveStreamFactory() -.createArchiveInputStream(buf); +.createArchiveInputStream(buf); this.checkArchiveContent(in, expected); } protected void checkArchiveContent(ArchiveInputStream in, List expected) -throws Exception { +throws Exception { File result = File.createTempFile(dir-result, ); result.delete(); result.mkdir(); @@ -180,7 +181,7 @@ ArchiveEntry entry = null; while ((entry = in.getNextEntry()) != null) { File outfile = new File(result.getCanonicalPath() + /result/ -+ entry.getName()); ++ entry.getName()); outfile.getParentFile().mkdirs(); OutputStream out = new FileOutputStream(outfile); IOUtils.copy(in, out);
svn commit: r755214 - /commons/sandbox/compress/trunk/src/main/java/org/apache/commons/compress/archivers/tar/TarArchiveEntry.java
Author: bodewig Date: Tue Mar 17 12:14:17 2009 New Revision: 755214 URL: http://svn.apache.org/viewvc?rev=755214view=rev Log: whitespace Modified: commons/sandbox/compress/trunk/src/main/java/org/apache/commons/compress/archivers/tar/TarArchiveEntry.java Modified: commons/sandbox/compress/trunk/src/main/java/org/apache/commons/compress/archivers/tar/TarArchiveEntry.java URL: http://svn.apache.org/viewvc/commons/sandbox/compress/trunk/src/main/java/org/apache/commons/compress/archivers/tar/TarArchiveEntry.java?rev=755214r1=755213r2=755214view=diff == --- commons/sandbox/compress/trunk/src/main/java/org/apache/commons/compress/archivers/tar/TarArchiveEntry.java (original) +++ commons/sandbox/compress/trunk/src/main/java/org/apache/commons/compress/archivers/tar/TarArchiveEntry.java Tue Mar 17 12:14:17 2009 @@ -213,8 +213,8 @@ char ch2 = fileName.charAt(1); if (ch2 == ':' - ((ch1 = 'a' ch1 = 'z') -|| (ch1 = 'A' ch1 = 'Z'))) { + ((ch1 = 'a' ch1 = 'z') +|| (ch1 = 'A' ch1 = 'Z'))) { fileName = fileName.substring(2); } } @@ -515,7 +515,7 @@ */ public boolean isGNULongNameEntry() { return linkFlag == LF_GNUTYPE_LONGNAME -name.toString().equals(GNU_LONGLINK); + name.toString().equals(GNU_LONGLINK); } /**
svn commit: r755227 - in /commons/sandbox/compress/trunk/src: main/java/org/apache/commons/compress/archivers/tar/ test/java/org/apache/commons/compress/archivers/tar/
Author: bodewig Date: Tue Mar 17 12:53:22 2009 New Revision: 755227 URL: http://svn.apache.org/viewvc?rev=755227view=rev Log: deal with file system roots added as tar entries. SANDBOX-284 Added: commons/sandbox/compress/trunk/src/test/java/org/apache/commons/compress/archivers/tar/ commons/sandbox/compress/trunk/src/test/java/org/apache/commons/compress/archivers/tar/TarArchiveEntryTest.java (with props) Modified: commons/sandbox/compress/trunk/src/main/java/org/apache/commons/compress/archivers/tar/TarArchiveEntry.java Modified: commons/sandbox/compress/trunk/src/main/java/org/apache/commons/compress/archivers/tar/TarArchiveEntry.java URL: http://svn.apache.org/viewvc/commons/sandbox/compress/trunk/src/main/java/org/apache/commons/compress/archivers/tar/TarArchiveEntry.java?rev=755227r1=755226r2=755227view=diff == --- commons/sandbox/compress/trunk/src/main/java/org/apache/commons/compress/archivers/tar/TarArchiveEntry.java (original) +++ commons/sandbox/compress/trunk/src/main/java/org/apache/commons/compress/archivers/tar/TarArchiveEntry.java Tue Mar 17 12:53:22 2009 @@ -158,6 +158,7 @@ public TarArchiveEntry(String name) { this(); +name = normalizeFileName(name); boolean isDir = name.endsWith(/); this.devMajor = 0; @@ -199,42 +200,7 @@ this.file = file; -String fileName = file.getPath(); -String osname = System.getProperty(os.name).toLowerCase(Locale.US); - -if (osname != null) { - -// Strip off drive letters! -// REVIEW Would a better check be (File.separator == '\')? - -if (osname.startsWith(windows)) { -if (fileName.length() 2) { -char ch1 = fileName.charAt(0); -char ch2 = fileName.charAt(1); - -if (ch2 == ':' - ((ch1 = 'a' ch1 = 'z') -|| (ch1 = 'A' ch1 = 'Z'))) { -fileName = fileName.substring(2); -} -} -} else if (osname.indexOf(netware) -1) { -int colon = fileName.indexOf(':'); -if (colon != -1) { -fileName = fileName.substring(colon + 1); -} -} -} - -fileName = fileName.replace(File.separatorChar, '/'); - -// No absolute pathnames -// Windows (and Posix?) paths can start with \\NetworkDrive\, -// so we loop on starting /'s. -while (fileName.startsWith(/)) { -fileName = fileName.substring(1); -} - +String fileName = normalizeFileName(file.getPath()); this.linkName = new StringBuffer(); this.name = new StringBuffer(fileName); @@ -242,7 +208,8 @@ this.mode = DEFAULT_DIR_MODE; this.linkFlag = LF_DIR; -if (this.name.charAt(this.name.length() - 1) != '/') { +int nameLength = name.length(); +if (nameLength == 0 || name.charAt(nameLength - 1) != '/') { this.name.append(/); } } else { @@ -328,7 +295,7 @@ * @param name This entry's new name. */ public void setName(String name) { -this.name = new StringBuffer(name); +this.name = new StringBuffer(normalizeFileName(name)); } /** @@ -632,5 +599,47 @@ offset += DEVLEN; devMinor = (int) TarUtils.parseOctal(header, offset, DEVLEN); } + +/** + * Strips Windows' drive letter as well as any leading slashes, + * turns path separators into forward slahes. + */ +private static String normalizeFileName(String fileName) { +String osname = System.getProperty(os.name).toLowerCase(Locale.US); + +if (osname != null) { + +// Strip off drive letters! +// REVIEW Would a better check be (File.separator == '\')? + +if (osname.startsWith(windows)) { +if (fileName.length() 2) { +char ch1 = fileName.charAt(0); +char ch2 = fileName.charAt(1); + +if (ch2 == ':' + ((ch1 = 'a' ch1 = 'z') +|| (ch1 = 'A' ch1 = 'Z'))) { +fileName = fileName.substring(2); +} +} +} else if (osname.indexOf(netware) -1) { +int colon = fileName.indexOf(':'); +if (colon != -1) { +fileName = fileName.substring(colon + 1); +} +} +} + +fileName = fileName.replace(File.separatorChar, '/'); + +// No absolute pathnames +// Windows (and Posix?) paths can start with \\NetworkDrive\, +// so we loop on starting /'s. +while (fileName.startsWith
svn commit: r755371 - /commons/sandbox/compress/trunk/src/test/java/org/apache/commons/compress/archivers/tar/TarArchiveEntryTest.java
Author: bodewig Date: Tue Mar 17 19:56:57 2009 New Revision: 755371 URL: http://svn.apache.org/viewvc?rev=755371view=rev Log: Make tests pass on Linux - this is only hiding a different issue that I'll open a JIRA ticket for tomorrow, directories have a size different from 0 when queried via File.length() on Unix-like systems Modified: commons/sandbox/compress/trunk/src/test/java/org/apache/commons/compress/archivers/tar/TarArchiveEntryTest.java Modified: commons/sandbox/compress/trunk/src/test/java/org/apache/commons/compress/archivers/tar/TarArchiveEntryTest.java URL: http://svn.apache.org/viewvc/commons/sandbox/compress/trunk/src/test/java/org/apache/commons/compress/archivers/tar/TarArchiveEntryTest.java?rev=755371r1=755370r2=755371view=diff == --- commons/sandbox/compress/trunk/src/test/java/org/apache/commons/compress/archivers/tar/TarArchiveEntryTest.java (original) +++ commons/sandbox/compress/trunk/src/test/java/org/apache/commons/compress/archivers/tar/TarArchiveEntryTest.java Tue Mar 17 19:56:57 2009 @@ -50,6 +50,7 @@ try { tout = new TarArchiveOutputStream(new FileOutputStream(f)); TarArchiveEntry t = new TarArchiveEntry(new File(ROOT)); +t.setSize(0); tout.putNextEntry(t); tout.closeEntry(); t = new TarArchiveEntry(new File(new File(ROOT), foo.txt)); @@ -73,13 +74,18 @@ tout = null; tin = new TarArchiveInputStream(new FileInputStream(f)); +//tin.setDebug(true); t = tin.getNextTarEntry(); +assertNotNull(t); assertEquals(/, t.getName()); t = tin.getNextTarEntry(); +assertNotNull(t); assertEquals(foo.txt, t.getName()); t = tin.getNextTarEntry(); +assertNotNull(t); assertEquals(bar.txt, t.getName()); t = tin.getNextTarEntry(); +assertNotNull(t); assertEquals(baz.txt, t.getName()); } finally { if (tin != null) {
svn commit: r755472 - in /commons/sandbox/compress/trunk/src: main/java/org/apache/commons/compress/archivers/tar/TarArchiveEntry.java test/java/org/apache/commons/compress/archivers/tar/TarArchiveEnt
Author: bodewig Date: Wed Mar 18 04:38:47 2009 New Revision: 755472 URL: http://svn.apache.org/viewvc?rev=755472view=rev Log: use proper size for directories - SANDBOX-303 Modified: commons/sandbox/compress/trunk/src/main/java/org/apache/commons/compress/archivers/tar/TarArchiveEntry.java commons/sandbox/compress/trunk/src/test/java/org/apache/commons/compress/archivers/tar/TarArchiveEntryTest.java Modified: commons/sandbox/compress/trunk/src/main/java/org/apache/commons/compress/archivers/tar/TarArchiveEntry.java URL: http://svn.apache.org/viewvc/commons/sandbox/compress/trunk/src/main/java/org/apache/commons/compress/archivers/tar/TarArchiveEntry.java?rev=755472r1=755471r2=755472view=diff == --- commons/sandbox/compress/trunk/src/main/java/org/apache/commons/compress/archivers/tar/TarArchiveEntry.java (original) +++ commons/sandbox/compress/trunk/src/main/java/org/apache/commons/compress/archivers/tar/TarArchiveEntry.java Wed Mar 18 04:38:47 2009 @@ -212,12 +212,13 @@ if (nameLength == 0 || name.charAt(nameLength - 1) != '/') { this.name.append(/); } +this.size = 0; } else { this.mode = DEFAULT_FILE_MODE; this.linkFlag = LF_NORMAL; +this.size = file.length(); } -this.size = file.length(); this.modTime = file.lastModified() / MILLIS_PER_SECOND; this.devMajor = 0; this.devMinor = 0; Modified: commons/sandbox/compress/trunk/src/test/java/org/apache/commons/compress/archivers/tar/TarArchiveEntryTest.java URL: http://svn.apache.org/viewvc/commons/sandbox/compress/trunk/src/test/java/org/apache/commons/compress/archivers/tar/TarArchiveEntryTest.java?rev=755472r1=755471r2=755472view=diff == --- commons/sandbox/compress/trunk/src/test/java/org/apache/commons/compress/archivers/tar/TarArchiveEntryTest.java (original) +++ commons/sandbox/compress/trunk/src/test/java/org/apache/commons/compress/archivers/tar/TarArchiveEntryTest.java Wed Mar 18 04:38:47 2009 @@ -50,7 +50,6 @@ try { tout = new TarArchiveOutputStream(new FileOutputStream(f)); TarArchiveEntry t = new TarArchiveEntry(new File(ROOT)); -t.setSize(0); tout.putNextEntry(t); tout.closeEntry(); t = new TarArchiveEntry(new File(new File(ROOT), foo.txt));
svn commit: r756433 - in /commons: proper/compress/ proper/compress/branches/ proper/compress/tags/ proper/compress/trunk/ sandbox/compress/ trunks-proper/ trunks-sandbox/
Author: bodewig Date: Fri Mar 20 12:40:03 2009 New Revision: 756433 URL: http://svn.apache.org/viewvc?rev=756433view=rev Log: move compress from sandbox to proper Added: commons/proper/compress/ - copied from r756432, commons/sandbox/compress/ Removed: commons/proper/compress/branches/ commons/proper/compress/tags/ commons/proper/compress/trunk/ commons/sandbox/compress/ Modified: commons/trunks-proper/ (props changed) commons/trunks-sandbox/ (props changed) Propchange: commons/trunks-proper/ -- --- svn:externals (original) +++ svn:externals Fri Mar 20 12:40:03 2009 @@ -10,6 +10,7 @@ commons-parent https://svn.apache.org/repos/asf/commons/proper/commons-parent/trunk commons-sandbox-parent https://svn.apache.org/repos/asf/commons/proper/commons-sandbox-parent/trunk/ commons-skin https://svn.apache.org/repos/asf/commons/proper/commons-skin/trunk +compress https://svn.apache.org/repos/asf/commons/proper/compress/trunk configuration https://svn.apache.org/repos/asf/commons/proper/configuration/trunk daemon https://svn.apache.org/repos/asf/commons/proper/daemon/trunk dbcp https://svn.apache.org/repos/asf/commons/proper/dbcp/trunk Propchange: commons/trunks-sandbox/ -- --- svn:externals (original) +++ svn:externals Fri Mar 20 12:40:03 2009 @@ -1,6 +1,5 @@ commons-build https://svn.apache.org/repos/asf/commons/proper/commons-build/trunk commons-sandbox-parent https://svn.apache.org/repos/asf/commons/proper/commons-sandbox-parent/trunk/ -compress https://svn.apache.org/repos/asf/commons/sandbox/compress/trunk csv https://svn.apache.org/repos/asf/commons/sandbox/csv/trunk expression https://svn.apache.org/repos/asf/commons/sandbox/expression/trunk finder https://svn.apache.org/repos/asf/commons/sandbox/finder/trunk
svn commit: r756437 - in /commons: proper/compress/ sandbox/compress/ sandbox/compress/branches/ sandbox/compress/branches/olddesign/ sandbox/compress/branches/olddesign/src/ sandbox/compress/branches
Author: bodewig Date: Fri Mar 20 12:50:18 2009 New Revision: 756437 URL: http://svn.apache.org/viewvc?rev=756437view=rev Log: revert part of the move, need to figure out why only the top level dir was copied first Added: commons/sandbox/compress/ - copied from r756432, commons/sandbox/compress/ commons/sandbox/compress/branches/ - copied from r756432, commons/sandbox/compress/branches/ commons/sandbox/compress/branches/olddesign/ (props changed) - copied from r756432, commons/sandbox/compress/branches/olddesign/ commons/sandbox/compress/branches/olddesign/LICENSE.txt - copied unchanged from r756432, commons/sandbox/compress/branches/olddesign/LICENSE.txt commons/sandbox/compress/branches/olddesign/NOTICE.txt - copied unchanged from r756432, commons/sandbox/compress/branches/olddesign/NOTICE.txt commons/sandbox/compress/branches/olddesign/README.txt - copied unchanged from r756432, commons/sandbox/compress/branches/olddesign/README.txt commons/sandbox/compress/branches/olddesign/checkstyle.xml - copied unchanged from r756432, commons/sandbox/compress/branches/olddesign/checkstyle.xml commons/sandbox/compress/branches/olddesign/license-header.txt - copied unchanged from r756432, commons/sandbox/compress/branches/olddesign/license-header.txt commons/sandbox/compress/branches/olddesign/maven.xml - copied unchanged from r756432, commons/sandbox/compress/branches/olddesign/maven.xml commons/sandbox/compress/branches/olddesign/pom.xml - copied unchanged from r756432, commons/sandbox/compress/branches/olddesign/pom.xml commons/sandbox/compress/branches/olddesign/project.properties - copied unchanged from r756432, commons/sandbox/compress/branches/olddesign/project.properties commons/sandbox/compress/branches/olddesign/project.xml - copied unchanged from r756432, commons/sandbox/compress/branches/olddesign/project.xml commons/sandbox/compress/branches/olddesign/src/ - copied from r756432, commons/sandbox/compress/branches/olddesign/src/ commons/sandbox/compress/branches/olddesign/src/examples/ - copied from r756432, commons/sandbox/compress/branches/olddesign/src/examples/ commons/sandbox/compress/branches/olddesign/src/examples/org/ - copied from r756432, commons/sandbox/compress/branches/olddesign/src/examples/org/ commons/sandbox/compress/branches/olddesign/src/examples/org/apache/ - copied from r756432, commons/sandbox/compress/branches/olddesign/src/examples/org/apache/ commons/sandbox/compress/branches/olddesign/src/examples/org/apache/commons/ - copied from r756432, commons/sandbox/compress/branches/olddesign/src/examples/org/apache/commons/ commons/sandbox/compress/branches/olddesign/src/examples/org/apache/commons/compress/ - copied from r756432, commons/sandbox/compress/branches/olddesign/src/examples/org/apache/commons/compress/ commons/sandbox/compress/branches/olddesign/src/examples/org/apache/commons/compress/examples/ - copied from r756432, commons/sandbox/compress/branches/olddesign/src/examples/org/apache/commons/compress/examples/ commons/sandbox/compress/branches/olddesign/src/examples/org/apache/commons/compress/examples/BZip2Example.java - copied unchanged from r756432, commons/sandbox/compress/branches/olddesign/src/examples/org/apache/commons/compress/examples/BZip2Example.java commons/sandbox/compress/branches/olddesign/src/examples/org/apache/commons/compress/examples/TarExample.java - copied unchanged from r756432, commons/sandbox/compress/branches/olddesign/src/examples/org/apache/commons/compress/examples/TarExample.java commons/sandbox/compress/branches/olddesign/src/examples/org/apache/commons/compress/examples/ZipExample.java - copied unchanged from r756432, commons/sandbox/compress/branches/olddesign/src/examples/org/apache/commons/compress/examples/ZipExample.java commons/sandbox/compress/branches/olddesign/src/java/ - copied from r756432, commons/sandbox/compress/branches/olddesign/src/java/ commons/sandbox/compress/branches/olddesign/src/java/org/ - copied from r756432, commons/sandbox/compress/branches/olddesign/src/java/org/ commons/sandbox/compress/branches/olddesign/src/java/org/apache/ - copied from r756432, commons/sandbox/compress/branches/olddesign/src/java/org/apache/ commons/sandbox/compress/branches/olddesign/src/java/org/apache/commons/ - copied from r756432, commons/sandbox/compress/branches/olddesign/src/java/org/apache/commons/ commons/sandbox/compress/branches/olddesign/src/java/org/apache/commons/compress/ - copied from r756432, commons/sandbox/compress/branches/olddesign/src/java/org/apache/commons/compress/ commons/sandbox/compress/branches/olddesign/src/java/org/apache/commons/compress/AbstractArchive.java - copied unchanged from r756432, commons
svn commit: r756443 - /commons/proper/compress/
Author: bodewig Date: Fri Mar 20 13:14:08 2009 New Revision: 756443 URL: http://svn.apache.org/viewvc?rev=756443view=rev Log: copy compress from sandbox to proper Added: commons/proper/compress/ - copied from r756441, commons/sandbox/compress/
svn commit: r756447 - in /commons/proper/compress/tags/compress_sandbox_03_2009: ./ LICENSE.txt NOTICE.txt PROPOSAL.txt pom.xml src/
Author: bodewig Date: Fri Mar 20 13:26:04 2009 New Revision: 756447 URL: http://svn.apache.org/viewvc?rev=756447view=rev Log: tag copied version of compress Added: commons/proper/compress/tags/compress_sandbox_03_2009/ - copied from r756441, commons/sandbox/compress/trunk/ commons/proper/compress/tags/compress_sandbox_03_2009/LICENSE.txt - copied unchanged from r756446, commons/sandbox/compress/trunk/LICENSE.txt commons/proper/compress/tags/compress_sandbox_03_2009/NOTICE.txt - copied unchanged from r756446, commons/sandbox/compress/trunk/NOTICE.txt commons/proper/compress/tags/compress_sandbox_03_2009/PROPOSAL.txt - copied unchanged from r756446, commons/sandbox/compress/trunk/PROPOSAL.txt commons/proper/compress/tags/compress_sandbox_03_2009/pom.xml - copied unchanged from r756446, commons/sandbox/compress/trunk/pom.xml commons/proper/compress/tags/compress_sandbox_03_2009/src/ - copied from r756446, commons/sandbox/compress/trunk/src/
svn commit: r756448 - /commons/sandbox/compress/
Author: bodewig Date: Fri Mar 20 13:26:59 2009 New Revision: 756448 URL: http://svn.apache.org/viewvc?rev=756448view=rev Log: remove compress from sandbox Removed: commons/sandbox/compress/
svn commit: r756451 - /commons/proper/compress/trunk/pom.xml
Author: bodewig Date: Fri Mar 20 13:31:11 2009 New Revision: 756451 URL: http://svn.apache.org/viewvc?rev=756451view=rev Log: Sandbox - Proper in POM except for site stuff 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=756451r1=756450r2=756451view=diff == --- commons/proper/compress/trunk/pom.xml (original) +++ commons/proper/compress/trunk/pom.xml Fri Mar 20 13:31:11 2009 @@ -22,13 +22,13 @@ modelVersion4.0.0/modelVersion parent groupIdorg.apache.commons/groupId -artifactIdcommons-sandbox-parent/artifactId -version7/version +artifactIdcommons-parent/artifactId +version11/version /parent artifactIdcommons-compress/artifactId version1.0-SNAPSHOT/version - nameCommons Compress (Sandbox)/name + nameCommons Compress/name urlhttp://commons.apache.org/sandbox/compress//url descriptionCommons Compress is a component that contains Tar, Zip and BZip2 packages/description @@ -71,9 +71,9 @@ /contributors scm - connectionscm:svn:http://svn.apache.org/repos/asf/commons/sandbox/compress/trunk/connection - developerConnectionscm:svn:https://svn.apache.org/repos/asf/commons/sandbox/compress/trunk/developerConnection -urlhttp://svn.apache.org/repos/asf/commons/sandbox/compress/trunk/url + connectionscm:svn:http://svn.apache.org/repos/asf/commons/proper/compress/trunk/connection + developerConnectionscm:svn:https://svn.apache.org/repos/asf/commons/proper/compress/trunk/developerConnection +urlhttp://svn.apache.org/repos/asf/commons/proper/compress/trunk/url /scm distributionManagement
svn commit: r756455 - /commons/proper/compress/trunk/pom.xml
Author: bodewig Date: Fri Mar 20 13:35:38 2009 New Revision: 756455 URL: http://svn.apache.org/viewvc?rev=756455view=rev Log: bump JUnit dependency 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=756455r1=756454r2=756455view=diff == --- commons/proper/compress/trunk/pom.xml (original) +++ commons/proper/compress/trunk/pom.xml Fri Mar 20 13:35:38 2009 @@ -36,7 +36,7 @@ dependency groupIdjunit/groupId artifactIdjunit/artifactId - version3.8.1/version + version3.8.2/version scopetest/scope /dependency /dependencies
svn commit: r756462 - /commons/trunks-sandbox/buildall.sh
Author: bodewig Date: Fri Mar 20 13:42:48 2009 New Revision: 756462 URL: http://svn.apache.org/viewvc?rev=756462view=rev Log: no idea whether this is still used. remove compress Modified: commons/trunks-sandbox/buildall.sh Modified: commons/trunks-sandbox/buildall.sh URL: http://svn.apache.org/viewvc/commons/trunks-sandbox/buildall.sh?rev=756462r1=756461r2=756462view=diff == --- commons/trunks-sandbox/buildall.sh (original) +++ commons/trunks-sandbox/buildall.sh Fri Mar 20 13:42:48 2009 @@ -18,7 +18,7 @@ ROOT=`pwd` LOGDIR=$ROOT/logs SITEDIR=$ROOT/site -COMPONENTS=compress csv exec id i18n javaflow pipeline openpgp +COMPONENTS=csv exec id i18n javaflow pipeline openpgp rm -rf $LOGDIR mkdir -p $LOGDIR
svn commit: r757383 - /commons/proper/compress/trunk/pom.xml
Author: bodewig Date: Mon Mar 23 12:25:59 2009 New Revision: 757383 URL: http://svn.apache.org/viewvc?rev=757383view=rev Log: disable checkstyle plugin since we don't provide a configuration and the site goal is broken when we leave the plugin in 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=757383r1=757382r2=757383view=diff == --- commons/proper/compress/trunk/pom.xml (original) +++ commons/proper/compress/trunk/pom.xml Mon Mar 23 12:25:59 2009 @@ -120,7 +120,7 @@ /build reporting -plugins +!--plugins plugin groupIdorg.apache.maven.plugins/groupId artifactIdmaven-checkstyle-plugin/artifactId @@ -128,7 +128,7 @@ configLocationcheckstyle.xml/configLocation /configuration /plugin -/plugins +/plugins-- /reporting /project
svn commit: r757409 - /commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/cpio/CpioUtil.java
Author: bodewig Date: Mon Mar 23 15:14:17 2009 New Revision: 757409 URL: http://svn.apache.org/viewvc?rev=757409view=rev Log: missing license header Modified: commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/cpio/CpioUtil.java Modified: commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/cpio/CpioUtil.java URL: http://svn.apache.org/viewvc/commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/cpio/CpioUtil.java?rev=757409r1=757408r2=757409view=diff == --- commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/cpio/CpioUtil.java (original) +++ commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/cpio/CpioUtil.java Mon Mar 23 15:14:17 2009 @@ -1,3 +1,21 @@ +/* + * 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; class CpioUtil {
svn commit: r758271 - /commons/proper/compress/trunk/pom.xml
Author: bodewig Date: Wed Mar 25 14:37:27 2009 New Revision: 758271 URL: http://svn.apache.org/viewvc?rev=758271view=rev Log: remove checkstyle plugin, COMPRESS-25 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=758271r1=758270r2=758271view=diff == --- commons/proper/compress/trunk/pom.xml (original) +++ commons/proper/compress/trunk/pom.xml Wed Mar 25 14:37:27 2009 @@ -161,16 +161,6 @@ /rulesets /configuration /plugin - !-- 2009-03-23 sgoeschl fix this is currently broken since there is no checkstyle.xml -- - !-- - plugin -groupIdorg.apache.maven.plugins/groupId -artifactIdmaven-checkstyle-plugin/artifactId -configuration - configLocationcheckstyle.xml/configLocation -/configuration - /plugin - -- /plugins /reporting
svn commit: r758276 - /commons/proper/compress/trunk/doap_compress.rdf
Author: bodewig Date: Wed Mar 25 14:43:44 2009 New Revision: 758276 URL: http://svn.apache.org/viewvc?rev=758276view=rev Log: Add a DOAP file, COMPRESS-38 Added: commons/proper/compress/trunk/doap_compress.rdf (with props) Added: commons/proper/compress/trunk/doap_compress.rdf URL: http://svn.apache.org/viewvc/commons/proper/compress/trunk/doap_compress.rdf?rev=758276view=auto == --- commons/proper/compress/trunk/doap_compress.rdf (added) +++ commons/proper/compress/trunk/doap_compress.rdf Wed Mar 25 14:43:44 2009 @@ -0,0 +1,47 @@ +?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 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. +-- +rdf:RDF xmlns=http://usefulinc.com/ns/doap#; xmlns:rdf=http://www.w3.org/1999/02/22-rdf-syntax-ns#; xmlns:asfext=http://projects.apache.org/ns/asfext#; xmlns:rdfs=http://www.w3.org/2000/01/rdf-schema#; xmlns:doap=http://usefulinc.com/ns/doap#; xml:lang=en + Project rdf:about=http://commons.apache.org/compress/; +nameApache Commons Compress/name +homepage rdf:resource=http://commons.apache.org/compress// +programming-languageJava/programming-language +category rdf:resource=http://projects.apache.org/category/library/ +license rdf:resource=http://usefulinc.com/doap/licenses/asl20/ +bug-database rdf:resource=http://issues.apache.org/jira/browse/COMPRESS/ +download-page rdf:resource=http://commons.apache.org/downloads/download_compress.cgi/ +asfext:pmc rdf:resource=http://commons.apache.org// +shortdesc xml:lang=enCommons Compress/shortdesc +description xml:lang=enCommons Compress: working with zip, ar, jar, bz2, cpio and gz files./description +repository + SVNRepository +browse rdf:resource=http://svn.apache.org/repos/asf/commons/proper/compress/trunk/ +location rdf:resource=http://svn.apache.org/repos/asf/commons/proper/compress/ + /SVNRepository +/repository +release + !-- + revision +namecommons-compress/name +created2009-03-18/created +version1.0/version + /revision + -- +/release +mailing-list rdf:resource=http://commons.apache.org/mail-lists.html/ + /Project +/rdf:RDF Propchange: commons/proper/compress/trunk/doap_compress.rdf -- svn:eol-style = native