org.freecompany.redline.payload
Class CpioHeader

java.lang.Object
  extended by org.freecompany.redline.payload.CpioHeader

public class CpioHeader
extends java.lang.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 int BDEV
           
static int CDEV
           
protected  java.nio.charset.Charset charset
           
protected  int checksum
           
protected static int CPIO_HEADER
           
static int DEFAULT_DIRECTORY_PERMISSION
           
static int DEFAULT_FILE_PERMISSION
           
protected  int devMajor
           
protected  int devMinor
           
static int DIR
           
static int FIFO
           
static int FILE
           
protected  int filesize
           
protected  int flags
           
protected  int gid
           
protected  java.lang.String gname
           
protected  int inode
           
protected static java.lang.CharSequence MAGIC
           
protected  long mtime
           
protected  java.lang.String name
           
protected  int nlink
           
protected  int permissions
           
protected  int rdevMajor
           
protected  int rdevMinor
           
static int SOCKET
           
static int SYMLINK
           
protected static java.lang.String TRAILER
           
protected  int type
           
protected  int uid
           
protected  java.lang.String uname
           
 
Constructor Summary
CpioHeader()
           
CpioHeader(java.io.File file)
           
CpioHeader(java.lang.String name)
           
CpioHeader(java.lang.String name, java.io.File file)
           
 
Method Summary
 int getDevMajor()
           
 int getDevMinor()
           
 int getFileSize()
           
 int getFlags()
           
 java.lang.String getGname()
           
 int getInode()
           
 int getMode()
           
 int getMtime()
           
 java.lang.String getName()
           
 int getPermissions()
           
 int getRdevMajor()
           
 int getRdevMinor()
           
 int getType()
           
 java.lang.String getUname()
           
 boolean isLast()
          Test to see if this is the last header, and is therefore the end of the archive.
protected  java.lang.String pad(java.lang.CharSequence sequence, int length)
           
 int read(java.nio.channels.ReadableByteChannel channel, int total)
           
protected  java.lang.CharSequence readChars(java.nio.CharBuffer buffer, int length)
           
protected  int readEight(java.nio.CharBuffer buffer)
           
protected  java.lang.CharSequence readSix(java.nio.CharBuffer buffer)
           
 void setFileSize(int filesize)
           
 void setFlags(int flags)
           
 void setGname(java.lang.String gname)
           
 void setInode(int inode)
           
 void setLast()
           
 void setMtime(long mtime)
           
 void setName(java.lang.String name)
           
 void setPermissions(int permissions)
           
 void setType(int type)
           
 void setUname(java.lang.String uname)
           
protected  int skip(java.nio.channels.ReadableByteChannel channel, int total)
           
 int skip(java.nio.channels.WritableByteChannel channel, int total)
           
 java.lang.String toString()
           
 int write(java.nio.channels.WritableByteChannel channel, int total)
          Writed the content for the CPIO header, including the name immediately following.
protected  java.nio.ByteBuffer writeEight(int data)
           
protected  java.nio.ByteBuffer writeSix(java.lang.CharSequence data)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

DEFAULT_FILE_PERMISSION

public static final int DEFAULT_FILE_PERMISSION
See Also:
Constant Field Values

DEFAULT_DIRECTORY_PERMISSION

public static final int DEFAULT_DIRECTORY_PERMISSION
See Also:
Constant Field Values

FIFO

public static final int FIFO
See Also:
Constant Field Values

CDEV

public static final int CDEV
See Also:
Constant Field Values

DIR

public static final int DIR
See Also:
Constant Field Values

BDEV

public static final int BDEV
See Also:
Constant Field Values

FILE

public static final int FILE
See Also:
Constant Field Values

SYMLINK

public static final int SYMLINK
See Also:
Constant Field Values

SOCKET

public static final int SOCKET
See Also:
Constant Field Values

CPIO_HEADER

protected static final int CPIO_HEADER
See Also:
Constant Field Values

MAGIC

protected static final java.lang.CharSequence MAGIC

TRAILER

protected static final java.lang.String TRAILER
See Also:
Constant Field Values

charset

protected java.nio.charset.Charset charset

inode

protected int inode

type

protected int type

permissions

protected int permissions

uid

protected int uid

uname

protected java.lang.String uname

gid

protected int gid

gname

protected java.lang.String gname

nlink

protected int nlink

mtime

protected long mtime

filesize

protected int filesize

devMinor

protected int devMinor

devMajor

protected int devMajor

rdevMinor

protected int rdevMinor

rdevMajor

protected int rdevMajor

checksum

protected int checksum

name

protected java.lang.String name

flags

protected int flags
Constructor Detail

CpioHeader

public CpioHeader()

CpioHeader

public CpioHeader(java.lang.String name)

CpioHeader

public CpioHeader(java.io.File file)

CpioHeader

public CpioHeader(java.lang.String name,
                  java.io.File file)
Method Detail

getType

public int getType()

getPermissions

public int getPermissions()

getRdevMajor

public int getRdevMajor()

getRdevMinor

public int getRdevMinor()

getDevMajor

public int getDevMajor()

getDevMinor

public int getDevMinor()

getMtime

public int getMtime()

getInode

public int getInode()

getName

public java.lang.String getName()

getFlags

public int getFlags()

getMode

public int getMode()

setPermissions

public void setPermissions(int permissions)

setType

public void setType(int type)

setFileSize

public void setFileSize(int filesize)

setMtime

public void setMtime(long mtime)

setInode

public void setInode(int inode)

setFlags

public void setFlags(int flags)

getUname

public java.lang.String getUname()

getGname

public java.lang.String getGname()

setUname

public void setUname(java.lang.String uname)

setGname

public void setGname(java.lang.String gname)

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.


setLast

public void setLast()

setName

public void setName(java.lang.String name)

getFileSize

public int getFileSize()

writeSix

protected java.nio.ByteBuffer writeSix(java.lang.CharSequence data)

writeEight

protected java.nio.ByteBuffer writeEight(int data)

readSix

protected java.lang.CharSequence readSix(java.nio.CharBuffer buffer)

readEight

protected int readEight(java.nio.CharBuffer buffer)

readChars

protected java.lang.CharSequence readChars(java.nio.CharBuffer buffer,
                                           int length)

pad

protected java.lang.String pad(java.lang.CharSequence sequence,
                               int length)

skip

protected int skip(java.nio.channels.ReadableByteChannel channel,
                   int total)
            throws java.io.IOException
Throws:
java.io.IOException

skip

public int skip(java.nio.channels.WritableByteChannel channel,
                int total)
         throws java.io.IOException
Throws:
java.io.IOException

read

public int read(java.nio.channels.ReadableByteChannel channel,
                int total)
         throws java.io.IOException
Throws:
java.io.IOException

write

public int write(java.nio.channels.WritableByteChannel channel,
                 int total)
          throws java.io.IOException
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.

Throws:
java.io.IOException

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object