commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bode...@apache.org
Subject svn commit: r1298930 - in /commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/tar: TarArchiveEntry.java TarArchiveInputStream.java TarArchiveOutputStream.java
Date Fri, 09 Mar 2012 17:19:54 GMT
Author: bodewig
Date: Fri Mar  9 17:19:53 2012
New Revision: 1298930

URL: http://svn.apache.org/viewvc?rev=1298930&view=rev
Log:
Support for major and minor device number in PAX headers.  COMPRESS-182

Modified:
    commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/tar/TarArchiveEntry.java
    commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/tar/TarArchiveInputStream.java
    commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/tar/TarArchiveOutputStream.java

Modified: commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/tar/TarArchiveEntry.java
URL: http://svn.apache.org/viewvc/commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/tar/TarArchiveEntry.java?rev=1298930&r1=1298929&r2=1298930&view=diff
==============================================================================
--- commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/tar/TarArchiveEntry.java
(original)
+++ commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/tar/TarArchiveEntry.java
Fri Mar  9 17:19:53 2012
@@ -574,6 +574,56 @@ public class TarArchiveEntry implements 
     }
 
     /**
+     * Get this entry's major device number.
+     *
+     * @return This entry's major device number.
+     * @since Apache Commons Compress 1.4
+     */
+    public int getDevMajor() {
+        return devMajor;
+    }
+
+    /**
+     * Set this entry's major device number.
+     *
+     * @param devNo This entry's major device number.
+     * @throws IllegalArgumentException if the devNo is < 0.
+     * @since Apache Commons Compress 1.4
+     */
+    public void setDevMajor(int devNo) {
+        if (devNo < 0){
+            throw new IllegalArgumentException("Major device number is out of "
+                                               + "range: " + devNo);
+        }
+        this.devMajor = devNo;
+    }
+
+    /**
+     * Get this entry's minor device number.
+     *
+     * @return This entry's minor device number.
+     * @since Apache Commons Compress 1.4
+     */
+    public int getDevMinor() {
+        return devMinor;
+    }
+
+    /**
+     * Set this entry's minor device number.
+     *
+     * @param devNo This entry's minor device number.
+     * @throws IllegalArgumentException if the devNo is &lt; 0.
+     * @since Apache Commons Compress 1.4
+     */
+    public void setDevMinor(int devNo) {
+        if (devNo < 0){
+            throw new IllegalArgumentException("Minor device number is out of "
+                                               + "range: " + devNo);
+        }
+        this.devMinor = devNo;
+    }
+
+    /**
      * Indicates in case of a sparse file if an extension sparse header
      * follows.
      *

Modified: commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/tar/TarArchiveInputStream.java
URL: http://svn.apache.org/viewvc/commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/tar/TarArchiveInputStream.java?rev=1298930&r1=1298929&r2=1298930&view=diff
==============================================================================
--- commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/tar/TarArchiveInputStream.java
(original)
+++ commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/tar/TarArchiveInputStream.java
Fri Mar  9 17:19:53 2012
@@ -367,12 +367,10 @@ public class TarArchiveInputStream exten
                 currEntry.setSize(Long.parseLong(val));
             } else if ("mtime".equals(key)){
                 currEntry.setModTime((long) (Double.parseDouble(val) * 1000));
-            /* currently not settable
             } else if ("SCHILY.devminor".equals(key)){
-                currEntry.setMinor(Integer.parseInt(val));
+                currEntry.setDevMinor(Integer.parseInt(val));
             } else if ("SCHILY.devmajor".equals(key)){
-                currEntry.setMajor(Integer.parseInt(val));
-            */
+                currEntry.setDevMajor(Integer.parseInt(val));
             }
         }
     }

Modified: commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/tar/TarArchiveOutputStream.java
URL: http://svn.apache.org/viewvc/commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/tar/TarArchiveOutputStream.java?rev=1298930&r1=1298929&r2=1298930&view=diff
==============================================================================
--- commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/tar/TarArchiveOutputStream.java
(original)
+++ commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/tar/TarArchiveOutputStream.java
Fri Mar  9 17:19:53 2012
@@ -462,12 +462,19 @@ public class TarArchiveOutputStream exte
         if (entry.getUserId() > TarConstants.MAXID) {
             paxHeaders.put("uid", String.valueOf(entry.getUserId()));
         }
+        if (entry.getDevMajor() > TarConstants.MAXID) {
+            paxHeaders.put("SCHILY.devmajor",
+                           String.valueOf(entry.getDevMajor()));
+        }
+        if (entry.getDevMinor() > TarConstants.MAXID) {
+            paxHeaders.put("SCHILY.devminor",
+                           String.valueOf(entry.getDevMinor()));
+        }
         if (entry.getMode() > TarConstants.MAXID) {
             throw new RuntimeException("mode '" + entry.getMode()
                                        + "' is too big ( > "
                                        + TarConstants.MAXID + " bytes)");
         }
-        // TODO add devMajor and devMinor
     }
 
     private void failForBigNumbers(TarArchiveEntry entry) {
@@ -498,6 +505,17 @@ public class TarArchiveOutputStream exte
                                        + "' is too big ( > "
                                        + TarConstants.MAXID + " bytes)");
         }
-        // TODO add devMajor and devMinor
+        if (entry.getDevMajor() > TarConstants.MAXID) {
+            throw new RuntimeException("major device number '"
+                                       + entry.getDevMajor()
+                                       + "' is too big ( > "
+                                       + TarConstants.MAXID + " bytes)");
+        }
+        if (entry.getDevMinor() > TarConstants.MAXID) {
+            throw new RuntimeException("minor device number '"
+                                       + entry.getDevMinor()
+                                       + "' is too big ( > "
+                                       + TarConstants.MAXID + " bytes)");
+        }
     }
 }



Mime
View raw message