public class TarHeader

  1. Object
  2. TarHeader

Header

Offset  Size     Field
0       100      File name
100     8        File mode
108     8        Owner's numeric user ID
116     8        Group's numeric user ID
124     12       File size in bytes
136     12       Last modification time in numeric Unix time format
148     8        Checksum for header block
156     1        Link indicator (file type)
157     100      Name of linked file

File Types

Value        Meaning
'0'          Normal file
(ASCII NUL)  Normal file (now obsolete)
'1'          Hard link
'2'          Symbolic link
'3'          Character special
'4'          Block special
'5'          Directory
'6'          FIFO
'7'          Contigous

Ustar header

Offset  Size    Field
257     6       UStar indicator "ustar"
263     2       UStar version "00"
265     32      Owner user name
297     32      Owner group name
329     8       Device major number
337     8       Device minor number
345     155     Filename prefix

Fields

public static final int NAMELEN = 100
public static final int MODELEN = 8
public static final int UIDLEN = 8
public static final int GIDLEN = 8
public static final int SIZELEN = 12
public static final int MODTIMELEN = 12
public static final int CHKSUMLEN = 8
public static final byte LF_OLDNORM = 0
public static final byte LF_NORMAL = 48
public static final byte LF_LINK = 49
public static final byte LF_SYMLINK = 50
public static final byte LF_CHR = 51
public static final byte LF_BLK = 52
public static final byte LF_DIR = 53
public static final byte LF_FIFO = 54
public static final byte LF_CONTIG = 55
public static final int MAGICLEN = 8
public static final String TMAGIC = "ustar"The magic tag representing a POSIX tar archive.
public static final String GNU_TMAGIC = "ustar "The magic tag representing a GNU tar archive.
public static final int UNAMELEN = 32
public static final int GNAMELEN = 32
public static final int DEVLEN = 8
public StringBuffer name
public int mode
public int userId
public int groupId
public long size
public long modTime
public int checkSum
public byte linkFlag
public StringBuffer linkName
public StringBuffer magic
public StringBuffer userName
public StringBuffer groupName
public int devMajor
public int devMinor

Constructors

public TarHeader()

Methods

public static StringBuffer parseName(byte[] header, int offset, int length)Parse an entry name from a header buffer.
public static int getNameBytes(StringBuffer name, byte[] buf, int offset, int length)Determine the number of bytes in an entry name.

Inherited methods

Field details

NAMELEN

public static final int NAMELEN = 100

MODELEN

public static final int MODELEN = 8

UIDLEN

public static final int UIDLEN = 8

GIDLEN

public static final int GIDLEN = 8

SIZELEN

public static final int SIZELEN = 12

MODTIMELEN

public static final int MODTIMELEN = 12

CHKSUMLEN

public static final int CHKSUMLEN = 8

LF_OLDNORM

public static final byte LF_OLDNORM = 0

LF_NORMAL

public static final byte LF_NORMAL = 48

LF_CHR

public static final byte LF_CHR = 51

LF_BLK

public static final byte LF_BLK = 52

LF_DIR

public static final byte LF_DIR = 53

LF_FIFO

public static final byte LF_FIFO = 54

LF_CONTIG

public static final byte LF_CONTIG = 55

MAGICLEN

public static final int MAGICLEN = 8

TMAGIC

public static final String TMAGIC = "ustar"
The magic tag representing a POSIX tar archive.

GNU_TMAGIC

public static final String GNU_TMAGIC = "ustar "
The magic tag representing a GNU tar archive.

UNAMELEN

public static final int UNAMELEN = 32

GNAMELEN

public static final int GNAMELEN = 32

DEVLEN

public static final int DEVLEN = 8

name

public StringBuffer name

mode

public int mode

userId

public int userId

groupId

public int groupId

size

public long size

modTime

public long modTime

checkSum

public int checkSum

linkFlag

public byte linkFlag

linkName

public StringBuffer linkName

magic

public StringBuffer magic

userName

public StringBuffer userName

groupName

public StringBuffer groupName

devMajor

public int devMajor

devMinor

public int devMinor

Constructor details

TarHeader

public TarHeader()

Method details

parseName

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

Parameters

header byte[]
The header buffer from which to parse.
offset int
The offset into the buffer from which to parse.
length int
The number of header bytes to parse.

Returns

The header’s entry name.

getNameBytes

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

Parameters

name StringBuffer
Not documented.
buf byte[]
Not documented.
offset int
The offset into the buffer from which to parse.
length int
The number of header bytes to parse.

Returns

The number of bytes in a header’s entry name.