commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tcu...@apache.org
Subject svn commit: r732334 - in /commons/sandbox/compress/trunk/src: main/java/org/apache/commons/compress/archivers/ main/java/org/apache/commons/compress/archivers/ar/ main/java/org/apache/commons/compress/archivers/jar/ test/java/org/apache/commons/compres...
Date Wed, 07 Jan 2009 13:48:43 GMT
Author: tcurdt
Date: Wed Jan  7 05:48:42 2009
New Revision: 732334

URL: http://svn.apache.org/viewvc?rev=732334&view=rev
Log:
applied patches from Tim Pinet

https://issues.apache.org/jira/browse/SANDBOX-259
https://issues.apache.org/jira/browse/SANDBOX-258


Modified:
    commons/sandbox/compress/trunk/src/main/java/org/apache/commons/compress/archivers/ArchiveEntry.java
    commons/sandbox/compress/trunk/src/main/java/org/apache/commons/compress/archivers/ar/ArArchiveEntry.java
    commons/sandbox/compress/trunk/src/main/java/org/apache/commons/compress/archivers/jar/JarArchiveInputStream.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/TarTestCase.java
    commons/sandbox/compress/trunk/src/test/java/org/apache/commons/compress/archivers/memory/MemoryArchiveEntry.java

Modified: commons/sandbox/compress/trunk/src/main/java/org/apache/commons/compress/archivers/ArchiveEntry.java
URL: http://svn.apache.org/viewvc/commons/sandbox/compress/trunk/src/main/java/org/apache/commons/compress/archivers/ArchiveEntry.java?rev=732334&r1=732333&r2=732334&view=diff
==============================================================================
--- commons/sandbox/compress/trunk/src/main/java/org/apache/commons/compress/archivers/ArchiveEntry.java
(original)
+++ commons/sandbox/compress/trunk/src/main/java/org/apache/commons/compress/archivers/ArchiveEntry.java
Wed Jan  7 05:48:42 2009
@@ -26,4 +26,6 @@
 	public String getName();
 	
 	public long getSize();
+	
+	public boolean isDirectory();
 }

Modified: commons/sandbox/compress/trunk/src/main/java/org/apache/commons/compress/archivers/ar/ArArchiveEntry.java
URL: http://svn.apache.org/viewvc/commons/sandbox/compress/trunk/src/main/java/org/apache/commons/compress/archivers/ar/ArArchiveEntry.java?rev=732334&r1=732333&r2=732334&view=diff
==============================================================================
--- commons/sandbox/compress/trunk/src/main/java/org/apache/commons/compress/archivers/ar/ArArchiveEntry.java
(original)
+++ commons/sandbox/compress/trunk/src/main/java/org/apache/commons/compress/archivers/ar/ArArchiveEntry.java
Wed Jan  7 05:48:42 2009
@@ -69,4 +69,8 @@
 	public long getLength() {
 		return length;
 	}
+
+	public boolean isDirectory() {
+		return false;
+	}
 }

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=732334&r1=732333&r2=732334&view=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 Jan  7 05:48:42 2009
@@ -32,7 +32,12 @@
 	}
 	
 	public ArchiveEntry getNextEntry() throws IOException {
-		return (ArchiveEntry)new JarArchiveEntry((ZipArchiveEntry)super.getNextEntry());
+		ZipArchiveEntry entry = (ZipArchiveEntry)super.getNextEntry();
+		if(entry == null){
+			return null;
+		}else{
+			return (ArchiveEntry)new JarArchiveEntry(entry);
+		}
 	}
 	
 	public static boolean matches( byte[] signature ) {

Modified: commons/sandbox/compress/trunk/src/test/java/org/apache/commons/compress/archivers/JarTestCase.java
URL: http://svn.apache.org/viewvc/commons/sandbox/compress/trunk/src/test/java/org/apache/commons/compress/archivers/JarTestCase.java?rev=732334&r1=732333&r2=732334&view=diff
==============================================================================
--- commons/sandbox/compress/trunk/src/test/java/org/apache/commons/compress/archivers/JarTestCase.java
(original)
+++ commons/sandbox/compress/trunk/src/test/java/org/apache/commons/compress/archivers/JarTestCase.java
Wed Jan  7 05:48:42 2009
@@ -80,5 +80,28 @@
         
         in.close();
     }
+	
+	public void testJarUnarchiveAll() throws Exception {
+		final File input = new File(getClass().getClassLoader().getResource("bla.jar").getFile());
+        final InputStream is = new FileInputStream(input);
+        final ArchiveInputStream in = new ArchiveStreamFactory().createArchiveInputStream("jar",
is);
+        
+        ArchiveEntry entry = in.getNextEntry();
+		while (entry != null) {
+			File archiveEntry = new File(dir, entry.getName());
+			archiveEntry.getParentFile().mkdirs();
+			if(entry.isDirectory()){
+				archiveEntry.mkdir();
+				entry = in.getNextEntry();
+				continue;
+			}
+			OutputStream out = new FileOutputStream(archiveEntry);
+			IOUtils.copy(in, out);
+			out.close();
+			entry = in.getNextEntry();
+		}
+		
+		in.close();
+	}
 
 }

Modified: commons/sandbox/compress/trunk/src/test/java/org/apache/commons/compress/archivers/TarTestCase.java
URL: http://svn.apache.org/viewvc/commons/sandbox/compress/trunk/src/test/java/org/apache/commons/compress/archivers/TarTestCase.java?rev=732334&r1=732333&r2=732334&view=diff
==============================================================================
--- commons/sandbox/compress/trunk/src/test/java/org/apache/commons/compress/archivers/TarTestCase.java
(original)
+++ commons/sandbox/compress/trunk/src/test/java/org/apache/commons/compress/archivers/TarTestCase.java
Wed Jan  7 05:48:42 2009
@@ -25,8 +25,6 @@
 import java.io.InputStream;
 import java.io.OutputStream;
 
-import junit.framework.TestCase;
-
 import org.apache.commons.compress.AbstractTestCase;
 import org.apache.commons.compress.archivers.tar.TarArchiveEntry;
 import org.apache.commons.compress.utils.IOUtils;

Modified: commons/sandbox/compress/trunk/src/test/java/org/apache/commons/compress/archivers/memory/MemoryArchiveEntry.java
URL: http://svn.apache.org/viewvc/commons/sandbox/compress/trunk/src/test/java/org/apache/commons/compress/archivers/memory/MemoryArchiveEntry.java?rev=732334&r1=732333&r2=732334&view=diff
==============================================================================
--- commons/sandbox/compress/trunk/src/test/java/org/apache/commons/compress/archivers/memory/MemoryArchiveEntry.java
(original)
+++ commons/sandbox/compress/trunk/src/test/java/org/apache/commons/compress/archivers/memory/MemoryArchiveEntry.java
Wed Jan  7 05:48:42 2009
@@ -37,4 +37,9 @@
 		return 0;
 	}
 
+	public boolean isDirectory() {
+		// TODO Auto-generated method stub
+		return false;
+	}
+
 }



Mime
View raw message