Maven module :un.storage : archive-tar :
Class : un.storage.archive.tar.TarBuffer
Extends/Implements : -
Subclasses : -

The TarBuffer class implements the tar archive concept of a buffered input
stream. This concept goes back to the days of blocked tape drives and special
io devices. In the Java universe, the only real function that this class
performs is to ensure that files have the correct "block" size, or other tars
will complain.

You should never have a need to access this class
directly. TarBuffers are created by Tar IO Streams.

@author Timothy Gerard Endres, time@trustice.com.



Variables : DEFAULT_RCDSIZE, DEFAULT_BLKSIZE
Functions : TarBuffer, TarBuffer, TarBuffer, TarBuffer, TarBuffer, TarBuffer, getBlockSize, getRecordSize, isEOFRecord, skipRecord, readRecord, getCurrentBlockNum, getCurrentRecordNum, writeRecord, writeRecord, close


public int DEFAULT_RCDSIZE

public int DEFAULT_BLKSIZE


public void TarBuffer (ByteInputStream inStream)

public void TarBuffer (ByteInputStream inStream, int blockSize)

public void TarBuffer (ByteInputStream inStream, int blockSize, int recordSize)

public void TarBuffer (ByteOutputStream outStream)

public void TarBuffer (ByteOutputStream outStream, int blockSize)

public void TarBuffer (ByteOutputStream outStream, int blockSize, int recordSize)


Get the TAR Buffer's block size. Blocks consist of multiple records.
public int getBlockSize ()


Get the TAR Buffer's record size.
public int getRecordSize ()


Determine if an archive record indicate End of Archive. End of archive is
indicated by a record that consists entirely of null bytes.
param  record The record data to check.
public boolean isEOFRecord (byte[] record)


Skip over a record on the input stream.
public void skipRecord ()


Read a record from the input stream and return the data.
return  The record data.
public byte[] readRecord ()


Get the current block number, zero based.
return  The current zero based block number.
public int getCurrentBlockNum ()


Get the current record number, within the current block, zero based.
Thus, current offset = (currentBlockNum * recsPerBlk) + currentRecNum.
return  The current zero based record number.
public int getCurrentRecordNum ()


Write an archive record to the archive.
param  record The record data to write to the archive.
public void writeRecord (byte[] record)


Write an archive record to the archive, where the record may be inside of
a larger array buffer. The buffer must be "offset plus record size" long.

@param buf The buffer containing the record data to write.
@param offset The offset of the record data within buf.
public void writeRecord (byte[] buf, int offset)


Close the TarBuffer. If this is an output buffer, also flush the current
block before closing.
public void close ()