Fingerprint_Card
Loading...
Searching...
No Matches
ICSharpCode.SharpZipLib.Tar.TarBuffer Class Reference

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 C# universe, the only real function that this class performs is to ensure that files have the correct "record" size, or other tars will complain. More...

Public Member Functions

int GetRecordSize ()
 Get the TAR Buffer's record size.
int GetBlockFactor ()
 Get the TAR Buffer's block factor.
bool IsEOFBlock (byte[] block)
 Determine if an archive block indicates End of Archive. End of archive is indicated by a block that consists entirely of null bytes. All remaining blocks for the record should also be null's However some older tars only do a couple of null blocks (Old GNU tar for one) and also partial records.
void SkipBlock ()
 Skip over a block on the input stream.
byte[] ReadBlock ()
 Read a block from the input stream.
int GetCurrentBlockNum ()
 Get the current block number, within the current record, zero based.
int GetCurrentRecordNum ()
 Get the current record number.
void WriteBlock (byte[] block)
 Write a block of data to the archive.
void WriteBlock (byte[] buffer, int offset)
 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.
void Close ()
 Close the TarBuffer. If this is an output buffer, also flush the current block before closing.

Static Public Member Functions

static TarBuffer CreateInputTarBuffer (Stream inputStream)
 Create TarBuffer for reading with default BlockFactor.
static TarBuffer CreateInputTarBuffer (Stream inputStream, int blockFactor)
 Construct TarBuffer for reading inputStream setting BlockFactor.
static TarBuffer CreateOutputTarBuffer (Stream outputStream)
 Construct TarBuffer for writing with default BlockFactor.
static TarBuffer CreateOutputTarBuffer (Stream outputStream, int blockFactor)
 Construct TarBuffer for writing Tar output to streams.
static bool IsEndOfArchiveBlock (byte[] block)
 Determine if an archive block indicates the End of an Archive has been reached. End of archive is indicated by a block that consists entirely of null bytes. All remaining blocks for the record should also be null's However some older tars only do a couple of null blocks (Old GNU tar for one) and also partial records.

Static Public Attributes

const int BlockSize = 512
 The size of a block in a tar archive in bytes.
const int DefaultBlockFactor = 20
 The number of blocks in a default record.
const int DefaultRecordSize = BlockSize * DefaultBlockFactor
 The size in bytes of a default record.

Protected Member Functions

 TarBuffer ()
 Construct a default TarBuffer.

Properties

int RecordSize [get]
 Get the record size for this buffer.
int BlockFactor [get]
 Get the Blocking factor for the buffer.
int CurrentBlock [get]
 Get the current block number, within the current record, zero based.
bool IsStreamOwner [get, set]
 Get/set flag indicating ownership of the underlying stream. When the flag is true Close will close the underlying stream also.
int CurrentRecord [get]
 Get the current record number.

Private Member Functions

void Initialize (int archiveBlockFactor)
 Initialization common to all constructors.
bool ReadRecord ()
 Read a record from data stream.
void WriteRecord ()
 Write a TarBuffer record to the archive.
void WriteFinalRecord ()
 WriteFinalRecord writes the current record buffer to output any unwritten data is present.

Private Attributes

Stream inputStream
Stream outputStream
byte[] recordBuffer
int currentBlockIndex
int currentRecordIndex
int recordSize = DefaultRecordSize
int blockFactor = DefaultBlockFactor
bool isStreamOwner_ = true

Detailed Description

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 C# universe, the only real function that this class performs is to ensure that files have the correct "record" size, or other tars will complain.

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

Constructor & Destructor Documentation

◆ TarBuffer()

ICSharpCode.SharpZipLib.Tar.TarBuffer.TarBuffer ( )
protected

Construct a default TarBuffer.

Here is the caller graph for this function:

Member Function Documentation

◆ Close()

void ICSharpCode.SharpZipLib.Tar.TarBuffer.Close ( )

Close the TarBuffer. If this is an output buffer, also flush the current block before closing.

Here is the call graph for this function:

◆ CreateInputTarBuffer() [1/2]

TarBuffer ICSharpCode.SharpZipLib.Tar.TarBuffer.CreateInputTarBuffer ( Stream inputStream)
static

Create TarBuffer for reading with default BlockFactor.

Parameters
inputStreamStream to buffer
Returns
A new TarBuffer suitable for input.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ CreateInputTarBuffer() [2/2]

TarBuffer ICSharpCode.SharpZipLib.Tar.TarBuffer.CreateInputTarBuffer ( Stream inputStream,
int blockFactor )
static

Construct TarBuffer for reading inputStream setting BlockFactor.

Parameters
inputStreamStream to buffer
blockFactorBlocking factor to apply
Returns
A new TarBuffer suitable for input.
Here is the call graph for this function:

◆ CreateOutputTarBuffer() [1/2]

TarBuffer ICSharpCode.SharpZipLib.Tar.TarBuffer.CreateOutputTarBuffer ( Stream outputStream)
static

Construct TarBuffer for writing with default BlockFactor.

Parameters
outputStreamoutput stream for buffer
Returns
A new TarBuffer suitable for output.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ CreateOutputTarBuffer() [2/2]

TarBuffer ICSharpCode.SharpZipLib.Tar.TarBuffer.CreateOutputTarBuffer ( Stream outputStream,
int blockFactor )
static

Construct TarBuffer for writing Tar output to streams.

Parameters
outputStreamOutput stream to write to.
blockFactorBlocking factor to apply
Returns
A new TarBuffer suitable for output.
Here is the call graph for this function:

◆ GetBlockFactor()

int ICSharpCode.SharpZipLib.Tar.TarBuffer.GetBlockFactor ( )

Get the TAR Buffer's block factor.

Returns
The block factor; the number of blocks per record.

◆ GetCurrentBlockNum()

int ICSharpCode.SharpZipLib.Tar.TarBuffer.GetCurrentBlockNum ( )

Get the current block number, within the current record, zero based.

Returns
The current zero based block number.

The absolute block number = (record number * block factor) + block number.

◆ GetCurrentRecordNum()

int ICSharpCode.SharpZipLib.Tar.TarBuffer.GetCurrentRecordNum ( )

Get the current record number.

Returns
The current zero based record number.

◆ GetRecordSize()

int ICSharpCode.SharpZipLib.Tar.TarBuffer.GetRecordSize ( )

Get the TAR Buffer's record size.

Returns
The record size in bytes. This is equal to the BlockFactor multiplied by the BlockSize

◆ Initialize()

void ICSharpCode.SharpZipLib.Tar.TarBuffer.Initialize ( int archiveBlockFactor)
private

Initialization common to all constructors.

Here is the caller graph for this function:

◆ IsEndOfArchiveBlock()

bool ICSharpCode.SharpZipLib.Tar.TarBuffer.IsEndOfArchiveBlock ( byte[] block)
static

Determine if an archive block indicates the End of an Archive has been reached. End of archive is indicated by a block that consists entirely of null bytes. All remaining blocks for the record should also be null's However some older tars only do a couple of null blocks (Old GNU tar for one) and also partial records.

Parameters
blockThe data block to check.
Returns
Returns true if the block is an EOF block; false otherwise.
Here is the caller graph for this function:

◆ IsEOFBlock()

bool ICSharpCode.SharpZipLib.Tar.TarBuffer.IsEOFBlock ( byte[] block)

Determine if an archive block indicates End of Archive. End of archive is indicated by a block that consists entirely of null bytes. All remaining blocks for the record should also be null's However some older tars only do a couple of null blocks (Old GNU tar for one) and also partial records.

Parameters
blockThe data block to check.
Returns
Returns true if the block is an EOF block; false otherwise.

◆ ReadBlock()

byte[] ICSharpCode.SharpZipLib.Tar.TarBuffer.ReadBlock ( )

Read a block from the input stream.

Returns
The block of data read.
Here is the call graph for this function:

◆ ReadRecord()

bool ICSharpCode.SharpZipLib.Tar.TarBuffer.ReadRecord ( )
private

Read a record from data stream.

Returns
false if End-Of-File, else true.
Here is the caller graph for this function:

◆ SkipBlock()

void ICSharpCode.SharpZipLib.Tar.TarBuffer.SkipBlock ( )

Skip over a block on the input stream.

Here is the call graph for this function:

◆ WriteBlock() [1/2]

void ICSharpCode.SharpZipLib.Tar.TarBuffer.WriteBlock ( byte[] block)

Write a block of data to the archive.

Parameters
blockThe data to write to the archive.
Here is the call graph for this function:

◆ WriteBlock() [2/2]

void ICSharpCode.SharpZipLib.Tar.TarBuffer.WriteBlock ( byte[] buffer,
int offset )

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.

Parameters
bufferThe buffer containing the record data to write.
offsetThe offset of the record data within buffer.
Here is the call graph for this function:

◆ WriteFinalRecord()

void ICSharpCode.SharpZipLib.Tar.TarBuffer.WriteFinalRecord ( )
private

WriteFinalRecord writes the current record buffer to output any unwritten data is present.

Any trailing bytes are set to zero which is by definition correct behaviour for the end of a tar stream.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ WriteRecord()

void ICSharpCode.SharpZipLib.Tar.TarBuffer.WriteRecord ( )
private

Write a TarBuffer record to the archive.

Here is the caller graph for this function:

Member Data Documentation

◆ blockFactor

int ICSharpCode.SharpZipLib.Tar.TarBuffer.blockFactor = DefaultBlockFactor
private

◆ BlockSize

const int ICSharpCode.SharpZipLib.Tar.TarBuffer.BlockSize = 512
static

The size of a block in a tar archive in bytes.

This is 512 bytes.

◆ currentBlockIndex

int ICSharpCode.SharpZipLib.Tar.TarBuffer.currentBlockIndex
private

◆ currentRecordIndex

int ICSharpCode.SharpZipLib.Tar.TarBuffer.currentRecordIndex
private

◆ DefaultBlockFactor

const int ICSharpCode.SharpZipLib.Tar.TarBuffer.DefaultBlockFactor = 20
static

The number of blocks in a default record.

The default value is 20 blocks per record.

◆ DefaultRecordSize

const int ICSharpCode.SharpZipLib.Tar.TarBuffer.DefaultRecordSize = BlockSize * DefaultBlockFactor
static

The size in bytes of a default record.

The default size is 10KB.

◆ inputStream

Stream ICSharpCode.SharpZipLib.Tar.TarBuffer.inputStream
private

◆ isStreamOwner_

bool ICSharpCode.SharpZipLib.Tar.TarBuffer.isStreamOwner_ = true
private

◆ outputStream

Stream ICSharpCode.SharpZipLib.Tar.TarBuffer.outputStream
private

◆ recordBuffer

byte [] ICSharpCode.SharpZipLib.Tar.TarBuffer.recordBuffer
private

◆ recordSize

int ICSharpCode.SharpZipLib.Tar.TarBuffer.recordSize = DefaultRecordSize
private

Property Documentation

◆ BlockFactor

int ICSharpCode.SharpZipLib.Tar.TarBuffer.BlockFactor
get

Get the Blocking factor for the buffer.

This is the number of blocks in each record.

◆ CurrentBlock

int ICSharpCode.SharpZipLib.Tar.TarBuffer.CurrentBlock
get

Get the current block number, within the current record, zero based.

Block numbers are zero based values

See also
RecordSize

◆ CurrentRecord

int ICSharpCode.SharpZipLib.Tar.TarBuffer.CurrentRecord
get

Get the current record number.

Returns
The current zero based record number.

◆ IsStreamOwner

bool ICSharpCode.SharpZipLib.Tar.TarBuffer.IsStreamOwner
getset

Get/set flag indicating ownership of the underlying stream. When the flag is true Close will close the underlying stream also.

◆ RecordSize

int ICSharpCode.SharpZipLib.Tar.TarBuffer.RecordSize
get

Get the record size for this buffer.

The record size in bytes. This is equal to the BlockFactor multiplied by the BlockSize


The documentation for this class was generated from the following file: