Author: sebb
Date: Sun May 23 11:53:07 2010
New Revision: 947399
URL: http://svn.apache.org/viewvc?rev=947399&view=rev
Log:
COMPRESS-108: add initial implementation of command-line interface to list
archive contents
Added:
commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/Lister.java
(with props)
Modified:
commons/proper/compress/trunk/RELEASE-NOTES.txt
commons/proper/compress/trunk/pom.xml
commons/proper/compress/trunk/src/changes/changes.xml
Modified: commons/proper/compress/trunk/RELEASE-NOTES.txt
URL:
http://svn.apache.org/viewvc/commons/proper/compress/trunk/RELEASE-NOTES.txt?rev=947399&r1=947398&r2=947399&view=diff
==============================================================================
--- commons/proper/compress/trunk/RELEASE-NOTES.txt (original)
+++ commons/proper/compress/trunk/RELEASE-NOTES.txt Sun May 23 11:53:07 2010
@@ -77,6 +77,8 @@ o The ar and cpio streams now properly r
o COMPRESS-81: TarOutputStream can leave garbage at the end of the archive
Changes:
+o COMPRESS-108: Command-line interface to list archive contents.
+ Usage: java -jar commons-compress-n.m.jar archive-name [zip|tar|etc]
o COMPRESS-112: ArArchiveInputStream does not handle GNU extended filename
records (//)
o COMPRESS-109: Tar implementation does not support Pax headers
Added support for reading pax headers.
Modified: commons/proper/compress/trunk/pom.xml
URL:
http://svn.apache.org/viewvc/commons/proper/compress/trunk/pom.xml?rev=947399&r1=947398&r2=947399&view=diff
==============================================================================
--- commons/proper/compress/trunk/pom.xml (original)
+++ commons/proper/compress/trunk/pom.xml Sun May 23 11:53:07 2010
@@ -132,6 +132,16 @@
</archive>
</configuration>
</plugin>
+ <plugin>
+ <artifactId>maven-jar-plugin</artifactId>
+ <configuration>
+ <archive>
+ <manifestEntries>
+
<Main-Class>org.apache.commons.compress.archivers.Lister</Main-Class>
+ </manifestEntries>
+ </archive>
+ </configuration>
+ </plugin>
</plugins>
</build>
Modified: commons/proper/compress/trunk/src/changes/changes.xml
URL:
http://svn.apache.org/viewvc/commons/proper/compress/trunk/src/changes/changes.xml?rev=947399&r1=947398&r2=947399&view=diff
==============================================================================
--- commons/proper/compress/trunk/src/changes/changes.xml (original)
+++ commons/proper/compress/trunk/src/changes/changes.xml Sun May 23 11:53:07
2010
@@ -45,6 +45,10 @@ The <action> type attribute can be add,u
</properties>
<body>
<release version="1.1" date="as in SVN" description="Release 1.1">
+ <action issue="COMPRESS-108" type="update" date="2010-05-23">
+ Command-line interface to list archive contents.
+ Usage: java -jar commons-compress-n.m.jar archive-name [zip|tar|etc]
+ </action>
<action issue="COMPRESS-118" type="fix" date="2010-05-17">
TarUtils.parseName does not properly handle characters outside the
range 0-127
</action>
Added:
commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/Lister.java
URL:
http://svn.apache.org/viewvc/commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/Lister.java?rev=947399&view=auto
==============================================================================
---
commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/Lister.java
(added)
+++
commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/Lister.java
Sun May 23 11:53:07 2010
@@ -0,0 +1,63 @@
+/*
+ * 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;
+
+import java.io.BufferedInputStream;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.InputStream;
+
+import org.apache.commons.compress.archivers.ArchiveEntry;
+import org.apache.commons.compress.archivers.ArchiveInputStream;
+import org.apache.commons.compress.archivers.ArchiveStreamFactory;
+
+/**
+ * Simple command line application that lists the contents of an archive.
+ *
+ * <p>The name of the archive must be given as a command line argument.</p>
+ * <p>The optional second argument defines the archive type, in case the
format is not recognised.</p>
+ *
+ * @since Apache Commons Compress 1.1
+ */
+public final class Lister {
+ private static final ArchiveStreamFactory factory = new
ArchiveStreamFactory();
+
+ public static void main(String[] args) throws Exception {
+ System.out.println("Analysing "+args[0]);
+ File f = new File(args[0]);
+ if (!f.isFile()) {
+ System.err.println(f + " doesn't exist or is a directory");
+ }
+ InputStream fis = new BufferedInputStream(new FileInputStream(f));
+ ArchiveInputStream ais;
+ if (args.length > 1) {
+ ais = factory.createArchiveInputStream(args[1], fis);
+ } else {
+ ais = factory.createArchiveInputStream(fis);
+ }
+ System.out.println("Created "+ais.toString());
+ ArchiveEntry ae;
+ while((ae=ais.getNextEntry()) != null){
+ System.out.println(ae.getName());
+ }
+ ais.close();
+ fis.close();
+ }
+
+}
\ No newline at end of file
Propchange:
commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/Lister.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange:
commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/Lister.java
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision