org.freecompany.redline.payload
Class CpioHeader

java.lang.Object
  extended by org.freecompany.redline.payload.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 int BDEV
           
static int CDEV
           
protected  Charset charset
           
protected  int checksum
           
protected static int CPIO_HEADER
           
static int DEFAULT_DIRECTORY_PERMISSION
           
static int DEFAULT_FILE_PERMISSION
           
static String DEFAULT_GROUP
           
static String DEFAULT_USERNAME
           
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  String gname
           
protected  int inode
           
protected static String MAGIC
           
protected  long mtime
           
protected  String name
           
protected  int nlink
           
protected  int permissions
           
protected  int rdevMajor
           
protected  int rdevMinor
           
static int SOCKET
           
static int SYMLINK
           
protected static String TRAILER
           
protected  int type
           
protected  int uid
           
protected  String uname
           
 
Constructor Summary
CpioHeader()
           
CpioHeader(File file)
           
CpioHeader(String name)
           
CpioHeader(String name, File file)
           
CpioHeader(String name, URL url)
           
 
Method Summary
 int getDevMajor()
           
 int getDevMinor()
           
 int getFileSize()
           
 int getFlags()
           
 String getGname()
           
 int getInode()
           
 int getMode()
           
 int getMtime()
           
 String getName()
           
 int getPermissions()
           
 int getRdevMajor()
           
 int getRdevMinor()
           
 int getType()
           
 String getUname()
           
 boolean isLast()
          Test to see if this is the last header, and is therefore the end of the archive.
protected  String pad(CharSequence sequence, int length)
           
 int read(ReadableByteChannel channel, int total)
           
protected  CharSequence readChars(CharBuffer buffer, int length)
           
protected  int readEight(CharBuffer buffer)
           
protected  CharSequence readSix(CharBuffer buffer)
           
 void setFileSize(int filesize)
           
 void setFlags(int flags)
           
 void setGname(String gname)
           
 void setInode(int inode)
           
 void setLast()
           
 void setMtime(long mtime)
           
 void setName(String name)
           
 void setPermissions(int permissions)
           
 void setType(int type)
           
 void setUname(String uname)
           
protected  int skip(ReadableByteChannel channel, int total)
           
 int skip(WritableByteChannel channel, int total)
           
 String toString()
           
 int write(WritableByteChannel channel, int total)
          Writed the content for the CPIO header, including the name immediately following.
protected  ByteBuffer writeEight(int data)
           
protected  ByteBuffer writeSix(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

DEFAULT_USERNAME

public static final String DEFAULT_USERNAME
See Also:
Constant Field Values

DEFAULT_GROUP

public static final String DEFAULT_GROUP
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 String MAGIC
See Also:
Constant Field Values

TRAILER

protected static final String TRAILER
See Also:
Constant Field Values

charset

protected Charset charset

inode

protected int inode

type

protected int type

permissions

protected int permissions

uid

protected int uid

uname

protected String uname

gid

protected int gid

gname

protected 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 String name

flags

protected int flags
Constructor Detail

CpioHeader

public CpioHeader()

CpioHeader

public CpioHeader(String name)

CpioHeader

public CpioHeader(File file)

CpioHeader

public CpioHeader(String name,
                  URL url)

CpioHeader

public CpioHeader(String name,
                  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 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 String getUname()

getGname

public String getGname()

setUname

public void setUname(String uname)

setGname

public void setGname(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(String name)

getFileSize

public int getFileSize()

writeSix

protected ByteBuffer writeSix(CharSequence data)

writeEight

protected ByteBuffer writeEight(int data)

readSix

protected CharSequence readSix(CharBuffer buffer)

readEight

protected int readEight(CharBuffer buffer)

readChars

protected CharSequence readChars(CharBuffer buffer,
                                 int length)

pad

protected String pad(CharSequence sequence,
                     int length)

skip

protected int skip(ReadableByteChannel channel,
                   int total)
            throws IOException
Throws:
IOException

skip

public int skip(WritableByteChannel channel,
                int total)
         throws IOException
Throws:
IOException

read

public int read(ReadableByteChannel channel,
                int total)
         throws IOException
Throws:
IOException

write

public int write(WritableByteChannel channel,
                 int total)
          throws 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:
IOException

toString

public String toString()
Overrides:
toString in class Object


Copyright © 2014. All Rights Reserved.