ant-notifications mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bode...@apache.org
Subject svn commit: r801280 - in /ant/sandbox/antlibs/compress/trunk/src: main/org/apache/ant/compress/antlib.xml main/org/apache/ant/compress/resources/CpioResource.java tests/antunit/cpioentry-test.xml
Date Wed, 05 Aug 2009 16:00:13 GMT
Author: bodewig
Date: Wed Aug  5 16:00:13 2009
New Revision: 801280

URL: http://svn.apache.org/viewvc?rev=801280&view=rev
Log:
CpioEntry resource

Added:
    ant/sandbox/antlibs/compress/trunk/src/main/org/apache/ant/compress/resources/CpioResource.java
      - copied, changed from r801271, ant/sandbox/antlibs/compress/trunk/src/main/org/apache/ant/compress/resources/TarResource.java
    ant/sandbox/antlibs/compress/trunk/src/tests/antunit/cpioentry-test.xml
      - copied, changed from r801271, ant/sandbox/antlibs/compress/trunk/src/tests/antunit/tarentry-test.xml
Modified:
    ant/sandbox/antlibs/compress/trunk/src/main/org/apache/ant/compress/antlib.xml

Modified: ant/sandbox/antlibs/compress/trunk/src/main/org/apache/ant/compress/antlib.xml
URL: http://svn.apache.org/viewvc/ant/sandbox/antlibs/compress/trunk/src/main/org/apache/ant/compress/antlib.xml?rev=801280&r1=801279&r2=801280&view=diff
==============================================================================
--- ant/sandbox/antlibs/compress/trunk/src/main/org/apache/ant/compress/antlib.xml (original)
+++ ant/sandbox/antlibs/compress/trunk/src/main/org/apache/ant/compress/antlib.xml Wed Aug
 5 16:00:13 2009
@@ -41,4 +41,8 @@
     name="arentry"
     classname="org.apache.ant.compress.resources.ArResource"
     />
+  <typedef
+    name="cpioentry"
+    classname="org.apache.ant.compress.resources.CpioResource"
+    />
 </antlib>

Copied: ant/sandbox/antlibs/compress/trunk/src/main/org/apache/ant/compress/resources/CpioResource.java
(from r801271, ant/sandbox/antlibs/compress/trunk/src/main/org/apache/ant/compress/resources/TarResource.java)
URL: http://svn.apache.org/viewvc/ant/sandbox/antlibs/compress/trunk/src/main/org/apache/ant/compress/resources/CpioResource.java?p2=ant/sandbox/antlibs/compress/trunk/src/main/org/apache/ant/compress/resources/CpioResource.java&p1=ant/sandbox/antlibs/compress/trunk/src/main/org/apache/ant/compress/resources/TarResource.java&r1=801271&r2=801280&rev=801280&view=diff
==============================================================================
--- ant/sandbox/antlibs/compress/trunk/src/main/org/apache/ant/compress/resources/TarResource.java
(original)
+++ ant/sandbox/antlibs/compress/trunk/src/main/org/apache/ant/compress/resources/CpioResource.java
Wed Aug  5 16:00:13 2009
@@ -25,81 +25,59 @@
 import org.apache.tools.ant.types.Resource;
 import org.apache.commons.compress.archivers.ArchiveEntry;
 import org.apache.commons.compress.archivers.ArchiveInputStream;
-import org.apache.commons.compress.archivers.tar.TarArchiveEntry;
-import org.apache.commons.compress.archivers.tar.TarArchiveInputStream;
+import org.apache.commons.compress.archivers.cpio.CpioArchiveEntry;
+import org.apache.commons.compress.archivers.cpio.CpioArchiveInputStream;
 
 /**
- * A Resource representation of an entry in a tar archive.
+ * A Resource representation of an entry in a cpio archive.
  */
-public class TarResource extends CommonsCompressArchiveResource {
+public class CpioResource extends CommonsCompressArchiveResource {
 
-    private String userName = "";
-    private String groupName = "";
-    private int    uid;
-    private int    gid;
+    private long    uid;
+    private long    gid;
 
     /**
      * Default constructor.
      */
-    public TarResource() {
+    public CpioResource() {
     }
 
     /**
-     * Construct a TarResource representing the specified
+     * Construct a CpioResource representing the specified
      * entry in the specified archive.
      * @param a the archive as File.
-     * @param e the TarEntry.
+     * @param e the CpioEntry.
      */
-    public TarResource(File a, TarArchiveEntry e) {
+    public CpioResource(File a, CpioArchiveEntry e) {
         super(a, e);
     }
 
     /**
-     * Construct a TarResource representing the specified
+     * Construct a CpioResource representing the specified
      * entry in the specified archive.
      * @param a the archive as Resource.
-     * @param e the TarEntry.
+     * @param e the CpioEntry.
      */
-    public TarResource(Resource a, TarArchiveEntry e) {
+    public CpioResource(Resource a, CpioArchiveEntry e) {
         super(a, e);
     }
 
     /**
-     * @return the user name for the tar entry
+     * @return the uid for the cpio entry
      */
-    public String getUserName() {
+    public long getUid() {
         if (isReference()) {
-            return ((TarResource) getCheckedRef()).getUserName();
-        }
-        return userName;
-    }
-
-    /**
-     * @return the group name for the tar entry
-     */
-    public String getGroup() {
-        if (isReference()) {
-            return ((TarResource) getCheckedRef()).getGroup();
-        }
-        return groupName;
-    }
-
-    /**
-     * @return the uid for the tar entry
-     */
-    public int getUid() {
-        if (isReference()) {
-            return ((TarResource) getCheckedRef()).getUid();
+            return ((CpioResource) getCheckedRef()).getUid();
         }
         return uid;
     }
 
     /**
-     * @return the uid for the tar entry
+     * @return the uid for the cpio entry
      */
-    public int getGid() {
+    public long getGid() {
         if (isReference()) {
-            return ((TarResource) getCheckedRef()).getGid();
+            return ((CpioResource) getCheckedRef()).getGid();
         }
         return uid;
     }
@@ -107,28 +85,26 @@
     protected void setEntry(ArchiveEntry e) {
         super.setEntry(e);
         if (e != null) {
-            TarArchiveEntry te = (TarArchiveEntry) e;
-            userName = te.getUserName();
-            groupName = te.getGroupName();
-            uid = te.getUserId();
-            gid = te.getGroupId();
+            CpioArchiveEntry ce = (CpioArchiveEntry) e;
+            uid = ce.getUID();
+            gid = ce.getGID();
         }
     }
 
     protected ArchiveInputStream getArchiveStream(InputStream is)
         throws IOException {
-        return new TarArchiveInputStream(is);
+        return new CpioArchiveInputStream(is);
     }
 
     protected Date getLastModified(ArchiveEntry entry) {
-        return ((TarArchiveEntry) entry).getModTime();
+        return new Date(((CpioArchiveEntry) entry).getTime() * 1000);
     }
 
     protected int getMode(ArchiveEntry e) {
-        return ((TarArchiveEntry) e).getMode();
+        return (int) ((CpioArchiveEntry) e).getMode();
     }
 
     protected String getArchiveType() {
-        return "tar";
+        return "cpio";
     }
 }

Copied: ant/sandbox/antlibs/compress/trunk/src/tests/antunit/cpioentry-test.xml (from r801271,
ant/sandbox/antlibs/compress/trunk/src/tests/antunit/tarentry-test.xml)
URL: http://svn.apache.org/viewvc/ant/sandbox/antlibs/compress/trunk/src/tests/antunit/cpioentry-test.xml?p2=ant/sandbox/antlibs/compress/trunk/src/tests/antunit/cpioentry-test.xml&p1=ant/sandbox/antlibs/compress/trunk/src/tests/antunit/tarentry-test.xml&r1=801271&r2=801280&rev=801280&view=diff
==============================================================================
--- ant/sandbox/antlibs/compress/trunk/src/tests/antunit/tarentry-test.xml (original)
+++ ant/sandbox/antlibs/compress/trunk/src/tests/antunit/cpioentry-test.xml Wed Aug  5 16:00:13
2009
@@ -23,14 +23,13 @@
 
   <target name="setUp">
     <mkdir dir="${output}"/>
-    <mkdir dir="${input}"/>
   </target>
 
-  <target name="testTarSource" depends="setUp">
+  <target name="testCpioSource" depends="setUp">
     <copy todir="${output}">
-      <cmp:tarentry name="asf-logo.gif">
-        <file file="../resources/asf-logo.gif.tar"/>
-      </cmp:tarentry>
+      <cmp:cpioentry name="asf-logo.gif">
+        <file file="../resources/asf-logo.gif.cpio"/>
+      </cmp:cpioentry>
     </copy>
     <au:assertFilesMatch
        actual="${output}/asf-logo.gif"
@@ -38,19 +37,4 @@
        />
   </target>
 
-  <target name="testUncompressSource" depends="setUp">
-    <gzip destfile="${input}/asf-logo.gif.tar.gz"
-          src="../resources/asf-logo.gif.tar"/>
-    <copy todir="${output}">
-      <cmp:tarentry name="asf-logo.gif">
-        <gzipresource>
-          <file file="${input}/asf-logo.gif.tar.gz"/>
-        </gzipresource>
-      </cmp:tarentry>
-    </copy>
-    <au:assertFilesMatch
-       actual="${output}/asf-logo.gif"
-       expected="../resources/asf-logo.gif"
-       />
-  </target>
 </project>



Mime
View raw message