commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From s...@apache.org
Subject svn commit: r942617 - in /commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/tar: TarArchiveEntry.java TarConstants.java
Date Sun, 09 May 2010 20:38:21 GMT
Author: sebb
Date: Sun May  9 20:38:20 2010
New Revision: 942617

URL: http://svn.apache.org/viewvc?rev=942617&view=rev
Log:
Add support for identifying Pax headers

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/TarConstants.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=942617&r1=942616&r2=942617&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
Sun May  9 20:38:20 2010
@@ -537,6 +537,15 @@ public class TarArchiveEntry implements 
     }
 
     /**
+     * Check if this is a Pax header.
+     * 
+     * @return <code>true</code> if this is a Pax header.
+     */
+    public boolean isPaxHeader(){
+        return linkFlag == LF_PAX_EXTENDED_HEADER || linkFlag == LF_PAX_GLOBAL_EXTENDED_HEADER;
+    }
+
+    /**
      * Return whether or not this entry represents a directory.
      *
      * @return True if this entry is a directory.
@@ -652,6 +661,11 @@ public class TarArchiveEntry implements 
         devMajor = (int) TarUtils.parseOctal(header, offset, DEVLEN);
         offset += DEVLEN;
         devMinor = (int) TarUtils.parseOctal(header, offset, DEVLEN);
+        offset += DEVLEN;
+        String prefix = TarUtils.parseName(header, offset, PREFIXLEN);
+        if (prefix.length() >0){
+            name = prefix + "/" + name;
+        }
     }
 
     /**

Modified: commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/tar/TarConstants.java
URL: http://svn.apache.org/viewvc/commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/tar/TarConstants.java?rev=942617&r1=942616&r2=942617&view=diff
==============================================================================
--- commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/tar/TarConstants.java
(original)
+++ commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/tar/TarConstants.java
Sun May  9 20:38:20 2010
@@ -147,6 +147,23 @@ public interface TarConstants {
     byte   LF_CONTIG = (byte) '7';
 
     /**
+     * Identifies the *next* file on the tape as having a long name.
+     */
+    byte LF_GNUTYPE_LONGNAME = (byte) 'L';
+
+    // See "http://www.opengroup.org/onlinepubs/009695399/utilities/pax.html#tag_04_100_13_02"
+
+    /**
+     * Identifies the entry as a Pax extended header.
+     */
+    byte LF_PAX_EXTENDED_HEADER = (byte) 'x';
+    
+    /**
+     * Identifies the entry as a Pax global extended header.
+     */
+    byte LF_PAX_GLOBAL_EXTENDED_HEADER = (byte) 'g';
+    
+    /**
      * The magic tag representing a POSIX tar archive.
      */
     String MAGIC_POSIX = "ustar\0";
@@ -161,12 +178,16 @@ public interface TarConstants {
     String VERSION_GNU_ZERO  = "0\0";
 
     /**
-     * The name of the GNU tar entry which contains a long name.
+     * The magic tag representing an Ant tar archive.
      */
-    String GNU_LONGLINK = "././@LongLink"; // TODO rename as LONGLINK_GNU ?
+    String MAGIC_ANT = "ustar\0";
+    // Does not appear to have a version, however Ant does write 8 bytes,
+    // so assume the version is 2 nulls
+    String VERSION_ANT = "\0\0";
 
     /**
-     * Identifies the *next* file on the tape as having a long name.
+     * The name of the GNU tar entry which contains a long name.
      */
-    byte LF_GNUTYPE_LONGNAME = (byte) 'L';
+    String GNU_LONGLINK = "././@LongLink"; // TODO rename as LONGLINK_GNU ?
+
 }



Mime
View raw message