commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tcu...@apache.org
Subject svn commit: r427072 [1/5] - in /jakarta/commons/sandbox/compress/trunk: ./ src/examples/ src/examples/org/ src/examples/org/apache/ src/examples/org/apache/commons/ src/examples/org/apache/commons/compress/ src/examples/org/apache/commons/compress/exam...
Date Mon, 31 Jul 2006 10:55:13 GMT
Author: tcurdt
Date: Mon Jul 31 03:55:10 2006
New Revision: 427072

URL: http://svn.apache.org/viewvc?rev=427072&view=rev
Log:
draft 8 from C. Grobmeier, grant has been received, cheers

Added:
    jakarta/commons/sandbox/compress/trunk/README.txt   (with props)
    jakarta/commons/sandbox/compress/trunk/src/examples/
    jakarta/commons/sandbox/compress/trunk/src/examples/org/
    jakarta/commons/sandbox/compress/trunk/src/examples/org/apache/
    jakarta/commons/sandbox/compress/trunk/src/examples/org/apache/commons/
    jakarta/commons/sandbox/compress/trunk/src/examples/org/apache/commons/compress/
    jakarta/commons/sandbox/compress/trunk/src/examples/org/apache/commons/compress/examples/
    jakarta/commons/sandbox/compress/trunk/src/examples/org/apache/commons/compress/examples/BZip2Example.java   (with props)
    jakarta/commons/sandbox/compress/trunk/src/examples/org/apache/commons/compress/examples/Bzip2Compress.java   (with props)
    jakarta/commons/sandbox/compress/trunk/src/examples/org/apache/commons/compress/examples/Bzip2Uncompress.java   (with props)
    jakarta/commons/sandbox/compress/trunk/src/examples/org/apache/commons/compress/examples/TarExample.java   (with props)
    jakarta/commons/sandbox/compress/trunk/src/examples/org/apache/commons/compress/examples/ZipExample.java   (with props)
    jakarta/commons/sandbox/compress/trunk/src/java/org/apache/commons/compress/AbstractArchive.java   (with props)
    jakarta/commons/sandbox/compress/trunk/src/java/org/apache/commons/compress/ArchiveEntry.java   (with props)
    jakarta/commons/sandbox/compress/trunk/src/java/org/apache/commons/compress/ArchiveException.java   (with props)
    jakarta/commons/sandbox/compress/trunk/src/java/org/apache/commons/compress/PackableObjectException.java   (with props)
    jakarta/commons/sandbox/compress/trunk/src/java/org/apache/commons/compress/UnpackException.java   (with props)
    jakarta/commons/sandbox/compress/trunk/src/java/org/apache/commons/compress/archivers/
    jakarta/commons/sandbox/compress/trunk/src/java/org/apache/commons/compress/archivers/tar/
    jakarta/commons/sandbox/compress/trunk/src/java/org/apache/commons/compress/archivers/tar/TarArchive.java   (with props)
    jakarta/commons/sandbox/compress/trunk/src/java/org/apache/commons/compress/archivers/tar/TarBuffer.java   (with props)
    jakarta/commons/sandbox/compress/trunk/src/java/org/apache/commons/compress/archivers/tar/TarEntry.java   (with props)
    jakarta/commons/sandbox/compress/trunk/src/java/org/apache/commons/compress/archivers/tar/TarInputStream.java   (with props)
    jakarta/commons/sandbox/compress/trunk/src/java/org/apache/commons/compress/archivers/tar/TarOutputStream.java   (with props)
    jakarta/commons/sandbox/compress/trunk/src/java/org/apache/commons/compress/archivers/tar/TarUtils.java   (with props)
    jakarta/commons/sandbox/compress/trunk/src/java/org/apache/commons/compress/archivers/zip/
    jakarta/commons/sandbox/compress/trunk/src/java/org/apache/commons/compress/archivers/zip/AsiExtraField.java   (with props)
    jakarta/commons/sandbox/compress/trunk/src/java/org/apache/commons/compress/archivers/zip/ExtraFieldUtils.java   (with props)
    jakarta/commons/sandbox/compress/trunk/src/java/org/apache/commons/compress/archivers/zip/UnixStat.java   (with props)
    jakarta/commons/sandbox/compress/trunk/src/java/org/apache/commons/compress/archivers/zip/UnrecognizedExtraField.java   (with props)
    jakarta/commons/sandbox/compress/trunk/src/java/org/apache/commons/compress/archivers/zip/ZipArchive.java   (with props)
    jakarta/commons/sandbox/compress/trunk/src/java/org/apache/commons/compress/archivers/zip/ZipEntry.java   (with props)
    jakarta/commons/sandbox/compress/trunk/src/java/org/apache/commons/compress/archivers/zip/ZipExtraField.java   (with props)
    jakarta/commons/sandbox/compress/trunk/src/java/org/apache/commons/compress/archivers/zip/ZipLong.java   (with props)
    jakarta/commons/sandbox/compress/trunk/src/java/org/apache/commons/compress/archivers/zip/ZipOutputStream.java   (with props)
    jakarta/commons/sandbox/compress/trunk/src/java/org/apache/commons/compress/archivers/zip/ZipShort.java   (with props)
    jakarta/commons/sandbox/compress/trunk/src/java/org/apache/commons/compress/archivers/zip/package.html   (with props)
    jakarta/commons/sandbox/compress/trunk/src/java/org/apache/commons/compress/compressors/
    jakarta/commons/sandbox/compress/trunk/src/java/org/apache/commons/compress/compressors/bzip2/
    jakarta/commons/sandbox/compress/trunk/src/java/org/apache/commons/compress/compressors/bzip2/BZip2Compressor.java   (with props)
    jakarta/commons/sandbox/compress/trunk/src/java/org/apache/commons/compress/compressors/bzip2/BZip2Constants.java   (with props)
    jakarta/commons/sandbox/compress/trunk/src/java/org/apache/commons/compress/compressors/bzip2/BZip2InputStream.java   (with props)
    jakarta/commons/sandbox/compress/trunk/src/java/org/apache/commons/compress/compressors/bzip2/BZip2OutputStream.java   (with props)
    jakarta/commons/sandbox/compress/trunk/src/java/org/apache/commons/compress/compressors/bzip2/CRC.java   (with props)
    jakarta/commons/sandbox/compress/trunk/src/java/org/apache/commons/compress/compressors/bzip2/package.html   (with props)
    jakarta/commons/sandbox/compress/trunk/src/test/org/apache/commons/compress/CompressUtilsTest.java   (with props)
    jakarta/commons/sandbox/compress/trunk/src/test/org/apache/commons/compress/archivers/
    jakarta/commons/sandbox/compress/trunk/src/test/org/apache/commons/compress/archivers/tar/
    jakarta/commons/sandbox/compress/trunk/src/test/org/apache/commons/compress/archivers/tar/TarTestCase.java   (with props)
    jakarta/commons/sandbox/compress/trunk/src/test/org/apache/commons/compress/archivers/tar/TarTestSuite.java   (with props)
    jakarta/commons/sandbox/compress/trunk/src/test/org/apache/commons/compress/archivers/tar/data.txt   (with props)
    jakarta/commons/sandbox/compress/trunk/src/test/org/apache/commons/compress/archivers/tar/gnu.tar   (with props)
    jakarta/commons/sandbox/compress/trunk/src/test/org/apache/commons/compress/archivers/tar/posix.tar   (with props)
    jakarta/commons/sandbox/compress/trunk/src/test/org/apache/commons/compress/archivers/tar/update-tars.bat   (with props)
    jakarta/commons/sandbox/compress/trunk/src/test/org/apache/commons/compress/archivers/zip/
    jakarta/commons/sandbox/compress/trunk/src/test/org/apache/commons/compress/archivers/zip/AsiExtraFieldTestCase.java   (with props)
    jakarta/commons/sandbox/compress/trunk/src/test/org/apache/commons/compress/archivers/zip/ExtraFieldUtilsTestCase.java   (with props)
    jakarta/commons/sandbox/compress/trunk/src/test/org/apache/commons/compress/archivers/zip/ZipEntryTestCase.java   (with props)
    jakarta/commons/sandbox/compress/trunk/src/test/org/apache/commons/compress/archivers/zip/ZipLongTestCase.java   (with props)
    jakarta/commons/sandbox/compress/trunk/src/test/org/apache/commons/compress/archivers/zip/ZipShortTestCase.java   (with props)
    jakarta/commons/sandbox/compress/trunk/src/test/org/apache/commons/compress/compressors/
    jakarta/commons/sandbox/compress/trunk/src/test/org/apache/commons/compress/compressors/bzip2/
    jakarta/commons/sandbox/compress/trunk/src/test/org/apache/commons/compress/compressors/bzip2/BzipTestCase.java   (with props)
    jakarta/commons/sandbox/compress/trunk/src/test/org/apache/commons/compress/compressors/bzip2/asf-logo-huge.tar   (with props)
    jakarta/commons/sandbox/compress/trunk/src/test/org/apache/commons/compress/compressors/bzip2/asf-logo-huge.tar.bz2   (with props)
Modified:
    jakarta/commons/sandbox/compress/trunk/project.properties
    jakarta/commons/sandbox/compress/trunk/project.xml
    jakarta/commons/sandbox/compress/trunk/xdocs/navigation.xml

Added: jakarta/commons/sandbox/compress/trunk/README.txt
URL: http://svn.apache.org/viewvc/jakarta/commons/sandbox/compress/trunk/README.txt?rev=427072&view=auto
==============================================================================
--- jakarta/commons/sandbox/compress/trunk/README.txt (added)
+++ jakarta/commons/sandbox/compress/trunk/README.txt Mon Jul 31 03:55:10 2006
@@ -0,0 +1,74 @@
+RELEASE NOTES DRAFT 7:
++ ArchiveFactory Interface has changed
++ Factory can identify archives by heade
+RELEASE NOTES DRAFT 6:
++ use of parameter overloading is back
++ divided between Decompressor and Comressor
+- compressor does not accept filenames as string arguments
+- deleted AbstractCompressor.createTempFile
++ created CompressUtils
++ Moved copy of AbstractCompressor into CompressUtils
++ Added new methods for decompressing/compressing
++ changed FileInputStream return methods to InputStream
++ refactored the archiver interface
++ Archive to Stream
++ Exceptions use initCause(Throwable) for exception chaining
++ one can add InputStreams now instead of files now
+
+* TODO:
+This list bases on comments from the user/development list which has NOT
+beeing implemented yet but should be checked for implementaton or should be implemented.
+
+** BASED ON DRAFT 6:
+* handle file overwriting f.e.
+	- Archiver.setOverwriteFilter(TrueFileFilter.INSTANCE)
+	- Compresser.setOverwrite(true); 
+* Recursivley add directories
+* For both of ArchiveType and CompressorType add a valueOf(String)
+  method. This is what Java 1.5 Enums have and it lets you convert a
+  String, say from a config file, into an Enum. To do this right you'll
+  need to keep track of other Types with a Map or something in the
+  constructor. 
+* TestCases are out of date
+* New Feature: delete from archives
+* if an archive is set with the setArchive or the getInstance(File) method
+  the archives fileentrys must be added to the internal entrylist for possible manipulation
+* Merge Plexus Code, if there is something which is good for compress
+* Propose new name? The maingoal is not to compress, imho
+* refactor and review tar, zip and bzip2 implementations
+* rebuild javadoc
+* check out how compress could fit in VFS best
+* Check wether TAR works on solaris or not.
+  "Background: The original tar format supports a maximum path size of 99
+  characters. If you use Solaris tar, you will not see a problem, because
+  Solaris tar extends this format beyond 99 characters but in a Solaris-only
+  way. GNU tar has a different way of extending the format, so is incompatible
+  with the Solaris tar. WinZip and Cygnus GNU tar 1.11.8 do not support the
+  Solaris way. We recommended that you use Solaris tar to extract the archive,
+  or use the jar tool or WinZip to extract the zip version."
+  http://java.sun.com/products/archive/j2se/1.2.2_017/install-docs.html
+
+** BASED ON DRAFT 5:
+* ZipInputStream/TarInputStream: skimming it I don't it. It looks like it's taking
+the InputStream concept and corrupting it with the notion of many
+separate streams for each file in one stream. This is confusing
+because it doesn't fit the expectations of an InputStream. IMO it
+should be it's something similar to an Iterator that takes a raw
+InputStream and provides a way to get at metadata sequentially from
+the raw InputStream. From the meta data you should be able to get an
+InputStream which is just for that file in the archive.
+
+* ZipOutputStream/TarOutputStream: Same problem as TarInputStream but with an
+OutputStream. Because TarOutputStream subclasses OutputStream it makes
+write methods available. But using these methods are dangerous because
+if you write a different number of bytes than what was passed when
+putNextEntry(TarEntry) was called you corrupt the archive. A good API
+doesn't let the programmer make mistakes. I'd change this to be it's
+own object type that accepts TarEntrys with all the needed to add a
+file in one step that either succeeds or fails.
+
+* ZipLong, ZipShort: these are both public, and I don't see why they
+need to be. They are only used inside the package with the exception
+of 3 places ZipShort is used as a parameter type in a public method. I
+don't see why those ZipShorts cannot be converted to shorts for the
+public API and both of them made package private.

Propchange: jakarta/commons/sandbox/compress/trunk/README.txt
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: jakarta/commons/sandbox/compress/trunk/README.txt
------------------------------------------------------------------------------
    svn:executable = *

Propchange: jakarta/commons/sandbox/compress/trunk/README.txt
------------------------------------------------------------------------------
    svn:keywords = "Author Date Id Revision"

Modified: jakarta/commons/sandbox/compress/trunk/project.properties
URL: http://svn.apache.org/viewvc/jakarta/commons/sandbox/compress/trunk/project.properties?rev=427072&r1=427071&r2=427072&view=diff
==============================================================================
--- jakarta/commons/sandbox/compress/trunk/project.properties (original)
+++ jakarta/commons/sandbox/compress/trunk/project.properties Mon Jul 31 03:55:10 2006
@@ -12,12 +12,12 @@
 #   See the License for the specific language governing permissions and
 #   limitations under the License.
 
+maven.xdoc.jsl=../commons-build/commons-site.jsl
 maven.xdoc.date=bottom
 maven.xdoc.poweredby.image=maven-feather.png
 maven.xdoc.version=${pom.currentVersion}
 maven.xdoc.developmentProcessUrl=http://jakarta.apache.org/commons/charter.html
 maven.xdoc.includeProjectDocumentation=yes
-maven.changes.issue.template=%URL%/browse/%ISSUE%
 
 maven.checkstyle.properties = checkstyle.xml
 
@@ -30,19 +30,13 @@
 # uncomment the next line to work in offline mode (no jar download & no linkcheck)
 #maven.mode.online=
 maven.changelog.factory=org.apache.maven.svnlib.SvnChangeLogFactory
-maven.changelog.range=365
 
 maven.javadoc.author=false
-#maven.javadoc.links=http://java.sun.com/products/jdk/1.4/docs/api
+maven.javadoc.links=http://java.sun.com/products/jdk/1.4/docs/api,http://jakarta.apache.org/commons/dbcp/apidocs
 
-maven.compile.source=1.3
-maven.compile.target=1.3
 maven.compile.debug=on
 maven.compile.deprecation=off
 maven.compile.optimize=off
-
-# Make the source distro unzip to a different directory
-maven.dist.src.assembly.dir=${maven.dist.assembly.dir}/src/${maven.final.name}-src
 
 maven.jarResources.basedir=src/java
 maven.jar.excludes=**/package.html

Modified: jakarta/commons/sandbox/compress/trunk/project.xml
URL: http://svn.apache.org/viewvc/jakarta/commons/sandbox/compress/trunk/project.xml?rev=427072&r1=427071&r2=427072&view=diff
==============================================================================
--- jakarta/commons/sandbox/compress/trunk/project.xml (original)
+++ jakarta/commons/sandbox/compress/trunk/project.xml Mon Jul 31 03:55:10 2006
@@ -15,60 +15,24 @@
    limitations under the License.
 -->
 <project>
-  <pomVersion>3</pomVersion>
+  <extend>../commons-build/sandbox-project.xml</extend>
   <name>Commons Compress</name>
-  <groupId>org.apache.commons</groupId>
-  <artifactId>commons-compress</artifactId>
+  <id>commons-compress</id>
   <logo>/images/compress-logo-white.png</logo>
-  <currentVersion>1.0-SNAPSHOT</currentVersion>
   <inceptionYear>2002</inceptionYear>
   <shortDescription>Commons Compress</shortDescription>
   <description>
     Commons Compress is a component that contains Tar, Zip and BZip2 packages.
   </description>
-
-  <url>http://jakarta.apache.org/commons/${pom.artifactId.substring(8)}/</url>
-  <package>org.apache.commons.${pom.artifactId.substring(8)}</package>
-
-  <organization>
-    <name>The Apache Software Foundation</name>
-    <url>http://jakarta.apache.org</url>
-    <logo>http://jakarta.apache.org/images/original-jakarta-logo.gif</logo>
-  </organization>
-
-  <licenses>
-    <license>
-      <name>The Apache Software License, Version 2.0</name>
-      <url>/LICENSE.txt</url>
-      <distribution>repo</distribution>
-    </license>
-  </licenses>
-
-  <gumpRepositoryId>jakarta</gumpRepositoryId>
-  <issueTrackingUrl>http://issues.apache.org/jira/</issueTrackingUrl>
-  <siteAddress>people.apache.org</siteAddress>
-  <siteDirectory>/www/jakarta.apache.org/commons/sandbox/${pom.artifactId.substring(8)}/</siteDirectory>
-  <distributionDirectory>/www/jakarta.apache.org/builds/jakarta-commons/sandbox/${pom.artifactId.substring(8)}/</distributionDirectory>
+  <currentVersion>0.1-dev</currentVersion>
+  <issueTrackingUrl>http://issues.apache.org/bugzilla/</issueTrackingUrl>
+  <siteAddress>cvs.apache.org</siteAddress>
+  <logo></logo>
   
-  <repository>
-    <connection>scm:svn:http://svn.apache.org/repos/asf/jakarta/commons/sandbox/${pom.artifactId.substring(8)}/trunk</connection>
-    <url>http://svn.apache.org/viewcvs.cgi</url>
-  </repository>
-
-  <mailingLists>
-    <mailingList>
-      <name>Commons Dev List</name>
-      <subscribe>commons-dev-subscribe@jakarta.apache.org</subscribe>
-      <unsubscribe>commons-dev-unsubscribe@jakarta.apache.org</unsubscribe>
-      <archive>http://mail-archives.apache.org/mod_mbox/jakarta-commons-dev/</archive>
-    </mailingList>
-    <mailingList>
-      <name>Commons User List</name>
-      <subscribe>commons-user-subscribe@jakarta.apache.org</subscribe>
-      <unsubscribe>commons-user-unsubscribe@jakarta.apache.org</unsubscribe>
-      <archive>http://mail-archives.apache.org/mod_mbox/jakarta-commons-user/</archive>
-    </mailingList>
-  </mailingLists>
+  <versions>
+  </versions>
+  <branches>
+  </branches>
 
   <developers>
     <developer>
@@ -93,65 +57,17 @@
   </developers>
     
   <dependencies>
-
     <dependency>
-      <groupId>junit</groupId>
-      <artifactId>junit</artifactId>
+      <id>junit</id>
       <version>3.8.1</version>
-      <url>http://www.junit.org/</url>
-      <properties>
-          <scope>test</scope>
-          <comment>
-              &lt;strong&gt;Test&lt;/strong&gt; - Only required
-              for running the unit tests.
-          </comment>
-      </properties>
     </dependency>
-
-    <dependency>
-      <groupId>maven</groupId>
-      <artifactId>maven-xdoc-plugin</artifactId>
-      <version>1.9.2</version>
-      <url>http://maven.apache.org/reference/plugins/xdoc/</url>
-      <type>plugin</type>
-      <properties>
-          <comment>
-              &lt;strong&gt;Site&lt;/strong&gt; - Only
-              required for building the website/documentation.
-          </comment>
-      </properties>
-    </dependency>
-
   </dependencies>
 
   <build>
-    <sourceDirectory>src/java</sourceDirectory>
-    <unitTestSourceDirectory>src/test</unitTestSourceDirectory>
     <unitTest>
       <includes>
         <include>**/*Test*</include>
       </includes>
     </unitTest>
-    <resources>
-      <resource>
-        <directory>${basedir}</directory>
-        <targetPath>META-INF</targetPath>
-        <includes>
-          <include>NOTICE.txt</include>
-        </includes>
-      </resource>
-    </resources>
   </build>
-
-
-  <reports>
-    <!-- report>maven-checkstyle-plugin</report -->
-    <report>maven-changelog-plugin</report>
-    <report>maven-javadoc-plugin</report>
-    <report>maven-junit-report-plugin</report>
-    <report>maven-jxr-plugin</report>
-    <report>maven-junit-report-plugin</report>
-    <report>maven-license-plugin</report>
-  </reports>
-
 </project>

Added: jakarta/commons/sandbox/compress/trunk/src/examples/org/apache/commons/compress/examples/BZip2Example.java
URL: http://svn.apache.org/viewvc/jakarta/commons/sandbox/compress/trunk/src/examples/org/apache/commons/compress/examples/BZip2Example.java?rev=427072&view=auto
==============================================================================
--- jakarta/commons/sandbox/compress/trunk/src/examples/org/apache/commons/compress/examples/BZip2Example.java (added)
+++ jakarta/commons/sandbox/compress/trunk/src/examples/org/apache/commons/compress/examples/BZip2Example.java Mon Jul 31 03:55:10 2006
@@ -0,0 +1,123 @@
+/*
+ * Copyright 2002,2004 The Apache Software Foundation.
+ * 
+ * Licensed 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.examples;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileNotFoundException;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+
+import org.apache.commons.compress.CompressException;
+import org.apache.commons.compress.Compressor;
+import org.apache.commons.compress.CompressorFactory;
+/**
+ * BZIP2 .Example
+ */
+public class BZip2Example {
+	/**
+	 * 
+	 */
+	public BZip2Example() {
+		super();
+	}
+	
+	/**
+	 * Compression
+	 */
+	public void compress() {
+		Compressor compressor;
+		try {
+			compressor = CompressorFactory.getInstance("bz2");
+			compressor.compressToHere( 
+							new File("C:\\Temp\\test.tar"));
+		} catch (CompressException e) {
+			e.printStackTrace();
+		}
+	}
+	
+	/**
+	 * 
+	 */
+	public void compressStream() {
+		InputStream in = null;
+		FileOutputStream out = null;
+		FileInputStream param = null;
+		try {
+			// Get a filestream
+			param = new FileInputStream(
+						new File("C:\\Temp\\test.tar"));
+
+			// get the compressor
+			Compressor compressor = CompressorFactory.getInstance("bz2");
+
+			// compress this stream and get back an readable inputstream
+			in = compressor.compress(param);
+				
+			// write this stream to a destination of your desire
+			File f = new File("C:\\Temp\\test.tar.example.bz2");
+			out = new FileOutputStream(f);
+			final byte[] buffer = new byte[ 8024 ];
+	        int n = 0;
+	        while( -1 != ( n = in.read( buffer ) ) ) {
+	            out.write( buffer, 0, n );
+	        }
+		} catch (CompressException e) {
+			e.printStackTrace();
+		} catch (FileNotFoundException e) {
+			e.printStackTrace();
+		} catch (IOException e) {
+			e.printStackTrace();
+		} finally {
+			try {
+				out.close();
+		        in.close();
+		        param.close();
+			} catch (IOException e1) {
+				e1.printStackTrace();
+			}
+		}
+	}
+	
+	/**
+	 * Decompress a file.
+	 */
+	public void decompress() {
+		Compressor decompressor;
+		try {
+//			decompressor = DecompressorFactory.BZIP2.getInstance();
+			decompressor = CompressorFactory.getInstance("bz2");
+			
+			decompressor.decompressTo( 
+							new File("C:\\Temp\\asf-logo-huge.tar.bz2"),
+							new File("C:\\Temp\\asf-logo-huge.tar"));
+		} catch (CompressException e) {
+			e.printStackTrace();
+		}
+	}
+	
+	public static void main(String[] args) {
+		new BZip2Example().compress();
+		new BZip2Example().decompress();
+	}
+}
+
+
+
+
+
+

Propchange: jakarta/commons/sandbox/compress/trunk/src/examples/org/apache/commons/compress/examples/BZip2Example.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: jakarta/commons/sandbox/compress/trunk/src/examples/org/apache/commons/compress/examples/BZip2Example.java
------------------------------------------------------------------------------
    svn:executable = *

Propchange: jakarta/commons/sandbox/compress/trunk/src/examples/org/apache/commons/compress/examples/BZip2Example.java
------------------------------------------------------------------------------
    svn:keywords = "Author Date Id Revision"

Added: jakarta/commons/sandbox/compress/trunk/src/examples/org/apache/commons/compress/examples/Bzip2Compress.java
URL: http://svn.apache.org/viewvc/jakarta/commons/sandbox/compress/trunk/src/examples/org/apache/commons/compress/examples/Bzip2Compress.java?rev=427072&view=auto
==============================================================================
--- jakarta/commons/sandbox/compress/trunk/src/examples/org/apache/commons/compress/examples/Bzip2Compress.java (added)
+++ jakarta/commons/sandbox/compress/trunk/src/examples/org/apache/commons/compress/examples/Bzip2Compress.java Mon Jul 31 03:55:10 2006
@@ -0,0 +1,70 @@
+/*
+ * Copyright 2002,2004 The Apache Software Foundation.
+ * 
+ * Licensed 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.examples;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+
+import org.apache.commons.compress.CompressUtils;
+import org.apache.commons.compress.compressors.bzip2.BZip2OutputStream;
+
+/**
+ * This simple example shows how to use the Bzip2 classes to compress a file.
+ *
+ * @author <a href="mailto:peter@apache.org">Peter Donald</a>
+ * @version $Revision: 155439 $ $Date$
+ * @deprecated Take a look at Bzip2Example instead
+ */
+public class Bzip2Compress
+{
+    public static void main( final String[] args )
+        throws Exception
+    {
+        if( 2 != args.length )
+        {
+            System.out.println( "java Bzip2Compress <input> <output>" );
+            System.exit( 1 );
+        }
+
+        final File source = new File( args[ 0 ] );
+        final File destination = new File( args[ 1 ] );
+        final BZip2OutputStream output =
+            new BZip2OutputStream( new FileOutputStream( destination ) );
+        final FileInputStream input = new FileInputStream( source );
+        CompressUtils.copy( input, output );
+        input.close();
+        output.close();
+    }
+
+    /**
+     * Copy bytes from an <code>InputStream</code> to an <code>OutputStream</code>.
+     */
+    private static void copy( final InputStream input,
+                              final OutputStream output )
+        throws IOException
+    {
+        final byte[] buffer = new byte[ 8024 ];
+        int n = 0;
+        while( -1 != ( n = input.read( buffer ) ) )
+        {
+            output.write( buffer, 0, n );
+        }
+    }
+}

Propchange: jakarta/commons/sandbox/compress/trunk/src/examples/org/apache/commons/compress/examples/Bzip2Compress.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: jakarta/commons/sandbox/compress/trunk/src/examples/org/apache/commons/compress/examples/Bzip2Compress.java
------------------------------------------------------------------------------
    svn:executable = *

Propchange: jakarta/commons/sandbox/compress/trunk/src/examples/org/apache/commons/compress/examples/Bzip2Compress.java
------------------------------------------------------------------------------
    svn:keywords = "Author Date Id Revision"

Added: jakarta/commons/sandbox/compress/trunk/src/examples/org/apache/commons/compress/examples/Bzip2Uncompress.java
URL: http://svn.apache.org/viewvc/jakarta/commons/sandbox/compress/trunk/src/examples/org/apache/commons/compress/examples/Bzip2Uncompress.java?rev=427072&view=auto
==============================================================================
--- jakarta/commons/sandbox/compress/trunk/src/examples/org/apache/commons/compress/examples/Bzip2Uncompress.java (added)
+++ jakarta/commons/sandbox/compress/trunk/src/examples/org/apache/commons/compress/examples/Bzip2Uncompress.java Mon Jul 31 03:55:10 2006
@@ -0,0 +1,76 @@
+/*
+ * Copyright 2002,2004 The Apache Software Foundation.
+ * 
+ * Licensed 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.examples;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+
+import org.apache.commons.compress.CompressUtils;
+import org.apache.commons.compress.compressors.bzip2.BZip2InputStream;
+
+/**
+ * This simple example shows how to use the Bzip2 classes to uncompress a file.
+ *
+ * @author <a href="mailto:peter@apache.org">Peter Donald</a>
+ * @author <a href="mailto:nicolaken@apache.org">Nicola Ken Barozzi</a>
+ * @version $Revision: 155439 $ $Date$
+ * @deprecated Take a look at Bzip2Example instead
+ */
+public class Bzip2Uncompress
+{
+    public static void main( final String[] args )
+    {
+      try
+      {
+        if( 2 != args.length )
+        {
+            System.out.println( "java Bzip2Uncompress <input> <output>" );
+            System.exit( 1 );
+        }
+        final File source = new File( args[ 0 ] );
+        final File destination = new File( args[ 1 ] );
+        final FileOutputStream output =
+            new FileOutputStream( destination );
+        final BZip2InputStream input = new BZip2InputStream( new FileInputStream( source ) );
+        CompressUtils.copy( input, output );
+        input.close();
+        output.close();
+      }catch(Exception e){
+        e.printStackTrace();
+        System.exit(1);       
+      
+      }
+    }
+
+    /**
+     * Copy bytes from an <code>InputStream</code> to an <code>OutputStream</code>.
+     */
+    private static void copy( final InputStream input,
+                              final OutputStream output )
+        throws IOException
+    {
+        final byte[] buffer = new byte[ 8024 ];
+        int n = 0;
+        while( -1 != ( n = input.read( buffer ) ) )
+        {
+            output.write( buffer, 0, n );
+        }
+    }
+}

Propchange: jakarta/commons/sandbox/compress/trunk/src/examples/org/apache/commons/compress/examples/Bzip2Uncompress.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: jakarta/commons/sandbox/compress/trunk/src/examples/org/apache/commons/compress/examples/Bzip2Uncompress.java
------------------------------------------------------------------------------
    svn:executable = *

Propchange: jakarta/commons/sandbox/compress/trunk/src/examples/org/apache/commons/compress/examples/Bzip2Uncompress.java
------------------------------------------------------------------------------
    svn:keywords = "Author Date Id Revision"

Added: jakarta/commons/sandbox/compress/trunk/src/examples/org/apache/commons/compress/examples/TarExample.java
URL: http://svn.apache.org/viewvc/jakarta/commons/sandbox/compress/trunk/src/examples/org/apache/commons/compress/examples/TarExample.java?rev=427072&view=auto
==============================================================================
--- jakarta/commons/sandbox/compress/trunk/src/examples/org/apache/commons/compress/examples/TarExample.java (added)
+++ jakarta/commons/sandbox/compress/trunk/src/examples/org/apache/commons/compress/examples/TarExample.java Mon Jul 31 03:55:10 2006
@@ -0,0 +1,69 @@
+/*
+ * Copyright 2002,2004 The Apache Software Foundation.
+ * 
+ * Licensed 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.examples;
+
+import java.io.File;
+import java.io.FileNotFoundException;
+
+import org.apache.commons.compress.Archive;
+import org.apache.commons.compress.ArchiveException;
+import org.apache.commons.compress.ArchiverFactory;
+
+/**
+ * @author christian.grobmeier
+ */
+public class TarExample {
+	/**
+	 * 
+	 */
+	public TarExample() {
+		super();
+	}
+	
+	/**
+	 * Example for Tar-packing
+	 */
+	public void pack() {
+		try {
+			Archive archiver = ArchiverFactory.getInstance("tar");
+			archiver.add( new File("C:\\Temp\\allclasses-frame.html"));
+			archiver.add( new File("C:\\Temp\\allclasses-frame.html.bz2"));
+			archiver.save(new File("C:\\Temp\\myTar.tar"));
+		} catch (ArchiveException e) {
+			e.printStackTrace();
+		} catch (FileNotFoundException e) {
+			e.printStackTrace();
+		} 
+	}
+	
+	/**
+	 * Example for an unpack operation
+	 */
+	public void unpack() {
+		try {
+			Archive archiver = ArchiverFactory.getInstance( 
+				new File("C:\\Temp\\myTar.tar"));
+			archiver.unpack(new File("C:\\Temp\\unpacked\\"));
+		} catch (ArchiveException e) {
+			e.printStackTrace();
+		}
+	}
+	
+	public static void main(String[] args) {
+		new TarExample().pack();
+		new TarExample().unpack();
+	}
+}

Propchange: jakarta/commons/sandbox/compress/trunk/src/examples/org/apache/commons/compress/examples/TarExample.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: jakarta/commons/sandbox/compress/trunk/src/examples/org/apache/commons/compress/examples/TarExample.java
------------------------------------------------------------------------------
    svn:executable = *

Propchange: jakarta/commons/sandbox/compress/trunk/src/examples/org/apache/commons/compress/examples/TarExample.java
------------------------------------------------------------------------------
    svn:keywords = "Author Date Id Revision"

Added: jakarta/commons/sandbox/compress/trunk/src/examples/org/apache/commons/compress/examples/ZipExample.java
URL: http://svn.apache.org/viewvc/jakarta/commons/sandbox/compress/trunk/src/examples/org/apache/commons/compress/examples/ZipExample.java?rev=427072&view=auto
==============================================================================
--- jakarta/commons/sandbox/compress/trunk/src/examples/org/apache/commons/compress/examples/ZipExample.java (added)
+++ jakarta/commons/sandbox/compress/trunk/src/examples/org/apache/commons/compress/examples/ZipExample.java Mon Jul 31 03:55:10 2006
@@ -0,0 +1,62 @@
+/*
+ * Copyright 2002,2004 The Apache Software Foundation.
+ * 
+ * Licensed 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.examples;
+
+import java.io.File;
+import java.io.FileNotFoundException;
+
+import org.apache.commons.compress.Archive;
+import org.apache.commons.compress.ArchiveException;
+import org.apache.commons.compress.ArchiverFactory;
+
+/**
+ * Example for how to use the TarArchive 
+ */
+public class ZipExample {
+	/**
+	 * Example for an pack operation 
+	 */
+	public void pack() {
+		try {
+			Archive archiver = ArchiverFactory.getInstance("zip");
+			archiver.add(	new File("C:\\Temp\\1.html"));
+			archiver.add(	new File("C:\\Temp\\1.html.bz2"));
+			archiver.save(	new File("C:\\Temp\\ZIPTEST.zip"));
+		} catch (ArchiveException e) {
+			e.printStackTrace();
+		} catch (FileNotFoundException e) {
+			e.printStackTrace();
+		}
+	}
+	
+	/**
+	 * Example for an unpack operation
+	 */
+	public void unpack() {
+		try {
+			Archive archiver = ArchiverFactory.getInstance(
+					new File("C:\\Temp\\ZIPTEST.zip"));
+			archiver.unpack( new File("C:\\Temp\\unpacked\\"));
+		} catch (ArchiveException e) {
+			e.printStackTrace();
+		}
+	}
+	
+	public static void main (String argv[]) {
+		new ZipExample().pack();
+		new ZipExample().unpack();
+	}
+}
\ No newline at end of file

Propchange: jakarta/commons/sandbox/compress/trunk/src/examples/org/apache/commons/compress/examples/ZipExample.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: jakarta/commons/sandbox/compress/trunk/src/examples/org/apache/commons/compress/examples/ZipExample.java
------------------------------------------------------------------------------
    svn:executable = *

Propchange: jakarta/commons/sandbox/compress/trunk/src/examples/org/apache/commons/compress/examples/ZipExample.java
------------------------------------------------------------------------------
    svn:keywords = "Author Date Id Revision"

Added: jakarta/commons/sandbox/compress/trunk/src/java/org/apache/commons/compress/AbstractArchive.java
URL: http://svn.apache.org/viewvc/jakarta/commons/sandbox/compress/trunk/src/java/org/apache/commons/compress/AbstractArchive.java?rev=427072&view=auto
==============================================================================
--- jakarta/commons/sandbox/compress/trunk/src/java/org/apache/commons/compress/AbstractArchive.java (added)
+++ jakarta/commons/sandbox/compress/trunk/src/java/org/apache/commons/compress/AbstractArchive.java Mon Jul 31 03:55:10 2006
@@ -0,0 +1,143 @@
+/*
+ * Copyright 2002,2004 The Apache Software Foundation.
+ * 
+ * Licensed 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;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileNotFoundException;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.ArrayList;
+import java.util.Iterator;
+/**
+ * Abstract implementation of an archiver
+ */
+public abstract class AbstractArchive extends PackableObject implements Archive {
+	
+	/* hold filestreams for a possible pack operation */
+	private ArrayList entries = new ArrayList();
+	
+	/* the source of an unpack-operation */
+	private File archive = null;
+
+	public Archive newInstance() {
+		return this.newInstance();
+	}
+	/**
+	 * Compresses the file with the given String as a filename
+	 * @see org.apache.commons.compress.Archive#save(java.lang.String)
+	 */
+	public void save(File output) throws ArchiveException {
+		if(output == null) {
+			throw new ArchiveException("Destination directory must not be null.");
+		}
+		try {
+			this.save(new FileOutputStream(output));
+		} catch (FileNotFoundException e) {
+			throw new ArchiveException("This path is not writeable", e);
+		}
+		this.setArchive(output);
+	}
+	
+	/* (non-Javadoc)
+	 * @see org.apache.commons.compress.Archive#save(java.io.FileOutputStream)
+	 */
+	public void save(FileOutputStream output) throws ArchiveException {
+		doSave(output);
+	}
+	
+	/**
+	 * Specific implementation of the save opteration. 
+	 * @param output - stream to archive to
+	 * @throws ArchiveException 
+	 */
+	protected abstract void doSave(FileOutputStream output) throws ArchiveException;
+	
+	/* (non-Javadoc)
+	 * @see org.apache.commons.compress.Archive#getArchive()
+	 */
+	public File getArchive() {
+		return this.archive;
+	}
+	
+	/* (non-Javadoc)
+	 * @see org.apache.commons.compress.Archive#setArchive(java.io.File)
+	 */
+	public void setArchive(File file) {
+		// TODO: when an archive is set, it's files must be added to the
+		// internal file list for possible delete operations
+		this.archive = file;
+	}
+
+	/* (non-Javadoc)
+	 * @see org.apache.commons.compress.Archive#add(java.io.File)
+	 */
+	public void add(File file) throws FileNotFoundException {
+		InputStream is = new FileInputStream(file);
+		ArchiveEntry archiveEntry = new ArchiveEntry(file.getName(), is);
+		entries.add( archiveEntry );
+	}
+
+	/* (non-Javadoc)
+	 * @see org.apache.commons.compress.Archive#add(java.io.InputStream)
+	 */
+	public void add(ArchiveEntry archiveEntry) {
+		entries.add( archiveEntry );
+	}
+	
+	/* (non-Javadoc)
+	 * @see org.apache.commons.compress.Archive#getPackFilesIterator()
+	 */
+	public Iterator getEntryIterator() {
+		return this.entries.iterator(); 
+	}
+
+	/* (non-Javadoc)
+	 * @see org.apache.commons.compress.Archive#unpack(java.lang.String)
+	 */
+	public void unpack(File unpackDir) throws UnpackException {
+		if(unpackDir == null) {
+			throw new UnpackException("Destination directory must not be null.");
+		}
+		if(!unpackDir.isDirectory()) {
+			throw new UnpackException("This file must be a valid directory.");
+		}
+		if(!unpackDir.canWrite()) {
+			throw new UnpackException("This path is not writeable");
+		}
+		doUnpack(unpackDir);
+	}
+	
+	/**
+	 * Specific implementation of the unpack opteration. 
+	 * @param unpackDir dir, to unpack to
+	 * @throws UnpackException 
+	 */
+	protected abstract void doUnpack(File unpackDir) throws UnpackException;
+	
+	/* (non-Javadoc)
+	 * @see org.apache.commons.compress.Archive#close()
+	 */
+	public void close() throws IOException {
+		Iterator it = getEntryIterator();
+		while(it.hasNext()) {
+			ArchiveEntry ae = (ArchiveEntry)it.next();
+			InputStream is = ae.getStream();
+			is.close();
+		}
+	}
+}
\ No newline at end of file

Propchange: jakarta/commons/sandbox/compress/trunk/src/java/org/apache/commons/compress/AbstractArchive.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: jakarta/commons/sandbox/compress/trunk/src/java/org/apache/commons/compress/AbstractArchive.java
------------------------------------------------------------------------------
    svn:executable = *

Propchange: jakarta/commons/sandbox/compress/trunk/src/java/org/apache/commons/compress/AbstractArchive.java
------------------------------------------------------------------------------
    svn:keywords = "Author Date Id Revision"

Added: jakarta/commons/sandbox/compress/trunk/src/java/org/apache/commons/compress/ArchiveEntry.java
URL: http://svn.apache.org/viewvc/jakarta/commons/sandbox/compress/trunk/src/java/org/apache/commons/compress/ArchiveEntry.java?rev=427072&view=auto
==============================================================================
--- jakarta/commons/sandbox/compress/trunk/src/java/org/apache/commons/compress/ArchiveEntry.java (added)
+++ jakarta/commons/sandbox/compress/trunk/src/java/org/apache/commons/compress/ArchiveEntry.java Mon Jul 31 03:55:10 2006
@@ -0,0 +1,61 @@
+/*
+ * Copyright 2002,2004 The Apache Software Foundation.
+ * 
+ * Licensed 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;
+
+import java.io.InputStream;
+/**
+ * Represents an entry of an archive.
+ */
+public class ArchiveEntry {
+	/* Name of this entry */
+	private String name = null;
+	/* name of this entry stream */
+	private InputStream stream = null;
+	
+	/*
+	 * Should only called with parameters 
+	 */
+	private ArchiveEntry() {
+		// unused
+	}
+	
+	/**
+	 * Constructs a new ArchiveEntry with name and stram
+	 * @param name the name of this entry
+	 * @param stream the inputstream of this entry
+	 */
+	public ArchiveEntry(String entryName, InputStream entryStream) {
+		super();
+		this.name = entryName;
+		this.stream = entryStream;
+	}
+	
+	/**
+	 * Returns this entries name
+	 * @return name of this entry
+	 */
+	public String getName() {
+		return name;
+	}
+	
+	/**
+	 * Returns this entries InputStream stream
+	 * @return InputStream of this entry
+	 */
+	public InputStream getStream() {
+		return stream;
+	}
+}
\ No newline at end of file

Propchange: jakarta/commons/sandbox/compress/trunk/src/java/org/apache/commons/compress/ArchiveEntry.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: jakarta/commons/sandbox/compress/trunk/src/java/org/apache/commons/compress/ArchiveEntry.java
------------------------------------------------------------------------------
    svn:executable = *

Propchange: jakarta/commons/sandbox/compress/trunk/src/java/org/apache/commons/compress/ArchiveEntry.java
------------------------------------------------------------------------------
    svn:keywords = "Author Date Id Revision"

Added: jakarta/commons/sandbox/compress/trunk/src/java/org/apache/commons/compress/ArchiveException.java
URL: http://svn.apache.org/viewvc/jakarta/commons/sandbox/compress/trunk/src/java/org/apache/commons/compress/ArchiveException.java?rev=427072&view=auto
==============================================================================
--- jakarta/commons/sandbox/compress/trunk/src/java/org/apache/commons/compress/ArchiveException.java (added)
+++ jakarta/commons/sandbox/compress/trunk/src/java/org/apache/commons/compress/ArchiveException.java Mon Jul 31 03:55:10 2006
@@ -0,0 +1,53 @@
+/*
+ * Copyright 2002,2004 The Apache Software Foundation.
+ * 
+ * Licensed 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;
+/**
+ * Exception for the archiver. 
+ */
+public class ArchiveException extends PackableObjectException {
+	/**
+	 * Comment for <code>serialVersionUID</code>
+	 */
+	private static final long serialVersionUID = 3256440322136748848L;
+
+	/**
+	 * Calls the IOException constructor
+	 */
+	public ArchiveException() {
+		super();
+	}
+
+	/**
+	 * Calls the super constructor with a message
+	 * @param message the message
+	 */
+	public ArchiveException(String message) {
+		super(message);
+	}
+	
+	/**
+	 * Calls the super constructor with a message
+	 * and fills the stacktrace with the stacktrace of 
+	 * an exception
+	 * 
+	 * @param message the message
+	 * @param e the exception 
+	 */
+	public ArchiveException(String message, Exception e) {
+		super(message);
+		this.initCause(e);
+	}
+}

Propchange: jakarta/commons/sandbox/compress/trunk/src/java/org/apache/commons/compress/ArchiveException.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: jakarta/commons/sandbox/compress/trunk/src/java/org/apache/commons/compress/ArchiveException.java
------------------------------------------------------------------------------
    svn:executable = *

Propchange: jakarta/commons/sandbox/compress/trunk/src/java/org/apache/commons/compress/ArchiveException.java
------------------------------------------------------------------------------
    svn:keywords = "Author Date Id Revision"

Added: jakarta/commons/sandbox/compress/trunk/src/java/org/apache/commons/compress/PackableObjectException.java
URL: http://svn.apache.org/viewvc/jakarta/commons/sandbox/compress/trunk/src/java/org/apache/commons/compress/PackableObjectException.java?rev=427072&view=auto
==============================================================================
--- jakarta/commons/sandbox/compress/trunk/src/java/org/apache/commons/compress/PackableObjectException.java (added)
+++ jakarta/commons/sandbox/compress/trunk/src/java/org/apache/commons/compress/PackableObjectException.java Mon Jul 31 03:55:10 2006
@@ -0,0 +1,53 @@
+/*
+ * Copyright 2002,2004 The Apache Software Foundation.
+ * 
+ * Licensed 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;
+/**
+ * Exception for the archiver. 
+ */
+public class PackableObjectException extends Exception {
+	/**
+	 * Comment for <code>serialVersionUID</code>
+	 */
+	private static final long serialVersionUID = 3904960871745534257L;
+
+	/**
+	 * Calls the IOException constructor
+	 */
+	public PackableObjectException() {
+		super();
+	}
+
+	/**
+	 * Calls the super constructor with a message
+	 * @param message the message
+	 */
+	public PackableObjectException(String message) {
+		super(message);
+	}
+	
+	/**
+	 * Calls the super constructor with a message
+	 * and fills the stacktrace with the stacktrace of 
+	 * an exception
+	 * 
+	 * @param message the message
+	 * @param e the exception 
+	 */
+	public PackableObjectException(String message, Exception e) {
+		super(message);
+		this.initCause(e);
+	}
+}

Propchange: jakarta/commons/sandbox/compress/trunk/src/java/org/apache/commons/compress/PackableObjectException.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: jakarta/commons/sandbox/compress/trunk/src/java/org/apache/commons/compress/PackableObjectException.java
------------------------------------------------------------------------------
    svn:executable = *

Propchange: jakarta/commons/sandbox/compress/trunk/src/java/org/apache/commons/compress/PackableObjectException.java
------------------------------------------------------------------------------
    svn:keywords = "Author Date Id Revision"

Added: jakarta/commons/sandbox/compress/trunk/src/java/org/apache/commons/compress/UnpackException.java
URL: http://svn.apache.org/viewvc/jakarta/commons/sandbox/compress/trunk/src/java/org/apache/commons/compress/UnpackException.java?rev=427072&view=auto
==============================================================================
--- jakarta/commons/sandbox/compress/trunk/src/java/org/apache/commons/compress/UnpackException.java (added)
+++ jakarta/commons/sandbox/compress/trunk/src/java/org/apache/commons/compress/UnpackException.java Mon Jul 31 03:55:10 2006
@@ -0,0 +1,55 @@
+/*
+ * Copyright 2002,2004 The Apache Software Foundation.
+ * 
+ * Licensed 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;
+
+/**
+ * Exception occurs when a exception within 
+ * the unpack actions occurs.
+ */
+public class UnpackException  extends ArchiveException {
+	/**
+	 * Comment for <code>serialVersionUID</code>
+	 */
+	private static final long serialVersionUID = 3906647522633135668L;
+
+	/**
+	 * Calls the super constructor
+	 */
+	public UnpackException() {
+		super();
+	}
+
+	/**
+	 * Calls the super constructor with a message
+	 * @param message the message
+	 */
+	public UnpackException(String message) {
+		super(message);
+	}
+	
+	/**
+	 * Calls the super constructor with a message
+	 * and fills the stacktrace with the stacktrace of 
+	 * an exception
+	 * 
+	 * @param message the message
+	 * @param e the exception 
+	 */
+	public UnpackException(String message, Exception e) {
+		super(message);
+		this.initCause(e);
+	}
+}

Propchange: jakarta/commons/sandbox/compress/trunk/src/java/org/apache/commons/compress/UnpackException.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: jakarta/commons/sandbox/compress/trunk/src/java/org/apache/commons/compress/UnpackException.java
------------------------------------------------------------------------------
    svn:executable = *

Propchange: jakarta/commons/sandbox/compress/trunk/src/java/org/apache/commons/compress/UnpackException.java
------------------------------------------------------------------------------
    svn:keywords = "Author Date Id Revision"

Added: jakarta/commons/sandbox/compress/trunk/src/java/org/apache/commons/compress/archivers/tar/TarArchive.java
URL: http://svn.apache.org/viewvc/jakarta/commons/sandbox/compress/trunk/src/java/org/apache/commons/compress/archivers/tar/TarArchive.java?rev=427072&view=auto
==============================================================================
--- jakarta/commons/sandbox/compress/trunk/src/java/org/apache/commons/compress/archivers/tar/TarArchive.java (added)
+++ jakarta/commons/sandbox/compress/trunk/src/java/org/apache/commons/compress/archivers/tar/TarArchive.java Mon Jul 31 03:55:10 2006
@@ -0,0 +1,192 @@
+/*
+ * Copyright 2002,2004 The Apache Software Foundation.
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.commons.compress.archivers.tar;
+
+import java.io.BufferedInputStream;
+import java.io.BufferedOutputStream;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileNotFoundException;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.Iterator;
+
+import org.apache.commons.compress.AbstractArchive;
+import org.apache.commons.compress.ArchiveEntry;
+import org.apache.commons.compress.ArchiveException;
+import org.apache.commons.compress.UnpackException;
+
+/**
+ * Archive-Implementation for Tar.
+ * An tar archive has no header. This means, that the 
+ * ArchiverFactory.getInstance( new File("file.tar")) Method
+ * cannot be used.
+ */
+public class TarArchive extends AbstractArchive {
+
+	/* Buffer for the file operations */
+	private static final int BUFFER = 2048;
+
+	/**
+	 * DEFAULT_FILE_EXTENSION Field for this archiver.
+	 */
+	public final static String DEFAULT_FILE_EXTENSION = "tar";
+
+	/**
+	 * ARCHIVER_NAME Field for this archiver.
+	 */
+	private final static String ARCHIVER_NAME = "tar";
+	
+	/**
+	 * This Archive should be instantiated in the Archive-Interface.
+	 */
+	public TarArchive() {
+		// Empty
+	}
+	
+	/* (non-Javadoc)
+	 * @see org.apache.commons.compress.Archive#unpack()
+	 */
+	protected void doUnpack(File unpackDir) throws UnpackException {
+		FileInputStream fInputStream = null;
+		TarInputStream zInputStream = null;
+		
+		try {
+			fInputStream = new FileInputStream(this.getArchive());
+			zInputStream = new TarInputStream(new BufferedInputStream(fInputStream));
+		} catch(FileNotFoundException e) {
+			throw new UnpackException("SourceFile could not be found.", e);
+		}
+		
+		try {
+			TarEntry entry = null;
+			
+			while((entry = zInputStream.getNextEntry()) != null) {
+				BufferedOutputStream destination = null;
+				
+				int count;
+				byte data[] = new byte[BUFFER];
+
+				String filename = "";
+				File f = new File(entry.getName());
+				if(f.isAbsolute()) {
+					filename = entry.getName().substring(3);
+				} else {
+					filename = entry.getName();
+				}
+				
+				String fosString = unpackDir.getPath() + File.separator + filename;
+				File destFile = new File(fosString);
+				File destPath = new File(destFile.getParent());
+				destPath.mkdirs();
+				
+				FileOutputStream fos = new FileOutputStream(destFile);
+				try {
+					destination = new BufferedOutputStream(fos, BUFFER);
+					
+					while((count = zInputStream.read(data, 0, BUFFER))!= -1) {
+						destination.write(data, 0, count);
+					}
+					destination.flush();
+				} finally {
+					destination.close();
+				}
+			}
+		} catch(IOException e) {
+			throw new UnpackException("Exception while unpacking.", e);
+		} finally {
+			try {
+				fInputStream.close();
+			} catch (IOException e1) {
+				throw new UnpackException("Exception while unpacking.", e1);
+			}
+		}
+	}
+	
+	/* (non-Javadoc)
+	 * @see org.apache.commons.compress.AbstractArchive#doSave(java.io.FileOutputStream)
+	 */
+	public void doSave(FileOutputStream output) throws ArchiveException {
+		// Stream initializing
+		BufferedInputStream origin = null;
+		
+		//out.setMethod(ZipOutputStream.DEFLATED);
+		byte data[] = new byte[BUFFER];
+		
+		// get a list of files from current directory
+		// less than one file leads to an exception
+		Iterator iterator = this.getEntryIterator();
+		if(!iterator.hasNext()) {
+			throw new ArchiveException("There must be at least one file to be pack.");
+		}
+		
+		// Pack-Operation
+		TarOutputStream out = null;
+		
+		try {
+			out = new TarOutputStream(new BufferedOutputStream(output));
+			while(iterator.hasNext()) {
+
+				ArchiveEntry archiveEntry = (ArchiveEntry)iterator.next();
+				InputStream fInputStream = archiveEntry.getStream();
+
+				TarEntry entry = new TarEntry(archiveEntry.getName());
+				entry.setModTime( 0 );
+		        entry.setSize( fInputStream.available() );
+		        entry.setUserID( 0 );
+		        entry.setGroupID( 0 );
+		        entry.setUserName( "avalon" );
+		        entry.setGroupName( "excalibur" );
+		        entry.setMode( 0100000 );
+		        out.putNextEntry( entry );
+		        
+		        out.copyEntryContents( fInputStream );
+		        out.closeEntry();
+			}
+		} catch (IOException e) {
+			throw new ArchiveException("Creation of this archive failed cause of IOExceptions.", e);
+		} finally {
+			try {
+				out.close();
+			} catch (IOException e1) {
+				throw new ArchiveException("Creation of this archive failed cause of IOExceptions.", e1);
+			}
+		}
+	}
+
+	/* (non-Javadoc)
+	 * @see org.apache.commons.compress.Archive#getArchiverName()
+	 */
+	public String getName() {
+		return ARCHIVER_NAME;
+	}
+
+	/* (non-Javadoc)
+	 * @see org.apache.commons.compress.Archive#getDefaultFileExtension()
+	 */
+	public String getDefaultFileExtension() {
+		return DEFAULT_FILE_EXTENSION;
+	}
+
+	/* (non-Javadoc)
+	 * @see org.apache.commons.compress.Archive#getHeader()
+	 */
+	public byte[] getHeader() {
+		// tar's have no specific header
+		return null;
+	}
+}
\ No newline at end of file

Propchange: jakarta/commons/sandbox/compress/trunk/src/java/org/apache/commons/compress/archivers/tar/TarArchive.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: jakarta/commons/sandbox/compress/trunk/src/java/org/apache/commons/compress/archivers/tar/TarArchive.java
------------------------------------------------------------------------------
    svn:executable = *

Propchange: jakarta/commons/sandbox/compress/trunk/src/java/org/apache/commons/compress/archivers/tar/TarArchive.java
------------------------------------------------------------------------------
    svn:keywords = "Author Date Id Revision"

Added: jakarta/commons/sandbox/compress/trunk/src/java/org/apache/commons/compress/archivers/tar/TarBuffer.java
URL: http://svn.apache.org/viewvc/jakarta/commons/sandbox/compress/trunk/src/java/org/apache/commons/compress/archivers/tar/TarBuffer.java?rev=427072&view=auto
==============================================================================
--- jakarta/commons/sandbox/compress/trunk/src/java/org/apache/commons/compress/archivers/tar/TarBuffer.java (added)
+++ jakarta/commons/sandbox/compress/trunk/src/java/org/apache/commons/compress/archivers/tar/TarBuffer.java Mon Jul 31 03:55:10 2006
@@ -0,0 +1,497 @@
+/*
+ * Copyright 2002,2004 The Apache Software Foundation.
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.commons.compress.archivers.tar;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+
+/**
+ * The TarBuffer class implements the tar archive concept of a buffered input
+ * stream. This concept goes back to the days of blocked tape drives and special
+ * io devices. In the Java universe, the only real function that this class
+ * performs is to ensure that files have the correct "block" size, or other tars
+ * will complain. <p>
+ *
+ * You should never have a need to access this class directly. TarBuffers are
+ * created by Tar IO Streams.
+ *
+ * @author <a href="mailto:time@ice.com">Timothy Gerard Endres</a>
+ * @author <a href="mailto:peter@apache.org">Peter Donald</a>
+ * @version $Revision: 155439 $ $Date$
+ */
+public class TarBuffer
+{
+    public static final int DEFAULT_RECORDSIZE = ( 512 );
+    public static final int DEFAULT_BLOCKSIZE = ( DEFAULT_RECORDSIZE * 20 );
+
+    private byte[] m_blockBuffer;
+    private int m_blockSize;
+    private int m_currBlkIdx;
+    private int m_currRecIdx;
+    private boolean m_debug;
+
+    private InputStream m_input;
+    private OutputStream m_output;
+    private int m_recordSize;
+    private int m_recsPerBlock;
+
+    public TarBuffer( final InputStream input )
+    {
+        this( input, TarBuffer.DEFAULT_BLOCKSIZE );
+    }
+
+    public TarBuffer( final InputStream input, final int blockSize )
+    {
+        this( input, blockSize, TarBuffer.DEFAULT_RECORDSIZE );
+    }
+
+    public TarBuffer( final InputStream input,
+                      final int blockSize,
+                      final int recordSize )
+    {
+        m_input = input;
+        initialize( blockSize, recordSize );
+    }
+
+    public TarBuffer( final OutputStream output )
+    {
+        this( output, TarBuffer.DEFAULT_BLOCKSIZE );
+    }
+
+    public TarBuffer( final OutputStream output, final int blockSize )
+    {
+        this( output, blockSize, TarBuffer.DEFAULT_RECORDSIZE );
+    }
+
+    public TarBuffer( final OutputStream output,
+                      final int blockSize,
+                      final int recordSize )
+    {
+        m_output = output;
+        initialize( blockSize, recordSize );
+    }
+
+    /**
+     * Set the debugging flag for the buffer.
+     *
+     * @param debug If true, print debugging output.
+     */
+    public void setDebug( final boolean debug )
+    {
+        m_debug = debug;
+    }
+
+    /**
+     * Get the TAR Buffer's block size. Blocks consist of multiple records.
+     *
+     * @return The BlockSize value
+     */
+    public int getBlockSize()
+    {
+        return m_blockSize;
+    }
+
+    /**
+     * Get the current block number, zero based.
+     *
+     * @return The current zero based block number.
+     */
+    public int getCurrentBlockNum()
+    {
+        return m_currBlkIdx;
+    }
+
+    /**
+     * Get the current record number, within the current block, zero based.
+     * Thus, current offset = (currentBlockNum * recsPerBlk) + currentRecNum.
+     *
+     * @return The current zero based record number.
+     */
+    public int getCurrentRecordNum()
+    {
+        return m_currRecIdx - 1;
+    }
+
+    /**
+     * Get the TAR Buffer's record size.
+     *
+     * @return The RecordSize value
+     */
+    public int getRecordSize()
+    {
+        return m_recordSize;
+    }
+
+    /**
+     * Determine if an archive record indicate End of Archive. End of archive is
+     * indicated by a record that consists entirely of null bytes.
+     *
+     * @param record The record data to check.
+     * @return The EOFRecord value
+     */
+    public boolean isEOFRecord( final byte[] record )
+    {
+        final int size = getRecordSize();
+        for( int i = 0; i < size; ++i )
+        {
+            if( record[ i ] != 0 )
+            {
+                return false;
+            }
+        }
+
+        return true;
+    }
+
+    /**
+     * Close the TarBuffer. If this is an output buffer, also flush the current
+     * block before closing.
+     */
+    public void close()
+        throws IOException
+    {
+        if( m_debug )
+        {
+            debug( "TarBuffer.closeBuffer()." );
+        }
+
+        if( null != m_output )
+        {
+            flushBlock();
+
+            if( m_output != System.out && m_output != System.err )
+            {
+                m_output.close();
+                m_output = null;
+            }
+        }
+        else if( m_input != null )
+        {
+            if( m_input != System.in )
+            {
+                m_input.close();
+                m_input = null;
+            }
+        }
+    }
+
+    /**
+     * Read a record from the input stream and return the data.
+     *
+     * @return The record data.
+     * @exception IOException Description of Exception
+     */
+    public byte[] readRecord()
+        throws IOException
+    {
+        if( m_debug )
+        {
+            final String message = "ReadRecord: recIdx = " + m_currRecIdx +
+                " blkIdx = " + m_currBlkIdx;
+            debug( message );
+        }
+
+        if( null == m_input )
+        {
+            final String message = "reading from an output buffer";
+            throw new IOException( message );
+        }
+
+        if( m_currRecIdx >= m_recsPerBlock )
+        {
+            if( !readBlock() )
+            {
+                return null;
+            }
+        }
+
+        final byte[] result = new byte[ m_recordSize ];
+        System.arraycopy( m_blockBuffer,
+                          ( m_currRecIdx * m_recordSize ),
+                          result,
+                          0,
+                          m_recordSize );
+
+        m_currRecIdx++;
+
+        return result;
+    }
+
+    /**
+     * Skip over a record on the input stream.
+     */
+    public void skipRecord()
+        throws IOException
+    {
+        if( m_debug )
+        {
+            final String message = "SkipRecord: recIdx = " + m_currRecIdx +
+                " blkIdx = " + m_currBlkIdx;
+            debug( message );
+        }
+
+        if( null == m_input )
+        {
+            final String message = "reading (via skip) from an output buffer";
+            throw new IOException( message );
+        }
+
+        if( m_currRecIdx >= m_recsPerBlock )
+        {
+            if( !readBlock() )
+            {
+                return;// UNDONE
+            }
+        }
+
+        m_currRecIdx++;
+    }
+
+    /**
+     * Write an archive record to the archive.
+     *
+     * @param record The record data to write to the archive.
+     */
+    public void writeRecord( final byte[] record )
+        throws IOException
+    {
+        if( m_debug )
+        {
+            final String message = "WriteRecord: recIdx = " + m_currRecIdx +
+                " blkIdx = " + m_currBlkIdx;
+            debug( message );
+        }
+
+        if( null == m_output )
+        {
+            final String message = "writing to an input buffer";
+            throw new IOException( message );
+        }
+
+        if( record.length != m_recordSize )
+        {
+            final String message = "record to write has length '" +
+                record.length + "' which is not the record size of '" +
+                m_recordSize + "'";
+            throw new IOException( message );
+        }
+
+        if( m_currRecIdx >= m_recsPerBlock )
+        {
+            writeBlock();
+        }
+
+        System.arraycopy( record,
+                          0,
+                          m_blockBuffer,
+                          ( m_currRecIdx * m_recordSize ),
+                          m_recordSize );
+
+        m_currRecIdx++;
+    }
+
+    /**
+     * Write an archive record to the archive, where the record may be inside of
+     * a larger array buffer. The buffer must be "offset plus record size" long.
+     *
+     * @param buffer The buffer containing the record data to write.
+     * @param offset The offset of the record data within buf.
+     */
+    public void writeRecord( final byte[] buffer, final int offset )
+        throws IOException
+    {
+        if( m_debug )
+        {
+            final String message = "WriteRecord: recIdx = " + m_currRecIdx +
+                " blkIdx = " + m_currBlkIdx;
+            debug( message );
+        }
+
+        if( null == m_output )
+        {
+            final String message = "writing to an input buffer";
+            throw new IOException( message );
+        }
+
+        if( ( offset + m_recordSize ) > buffer.length )
+        {
+            final String message = "record has length '" + buffer.length +
+                "' with offset '" + offset + "' which is less than the record size of '" +
+                m_recordSize + "'";
+            throw new IOException( message );
+        }
+
+        if( m_currRecIdx >= m_recsPerBlock )
+        {
+            writeBlock();
+        }
+
+        System.arraycopy( buffer,
+                          offset,
+                          m_blockBuffer,
+                          ( m_currRecIdx * m_recordSize ),
+                          m_recordSize );
+
+        m_currRecIdx++;
+    }
+
+    /**
+     * Flush the current data block if it has any data in it.
+     */
+    private void flushBlock()
+        throws IOException
+    {
+        if( m_debug )
+        {
+            final String message = "TarBuffer.flushBlock() called.";
+            debug( message );
+        }
+
+        if( m_output == null )
+        {
+            final String message = "writing to an input buffer";
+            throw new IOException( message );
+        }
+
+        if( m_currRecIdx > 0 )
+        {
+            writeBlock();
+        }
+    }
+
+    /**
+     * Initialization common to all constructors.
+     */
+    private void initialize( final int blockSize, final int recordSize )
+    {
+        m_debug = false;
+        m_blockSize = blockSize;
+        m_recordSize = recordSize;
+        m_recsPerBlock = ( m_blockSize / m_recordSize );
+        m_blockBuffer = new byte[ m_blockSize ];
+
+        if( null != m_input )
+        {
+            m_currBlkIdx = -1;
+            m_currRecIdx = m_recsPerBlock;
+        }
+        else
+        {
+            m_currBlkIdx = 0;
+            m_currRecIdx = 0;
+        }
+    }
+
+    /**
+     * @return false if End-Of-File, else true
+     */
+    private boolean readBlock()
+        throws IOException
+    {
+        if( m_debug )
+        {
+            final String message = "ReadBlock: blkIdx = " + m_currBlkIdx;
+            debug( message );
+        }
+
+        if( null == m_input )
+        {
+            final String message = "reading from an output buffer";
+            throw new IOException( message );
+        }
+
+        m_currRecIdx = 0;
+
+        int offset = 0;
+        int bytesNeeded = m_blockSize;
+
+        while( bytesNeeded > 0 )
+        {
+            final long numBytes = m_input.read( m_blockBuffer, offset, bytesNeeded );
+
+            //
+            // NOTE
+            // We have fit EOF, and the block is not full!
+            //
+            // This is a broken archive. It does not follow the standard
+            // blocking algorithm. However, because we are generous, and
+            // it requires little effort, we will simply ignore the error
+            // and continue as if the entire block were read. This does
+            // not appear to break anything upstream. We used to return
+            // false in this case.
+            //
+            // Thanks to 'Yohann.Roussel@alcatel.fr' for this fix.
+            //
+            if( numBytes == -1 )
+            {
+                break;
+            }
+
+            offset += numBytes;
+            bytesNeeded -= numBytes;
+
+            if( numBytes != m_blockSize )
+            {
+                if( m_debug )
+                {
+                    System.err.println( "ReadBlock: INCOMPLETE READ "
+                                        + numBytes + " of " + m_blockSize
+                                        + " bytes read." );
+                }
+            }
+        }
+
+        m_currBlkIdx++;
+
+        return true;
+    }
+
+    /**
+     * Write a TarBuffer block to the archive.
+     *
+     * @exception IOException Description of Exception
+     */
+    private void writeBlock()
+        throws IOException
+    {
+        if( m_debug )
+        {
+            final String message = "WriteBlock: blkIdx = " + m_currBlkIdx;
+            debug( message );
+        }
+
+        if( null == m_output )
+        {
+            final String message = "writing to an input buffer";
+            throw new IOException( message );
+        }
+
+        m_output.write( m_blockBuffer, 0, m_blockSize );
+        m_output.flush();
+
+        m_currRecIdx = 0;
+        m_currBlkIdx++;
+    }
+
+    protected void debug( final String message )
+    {
+        if( m_debug )
+        {
+            System.err.println( message );
+        }
+    }
+}

Propchange: jakarta/commons/sandbox/compress/trunk/src/java/org/apache/commons/compress/archivers/tar/TarBuffer.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: jakarta/commons/sandbox/compress/trunk/src/java/org/apache/commons/compress/archivers/tar/TarBuffer.java
------------------------------------------------------------------------------
    svn:executable = *

Propchange: jakarta/commons/sandbox/compress/trunk/src/java/org/apache/commons/compress/archivers/tar/TarBuffer.java
------------------------------------------------------------------------------
    svn:keywords = "Author Date Id Revision"



---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org


Mime
View raw message