commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bode...@apache.org
Subject svn commit: r1298950 - /commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/tar/TarArchiveOutputStream.java
Date Fri, 09 Mar 2012 18:07:14 GMT
Author: bodewig
Date: Fri Mar  9 18:07:13 2012
New Revision: 1298950

URL: http://svn.apache.org/viewvc?rev=1298950&view=rev
Log:
simplify addition of PAX headers

Modified:
    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/TarArchiveOutputStream.java
URL: http://svn.apache.org/viewvc/commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/tar/TarArchiveOutputStream.java?rev=1298950&r1=1298949&r2=1298950&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 18:07:13 2012
@@ -449,30 +449,32 @@ public class TarArchiveOutputStream exte
 
     private void addPaxHeadersForBigNumbers(Map<String, String> paxHeaders,
                                             TarArchiveEntry entry) {
-        if (entry.getSize() > TarConstants.MAXSIZE) {
-            paxHeaders.put("size", String.valueOf(entry.getSize()));
-        }
-        if (entry.getGroupId() > TarConstants.MAXID) {
-            paxHeaders.put("gid", String.valueOf(entry.getGroupId()));
-        }
-        final long mtime =  entry.getModTime().getTime() / 1000;
-        if (mtime < 0 || mtime > TarConstants.MAXSIZE) {
-            paxHeaders.put("mtime", String.valueOf(mtime));
-        }
-        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()));
-        }
+        addPaxHeaderForBigNumber(paxHeaders, "size", entry.getSize(),
+                                 TarConstants.MAXSIZE);
+        addPaxHeaderForBigNumber(paxHeaders, "gid", entry.getGroupId(),
+                                 TarConstants.MAXID);
+        addPaxHeaderForBigNumber(paxHeaders, "mtime",
+                                 entry.getModTime().getTime() / 1000,
+                                 TarConstants.MAXSIZE);
+        addPaxHeaderForBigNumber(paxHeaders, "uid", entry.getUserId(),
+                                 TarConstants.MAXID);
+        // star extensions by J\u00f6rg Schillig
+        addPaxHeaderForBigNumber(paxHeaders, "SCHILY.devmajor",
+                                 entry.getDevMajor(), TarConstants.MAXID);
+        addPaxHeaderForBigNumber(paxHeaders, "SCHILY.devminor",
+                                 entry.getDevMinor(), TarConstants.MAXID);
+        // there is no PAX header for file mode
         failForBigNumber("mode", entry.getMode(), TarConstants.MAXID);
     }
 
+    private void addPaxHeaderForBigNumber(Map<String, String> paxHeaders,
+                                          String header, long value,
+                                          long maxValue) {
+        if (value < 0 || value > maxValue) {
+            paxHeaders.put(header, String.valueOf(value));
+        }
+    }
+
     private void failForBigNumbers(TarArchiveEntry entry) {
         failForBigNumber("entry size", entry.getSize(), TarConstants.MAXSIZE);
         failForBigNumber("group id", entry.getGroupId(), TarConstants.MAXID);



Mime
View raw message