org.freecompany.redline.payload

Class CpioHeader

public class CpioHeader extends Object

This class provides a means to read file content from the compressed CPIO stream that is the body of an RPM distributable. Iterative calls to to read header will result in a header description being returned which includes a count of how many bytes to read from the channel for the file content.
Field Summary
static intBDEV
protected Charsetcharset
protected intchecksum
static intCDEV
protected static intCPIO_HEADER
protected intdevMajor
protected intdevMinor
static intDEFAULT_DIRECTORY_PERMISSION
static intDEFAULT_FILE_PERMISSION
static intDIR
protected intfilesize
protected intflags
static intFIFO
static intFILE
protected intgid
protected Stringgname
protected intinode
protected longmtime
protected static CharSequenceMAGIC
protected Stringname
protected intnlink
protected intpermissions
protected intrdevMajor
protected intrdevMinor
static intSOCKET
static intSYMLINK
protected inttype
protected static StringTRAILER
protected intuid
protected Stringuname
Constructor Summary
CpioHeader()
CpioHeader(String name)
CpioHeader(File file)
CpioHeader(String name, File file)
Method Summary
intgetDevMajor()
intgetDevMinor()
intgetFileSize()
intgetFlags()
StringgetGname()
intgetInode()
intgetMode()
intgetMtime()
StringgetName()
intgetPermissions()
intgetRdevMajor()
intgetRdevMinor()
intgetType()
StringgetUname()
booleanisLast()
Test to see if this is the last header, and is therefore the end of the archive.
protected Stringpad(CharSequence sequence, int length)
intread(ReadableByteChannel channel, int total)
protected CharSequencereadChars(CharBuffer buffer, int length)
protected intreadEight(CharBuffer buffer)
protected CharSequencereadSix(CharBuffer buffer)
voidsetFileSize(int filesize)
voidsetFlags(int flags)
voidsetGname(String gname)
voidsetInode(int inode)
voidsetLast()
voidsetMtime(long mtime)
voidsetName(String name)
voidsetPermissions(int permissions)
voidsetType(int type)
voidsetUname(String uname)
protected intskip(ReadableByteChannel channel, int total)
intskip(WritableByteChannel channel, int total)
StringtoString()
intwrite(WritableByteChannel channel, int total)
Writed the content for the CPIO header, including the name immediately following.
protected ByteBufferwriteEight(int data)
protected ByteBufferwriteSix(CharSequence data)

Field Detail

BDEV

public static final int BDEV

charset

protected Charset charset

checksum

protected int checksum

CDEV

public static final int CDEV

CPIO_HEADER

protected static final int CPIO_HEADER

devMajor

protected int devMajor

devMinor

protected int devMinor

DEFAULT_DIRECTORY_PERMISSION

public static final int DEFAULT_DIRECTORY_PERMISSION

DEFAULT_FILE_PERMISSION

public static final int DEFAULT_FILE_PERMISSION

DIR

public static final int DIR

filesize

protected int filesize

flags

protected int flags

FIFO

public static final int FIFO

FILE

public static final int FILE

gid

protected int gid

gname

protected String gname

inode

protected int inode

mtime

protected long mtime

MAGIC

protected static final CharSequence MAGIC

name

protected String name

nlink

protected int nlink

permissions

protected int permissions

rdevMajor

protected int rdevMajor

rdevMinor

protected int rdevMinor

SOCKET

public static final int SOCKET

SYMLINK

public static final int SYMLINK

type

protected int type

TRAILER

protected static final String TRAILER

uid

protected int uid

uname

protected String uname

Constructor Detail

CpioHeader

public CpioHeader()

CpioHeader

public CpioHeader(String name)

CpioHeader

public CpioHeader(File file)

CpioHeader

public CpioHeader(String name, File file)

Method Detail

getDevMajor

public int getDevMajor()

getDevMinor

public int getDevMinor()

getFileSize

public int getFileSize()

getFlags

public int getFlags()

getGname

public String getGname()

getInode

public int getInode()

getMode

public int getMode()

getMtime

public int getMtime()

getName

public String getName()

getPermissions

public int getPermissions()

getRdevMajor

public int getRdevMajor()

getRdevMinor

public int getRdevMinor()

getType

public int getType()

getUname

public String getUname()

isLast

public boolean isLast()
Test to see if this is the last header, and is therefore the end of the archive. Uses the CPIO magic trailer value to denote the last header of the stream.

pad

protected String pad(CharSequence sequence, int length)

read

public int read(ReadableByteChannel channel, int total)

readChars

protected CharSequence readChars(CharBuffer buffer, int length)

readEight

protected int readEight(CharBuffer buffer)

readSix

protected CharSequence readSix(CharBuffer buffer)

setFileSize

public void setFileSize(int filesize)

setFlags

public void setFlags(int flags)

setGname

public void setGname(String gname)

setInode

public void setInode(int inode)

setLast

public void setLast()

setMtime

public void setMtime(long mtime)

setName

public void setName(String name)

setPermissions

public void setPermissions(int permissions)

setType

public void setType(int type)

setUname

public void setUname(String uname)

skip

protected int skip(ReadableByteChannel channel, int total)

skip

public int skip(WritableByteChannel channel, int total)

toString

public String toString()

write

public int write(WritableByteChannel channel, int total)
Writed the content for the CPIO header, including the name immediately following. The name data is rounded to the nearest 2 byte boundary as CPIO requires by appending a null when needed.

writeEight

protected ByteBuffer writeEight(int data)

writeSix

protected ByteBuffer writeSix(CharSequence data)