com.jguild.jrpm.io.cpio

Class CPIOEntry

public final class CPIOEntry extends Object implements CPIOConstants

A cpio archive consists of a sequence of files. There are several types of headers defided in two categories of new and old format. The headers are recognized by magic numbers: "070701" ascii for "new" portable format "070702" ascii for "new" portable format with CRC format "070707" ascii for old ascii "070707" short for old binary CPIO 2.5 knows also about tar, but it is not recognized here. OLD FORMAT: Each file has a 76(ascii)/26(binary) byte header, a variable length, NUL terminated filename, and variable length file data. A header for a filename "TRAILER!!!" indicates the end of the archive. All the fields in the header are ISO 646 (approximately ASCII) strings of octal numbers, left padded, not NUL terminated. Field Name Length in Bytes Notes ASCII / BINARY c_magic 6 / 2 c_dev 6 / 2 Device that contains a directory entry for this file c_ino 6 / 2 I-node number that identifies the input file to the file system c_mode 6 / 2 Mode of the input file c_uid 6 / 2 User ID of the owner of the input file c_gid 6 / 2 Group ID of the owner of the input file c_nlink 6 / 2 Number of links that are connected to the input file c_rdev 6 / 2 ID of the remote device from which the input file is taken only valid for chr and blk special files c_mtime 11 / 4 Time when data was last modified. For remote files, this field contains the time at the server c_namesize 6 / 2 Length of the path name, including the terminating null byte c_filesize 11 / 4 Length of the file in bytes. This is the length of the data section that follows the header structure. Must be 0 for FIFOs and directories Special files, directories, and the trailer are recorded with the h_filesize field equal to 0. NEW FORMAT: Each file has a 110 byte header, a variable length, NUL terminated filename, and variable length file data. A header for a filename "TRAILER!!!" indicates the end of the archive. All the fields in the header are ISO 646 (approximately ASCII) strings of hexadecimal numbers, left padded, not NUL terminated. Field Name Length in Bytes Notes c_magic 6 c_ino 8 c_mode 8 c_uid 8 c_gid 8 c_nlink 8 c_mtime 8 c_filesize 8 must be 0 for FIFOs and directories c_maj 8 c_min 8 c_rmaj 8 only valid for chr and blk special files c_rmin 8 only valid for chr and blk special files c_namesize 8 count includes terminating NUL in pathname c_chksum 8 0 for "new" portable format; for CRC format the sum of all the bytes in the file

Author: Michael Kuss

Constructor Summary
CPIOEntry()
Ceates a CPIOEntry without a cpio format.
CPIOEntry(short format)
Ceates a CPIOEntry with a specified format.
CPIOEntry(String name)
Ceates a CPIOEntry with a specified name.
Method Summary
longgetChksum()
Get the checksum.
longgetDevice()
Get the device id.
longgetDeviceMaj()
Get the major device id.
longgetDeviceMin()
Get the minor device id
longgetFileSize()
Get the filesize.
shortgetFormat()
Get the format for this entry.
longgetGID()
Get the group id.
longgetHeaderSize()
Get the size of this entry on the stream
longgetInode()
Set the inode.
longgetMode()
Get the mode of this entry (e.g. directory, regular file).
StringgetName()
Get the name.
longgetNumberOfLinks()
Get the number of links.
longgetRemoteDevice()
Get the remote device id.
longgetRemoteDeviceMaj()
Get the remote major device id.
longgetRemoteDeviceMin()
Get the remote minor device id.
longgetTime()
Get the time in seconds.
longgetUID()
Get the user id.
booleanisBlockDevice()
Check if this entry represents a block device.
booleanisCharacterDevice()
Check if this entry represents a character device.
booleanisDirectory()
Check if this entry represents a directory.
booleanisNetwork()
Check if this entry represents a network device.
booleanisPipe()
Check if this entry represents a pipe.
booleanisRegularFile()
Check if this entry represents a regular file.
booleanisSocket()
Check if this entry represents a socket.
booleanisSymbolicLink()
Check if this entry represents a symbolic link.
voidsetChksum(long chksum)
Set the checksum.
voidsetDevice(long device)
Set the device id.
voidsetDeviceMaj(long maj)
Set major device id.
voidsetDeviceMin(long min)
Set the minor device id
voidsetFileSize(long size)
Set the filesize.
voidsetGID(long gid)
Set the group id.
voidsetInode(long inode)
Set the inode.
voidsetMode(long mode)
Set the mode of this entry (e.g. directory, regular file).
voidsetName(String name)
Set the name.
voidsetNumberOfLinks(long nlink)
Set the number of links.
voidsetRemoteDevice(long device)
Set the remote device id.
voidsetRemoteDeviceMaj(long rmaj)
Set the remote major device id.
voidsetRemoteDeviceMin(long rmin)
Set the remote minor device id.
voidsetTime(long time)
Set the time in seconds.
voidsetUID(long uid)
Set the user id.

Constructor Detail

CPIOEntry

public CPIOEntry()
Ceates a CPIOEntry without a cpio format.

CPIOEntry

public CPIOEntry(short format)
Ceates a CPIOEntry with a specified format.

Parameters: format The cpio format for this entry.

CPIOEntry

public CPIOEntry(String name)
Ceates a CPIOEntry with a specified name. The format of this entry will be the new format.

Parameters: name The name of this entry.

Method Detail

getChksum

public long getChksum()
Get the checksum.

Returns: Returns the checksum.

getDevice

public long getDevice()
Get the device id.

Returns: Returns the device id.

Throws: UnsupportedOperationException if this method is called for a CPIOEntry with a new format.

getDeviceMaj

public long getDeviceMaj()
Get the major device id.

Returns: Returns the major device id.

Throws: UnsupportedOperationException if this method is called for a CPIOEntry with an old format.

getDeviceMin

public long getDeviceMin()
Get the minor device id

Returns: Returns the minor device id.

getFileSize

public long getFileSize()
Get the filesize.

Returns: Returns the filesize.

getFormat

public short getFormat()
Get the format for this entry.

Returns: Returns the format.

getGID

public long getGID()
Get the group id.

Returns: Returns the group id.

getHeaderSize

public long getHeaderSize()
Get the size of this entry on the stream

Returns: Returns the size.

getInode

public long getInode()
Set the inode.

Returns: Returns the inode.

getMode

public long getMode()
Get the mode of this entry (e.g. directory, regular file).

Returns: Returns the mode.

getName

public String getName()
Get the name.

Returns: Returns the name.

getNumberOfLinks

public long getNumberOfLinks()
Get the number of links.

Returns: Returns the number of links.

getRemoteDevice

public long getRemoteDevice()
Get the remote device id.

Returns: Returns the remote device id.

Throws: UnsupportedOperationException if this method is called for a CPIOEntry with a new format.

getRemoteDeviceMaj

public long getRemoteDeviceMaj()
Get the remote major device id.

Returns: Returns the remote major device id.

Throws: UnsupportedOperationException if this method is called for a CPIOEntry with an old format.

getRemoteDeviceMin

public long getRemoteDeviceMin()
Get the remote minor device id.

Returns: Returns the remote minor device id.

Throws: UnsupportedOperationException if this method is called for a CPIOEntry with an old format.

getTime

public long getTime()
Get the time in seconds.

Returns: Returns the time.

getUID

public long getUID()
Get the user id.

Returns: Returns the user id.

isBlockDevice

public boolean isBlockDevice()
Check if this entry represents a block device.

Returns: TRUE if this entry is a block device.

isCharacterDevice

public boolean isCharacterDevice()
Check if this entry represents a character device.

Returns: TRUE if this entry is a character device.

isDirectory

public boolean isDirectory()
Check if this entry represents a directory.

Returns: TRUE if this entry is a directory.

isNetwork

public boolean isNetwork()
Check if this entry represents a network device.

Returns: TRUE if this entry is a network device.

isPipe

public boolean isPipe()
Check if this entry represents a pipe.

Returns: TRUE if this entry is a pipe.

isRegularFile

public boolean isRegularFile()
Check if this entry represents a regular file.

Returns: TRUE if this entry is a regular file.

isSocket

public boolean isSocket()
Check if this entry represents a socket.

Returns: TRUE if this entry is a socket.

isSymbolicLink

public boolean isSymbolicLink()
Check if this entry represents a symbolic link.

Returns: TRUE if this entry is a symbolic link.

setChksum

public void setChksum(long chksum)
Set the checksum. The checksum is calculated by adding all bytes of a file to transfer (crc += buf[pos] & 0xFF).

Parameters: chksum The checksum to set.

setDevice

public void setDevice(long device)
Set the device id.

Parameters: device The device id to set.

Throws: UnsupportedOperationException if this method is called for a CPIOEntry with a new format.

setDeviceMaj

public void setDeviceMaj(long maj)
Set major device id.

Parameters: maj The major device id to set.

setDeviceMin

public void setDeviceMin(long min)
Set the minor device id

Parameters: min The minor device id to set.

setFileSize

public void setFileSize(long size)
Set the filesize.

Parameters: size The filesize to set.

setGID

public void setGID(long gid)
Set the group id.

Parameters: gid The group id to set.

setInode

public void setInode(long inode)
Set the inode.

Parameters: inode The inode to set.

setMode

public void setMode(long mode)
Set the mode of this entry (e.g. directory, regular file).

Parameters: mode The mode to set.

setName

public void setName(String name)
Set the name.

Parameters: name The name to set.

setNumberOfLinks

public void setNumberOfLinks(long nlink)
Set the number of links.

Parameters: nlink The number of links to set.

setRemoteDevice

public void setRemoteDevice(long device)
Set the remote device id.

Parameters: device The remote device id to set.

Throws: UnsupportedOperationException if this method is called for a CPIOEntry with a new format.

setRemoteDeviceMaj

public void setRemoteDeviceMaj(long rmaj)
Set the remote major device id.

Parameters: rmaj The remote major device id to set.

Throws: UnsupportedOperationException if this method is called for a CPIOEntry with an old format.

setRemoteDeviceMin

public void setRemoteDeviceMin(long rmin)
Set the remote minor device id.

Parameters: rmin The remote minor device id to set.

Throws: UnsupportedOperationException if this method is called for a CPIOEntry with an old format.

setTime

public void setTime(long time)
Set the time in seconds.

Parameters: time The time to set.

setUID

public void setUID(long uid)
Set the user id.

Parameters: uid The user id to set.