Maven module :un.storage : archive-tar :
Class : un.storage.archive.tar.TarHeader
Extends/Implements : -
Subclasses : -

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


Variables : name, mode, userId, groupId, size, modTime, checkSum, linkFlag, linkName, magic, userName, groupName, devMajor, devMinor
Functions : TarHeader, getName, parseOctal, parseFileName, parseName, getFileNameBytes, getNameBytes, getOctalBytes, getLongOctalBytes, getCheckSumOctalBytes



The entry's name.
public String name


The entry's permission mode.
public int mode


The entry's user id.
public int userId


The entry's group id.
public int groupId


The entry's size.
public long size


The entry's modification time.
public long modTime


The entry's checksum.
public int checkSum


The entry's link flag.
public byte linkFlag


The entry's link name.
public String linkName


The entry's magic tag.
public String magic


The entry's user name.
public String userName


The entry's group name.
public String groupName


The entry's major device number.
public int devMajor


The entry's minor device number.
public int devMinor


public void TarHeader ()


Get the name of this entry.
return  Teh entry's name.
public String getName ()


Parse an octal string from a header buffer. This is used for the file
permission mode value.
param  header The header buffer from which to parse.
param  offset The offset into the buffer from which to parse.
param  length The number of header bytes to parse.
return  The long value of the octal string.
public long parseOctal (byte[] header, int offset, int length)


Parse a file name from a header buffer. This is different from
parseName() in that is recognizes 'ustar' names and will handle adding on
the "prefix" field to the name.

Contributed by Dmitri Tikhonov

@param header The header buffer from which to parse.
@param offset The offset into the buffer from which to parse.
@param length The number of header bytes to parse.
@return The header's entry name.
public String parseFileName (byte[] header)


Parse an entry name from a header buffer.
param  header The header buffer from which to parse.
param  offset The offset into the buffer from which to parse.
param  length The number of header bytes to parse.
return  The header's entry name.
public String parseName (byte[] header, int offset, int length)


This method, like getNameBytes(), is intended to place a name into a
TarHeader's buffer. However, this method is sophisticated enough to
recognize long names (name.length() > NAMELEN). In these cases, the
method will break the name into a prefix and suffix and place the name in
the header in 'ustar' format. It is up to the TarEntry to manage the
"entry header format". This method assumes the name is valid for the type
of archive being generated.

@param outbuf The buffer containing the entry header to modify.
@param newName The new name to place into the header buffer.
@return The current offset in the tar header (always TarHeader.NAMELEN).
@throws InvalidHeaderException If the name will not fit in the header.
public int getFileNameBytes (String newName, byte[] outbuf)


Move the bytes from the name StringBuffer into the header's buffer.
param  header The header buffer into which to copy the name.
param  offset The offset into the buffer at which to store.
param  length The number of header bytes to store.
return  The new offset (offset + length).
public int getNameBytes (String name, byte[] buf, int offset, int length)


Parse an octal integer from a header buffer.
param  header The header buffer from which to parse.
param  offset The offset into the buffer from which to parse.
param  length The number of header bytes to parse.
return  The integer value of the octal bytes.
public int getOctalBytes (long value, byte[] buf, int offset, int length)


Parse an octal long integer from a header buffer.
param  header The header buffer from which to parse.
param  offset The offset into the buffer from which to parse.
param  length The number of header bytes to parse.
return  The long value of the octal bytes.
public int getLongOctalBytes (long value, byte[] buf, int offset, int length)


Parse the checksum octal integer from a header buffer.
param  header The header buffer from which to parse.
param  offset The offset into the buffer from which to parse.
param  length The number of header bytes to parse.
return  The integer value of the entry's checksum.
public int getCheckSumOctalBytes (long value, byte[] buf, int offset, int length)