installer
Class TarHeader

java.lang.Object
  extended by installer.TarHeader

public class TarHeader
extends java.lang.Object

This class encapsulates the Tar Entry Header used in Tar Archives. The class also holds a number of tar constants, used mostly in headers.


Field Summary
 int checkSum
          The entry's checksum.
static int CHKSUMLEN
          The length of the checksum field in a header buffer.
static int DEVLEN
          The length of the devices field in a header buffer.
 int devMajor
          The entry's major device number.
 int devMinor
          The entry's minor device number.
static int GIDLEN
          The length of the group id field in a header buffer.
static int GNAMELEN
          The length of the group name field in a header buffer.
static java.lang.String GNU_TMAGIC
          The magic tag representing a GNU tar archive.
 int groupId
          The entry's group id.
 java.lang.StringBuffer groupName
          The entry's group name.
static byte LF_BLK
          Block device file type.
static byte LF_CHR
          Character device file type.
static byte LF_CONTIG
          Contiguous file type.
static byte LF_DIR
          Directory file type.
static byte LF_FIFO
          FIFO (pipe) file type.
static byte LF_LINK
          Link file type.
static byte LF_NORMAL
          Normal file type.
static byte LF_OLDNORM
          LF_ constants represent the "link flag" of an entry, or more commonly, the "entry type".
static byte LF_SYMLINK
          Symbolic link file type.
 byte linkFlag
          The entry's link flag.
 java.lang.StringBuffer linkName
          The entry's link name.
 java.lang.StringBuffer magic
          The entry's magic tag.
static int MAGICLEN
          The length of the magic field in a header buffer.
 int mode
          The entry's permission mode.
static int MODELEN
          The length of the mode field in a header buffer.
 long modTime
          The entry's modification time.
static int MODTIMELEN
          The length of the modification time field in a header buffer.
 java.lang.StringBuffer name
          The entry's name.
static int NAMELEN
          The length of the name field in a header buffer.
 long size
          The entry's size.
static int SIZELEN
          The length of the size field in a header buffer.
static java.lang.String TMAGIC
          The magic tag representing a POSIX tar archive.
static int UIDLEN
          The length of the user id field in a header buffer.
static int UNAMELEN
          The length of the user name field in a header buffer.
 int userId
          The entry's user id.
 java.lang.StringBuffer userName
          The entry's user name.
 
Constructor Summary
TarHeader()
           
 
Method Summary
 java.lang.Object clone()
          TarHeaders can be cloned.
static int getCheckSumOctalBytes(long value, byte[] buf, int offset, int length)
          Parse the checksum octal integer from a header buffer.
static int getLongOctalBytes(long value, byte[] buf, int offset, int length)
          Parse an octal long integer from a header buffer.
 java.lang.String getName()
          Get the name of this entry.
static int getNameBytes(java.lang.StringBuffer name, byte[] buf, int offset, int length)
          Determine the number of bytes in an entry name.
static int getOctalBytes(long value, byte[] buf, int offset, int length)
          Parse an octal integer from a header buffer.
static java.lang.StringBuffer parseName(byte[] header, int offset, int length)
          Parse an entry name from a header buffer.
static long parseOctal(byte[] header, int offset, int length)
          Parse an octal string from a header buffer.
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

NAMELEN

public static final int NAMELEN
The length of the name field in a header buffer.

See Also:
Constant Field Values

MODELEN

public static final int MODELEN
The length of the mode field in a header buffer.

See Also:
Constant Field Values

UIDLEN

public static final int UIDLEN
The length of the user id field in a header buffer.

See Also:
Constant Field Values

GIDLEN

public static final int GIDLEN
The length of the group id field in a header buffer.

See Also:
Constant Field Values

CHKSUMLEN

public static final int CHKSUMLEN
The length of the checksum field in a header buffer.

See Also:
Constant Field Values

SIZELEN

public static final int SIZELEN
The length of the size field in a header buffer.

See Also:
Constant Field Values

MAGICLEN

public static final int MAGICLEN
The length of the magic field in a header buffer.

See Also:
Constant Field Values

MODTIMELEN

public static final int MODTIMELEN
The length of the modification time field in a header buffer.

See Also:
Constant Field Values

UNAMELEN

public static final int UNAMELEN
The length of the user name field in a header buffer.

See Also:
Constant Field Values

GNAMELEN

public static final int GNAMELEN
The length of the group name field in a header buffer.

See Also:
Constant Field Values

DEVLEN

public static final int DEVLEN
The length of the devices field in a header buffer.

See Also:
Constant Field Values

LF_OLDNORM

public static final byte LF_OLDNORM
LF_ constants represent the "link flag" of an entry, or more commonly, the "entry type". This is the "old way" of indicating a normal file.

See Also:
Constant Field Values

LF_NORMAL

public static final byte LF_NORMAL
Normal file type.

See Also:
Constant Field Values

LF_LINK

public static final byte LF_LINK
Link file type.

See Also:
Constant Field Values

LF_SYMLINK

public static final byte LF_SYMLINK
Symbolic link file type.

See Also:
Constant Field Values

LF_CHR

public static final byte LF_CHR
Character device file type.

See Also:
Constant Field Values

LF_BLK

public static final byte LF_BLK
Block device file type.

See Also:
Constant Field Values

LF_DIR

public static final byte LF_DIR
Directory file type.

See Also:
Constant Field Values

LF_FIFO

public static final byte LF_FIFO
FIFO (pipe) file type.

See Also:
Constant Field Values

LF_CONTIG

public static final byte LF_CONTIG
Contiguous file type.

See Also:
Constant Field Values

TMAGIC

public static final java.lang.String TMAGIC
The magic tag representing a POSIX tar archive.

See Also:
Constant Field Values

GNU_TMAGIC

public static final java.lang.String GNU_TMAGIC
The magic tag representing a GNU tar archive.

See Also:
Constant Field Values

name

public java.lang.StringBuffer name
The entry's name.


mode

public int mode
The entry's permission mode.


userId

public int userId
The entry's user id.


groupId

public int groupId
The entry's group id.


size

public long size
The entry's size.


modTime

public long modTime
The entry's modification time.


checkSum

public int checkSum
The entry's checksum.


linkFlag

public byte linkFlag
The entry's link flag.


linkName

public java.lang.StringBuffer linkName
The entry's link name.


magic

public java.lang.StringBuffer magic
The entry's magic tag.


userName

public java.lang.StringBuffer userName
The entry's user name.


groupName

public java.lang.StringBuffer groupName
The entry's group name.


devMajor

public int devMajor
The entry's major device number.


devMinor

public int devMinor
The entry's minor device number.

Constructor Detail

TarHeader

public TarHeader()
Method Detail

clone

public java.lang.Object clone()
TarHeaders can be cloned.

Overrides:
clone in class java.lang.Object

getName

public java.lang.String getName()
Get the name of this entry.

Returns:
Teh entry's name.

parseOctal

public static long parseOctal(byte[] header,
                              int offset,
                              int length)
                       throws InvalidHeaderException
Parse an octal string from a header buffer. This is used for the file permission mode value.

Parameters:
header - The header buffer from which to parse.
offset - The offset into the buffer from which to parse.
length - The number of header bytes to parse.
Returns:
The long value of the octal string.
Throws:
InvalidHeaderException

parseName

public static java.lang.StringBuffer parseName(byte[] header,
                                               int offset,
                                               int length)
                                        throws InvalidHeaderException
Parse an entry name from a header buffer.

Parameters:
header - The header buffer from which to parse.
offset - The offset into the buffer from which to parse.
length - The number of header bytes to parse.
Returns:
The header's entry name.
Throws:
InvalidHeaderException

getNameBytes

public static int getNameBytes(java.lang.StringBuffer name,
                               byte[] buf,
                               int offset,
                               int length)
Determine the number of bytes in an entry name.

Parameters:
header - The header buffer from which to parse.
offset - The offset into the buffer from which to parse.
length - The number of header bytes to parse.
Returns:
The number of bytes in a header's entry name.

getOctalBytes

public static int getOctalBytes(long value,
                                byte[] buf,
                                int offset,
                                int length)
Parse an octal integer from a header buffer.

Parameters:
header - The header buffer from which to parse.
offset - The offset into the buffer from which to parse.
length - The number of header bytes to parse.
Returns:
The integer value of the octal bytes.

getLongOctalBytes

public static int getLongOctalBytes(long value,
                                    byte[] buf,
                                    int offset,
                                    int length)
Parse an octal long integer from a header buffer.

Parameters:
header - The header buffer from which to parse.
offset - The offset into the buffer from which to parse.
length - The number of header bytes to parse.
Returns:
The long value of the octal bytes.

getCheckSumOctalBytes

public static int getCheckSumOctalBytes(long value,
                                        byte[] buf,
                                        int offset,
                                        int length)
Parse the checksum octal integer from a header buffer.

Parameters:
header - The header buffer from which to parse.
offset - The offset into the buffer from which to parse.
length - The number of header bytes to parse.
Returns:
The integer value of the entry's checksum.