java.lang.Object
org.xbib.rpm.payload.CpioHeader
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
Fields -
Constructor Summary
ConstructorsConstructorDescriptionCpioHeader(String name) CpioHeader(String name, URL url) CpioHeader(String name, Path path) -
Method Summary
Modifier and TypeMethodDescriptionstatic intdifference(int start, int boundary) intintintintgetFlags()intgetGid()intgetInode()intgetMode()intgetMtime()getName()intintintintgetType()intgetUid()intbooleanisLast()Test to see if this is the last header, and is therefore the end of the archive.static StringnormalizePath(String path) 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) voidsetGid(int gid) voidsetInode(int inode) voidsetLast()voidsetMtime(long mtime) voidvoidsetPermissions(int permissions) voidsetType(int type) voidsetUid(int uid) voidsetVerifyFlags(int verifyFlags) protected intskip(ReadableByteChannel channel, int total) intskip(WritableByteChannel channel, int total) toString()intwrite(WritableByteChannel channel, int total) Write the content for the CPIO header, including the name immediately following.protected ByteBufferwriteEight(int data) protected ByteBufferwriteSix(CharSequence data)
-
Field Details
-
FIFO
public static final int FIFO- See Also:
-
CDEV
public static final int CDEV- See Also:
-
DIR
public static final int DIR- See Also:
-
BDEV
public static final int BDEV- See Also:
-
FILE
public static final int FILE- See Also:
-
SYMLINK
public static final int SYMLINK- See Also:
-
SOCKET
public static final int SOCKET- See Also:
-
type
protected int type -
permissions
protected int permissions -
name
-
flags
protected int flags
-
-
Constructor Details
-
CpioHeader
public CpioHeader() -
CpioHeader
-
CpioHeader
-
CpioHeader
- Throws:
IOException
-
-
Method Details
-
normalizePath
-
difference
public static int difference(int start, int boundary) -
getType
public int getType() -
setType
public void setType(int type) -
getPermissions
public int getPermissions() -
setPermissions
public void setPermissions(int permissions) -
getRdevMajor
public int getRdevMajor() -
getRdevMinor
public int getRdevMinor() -
getDevMajor
public int getDevMajor() -
getDevMinor
public int getDevMinor() -
getMtime
public int getMtime() -
setMtime
public void setMtime(long mtime) -
getInode
public int getInode() -
setInode
public void setInode(int inode) -
setName
-
getName
-
setFlags
public void setFlags(int flags) -
getFlags
public int getFlags() -
setVerifyFlags
public void setVerifyFlags(int verifyFlags) -
getVerifyFlags
public int getVerifyFlags() -
getMode
public int getMode() -
setUid
public void setUid(int uid) -
getUid
public int getUid() -
setGid
public void setGid(int gid) -
getGid
public int getGid() -
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.- Returns:
- true if last, false if not
-
setLast
public void setLast() -
getFileSize
public int getFileSize() -
setFileSize
public void setFileSize(int filesize) -
writeSix
-
writeEight
-
readSix
-
readEight
-
readChars
-
pad
-
skip
- Throws:
IOException
-
skip
- Throws:
IOException
-
read
- Throws:
IOException
-
write
Write 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.- Parameters:
channel- which channel to write ontotal- current size of header?- Returns:
- total written and skipped
- Throws:
IOException- there was an IO error
-
toString
-