C# Class ICSharpCode.SharpZipLib.Tar.TarBuffer

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.

Show file Open project: icsharpcode/SharpZipLib Class Usage Examples

Public Methods

Method Description
Close ( ) : void

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

CreateInputTarBuffer ( Stream inputStream ) : TarBuffer

Create TarBuffer for reading with default BlockFactor

CreateInputTarBuffer ( Stream inputStream, int blockFactor ) : TarBuffer

Construct TarBuffer for reading inputStream setting BlockFactor

CreateOutputTarBuffer ( Stream outputStream ) : TarBuffer

Construct TarBuffer for writing with default BlockFactor

CreateOutputTarBuffer ( Stream outputStream, int blockFactor ) : TarBuffer

Construct TarBuffer for writing Tar output to streams.

Initialize ( int archiveBlockFactor ) : void

Initialization common to all constructors.

IsEndOfArchiveBlock ( byte block ) : bool

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

ReadBlock ( ) : byte[]

Read a block from the input stream.

SkipBlock ( ) : void

Skip over a block on the input stream.

WriteBlock ( byte block ) : void

Write a block of data to the archive.

WriteBlock ( byte buffer, int offset ) : void

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.

WriteFinalRecord ( ) : void

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.

WriteRecord ( ) : void

Write a TarBuffer record to the archive.

Protected Methods

Method Description
TarBuffer ( ) : System

Construct a default TarBuffer

Private Methods

Method Description
GetBlockFactor ( ) : int
GetCurrentBlockNum ( ) : int
GetCurrentRecordNum ( ) : int
GetRecordSize ( ) : int
IsEOFBlock ( byte block ) : bool
ReadRecord ( ) : bool

Read a record from data stream.

Method Details

Close() public method

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

CreateInputTarBuffer() public static method

Create TarBuffer for reading with default BlockFactor
public static CreateInputTarBuffer ( Stream inputStream ) : TarBuffer
inputStream Stream Stream to buffer
return TarBuffer

CreateInputTarBuffer() public static method

Construct TarBuffer for reading inputStream setting BlockFactor
public static CreateInputTarBuffer ( Stream inputStream, int blockFactor ) : TarBuffer
inputStream Stream Stream to buffer
blockFactor int Blocking factor to apply
return TarBuffer

CreateOutputTarBuffer() public static method

Construct TarBuffer for writing with default BlockFactor
public static CreateOutputTarBuffer ( Stream outputStream ) : TarBuffer
outputStream Stream output stream for buffer
return TarBuffer

CreateOutputTarBuffer() public static method

Construct TarBuffer for writing Tar output to streams.
public static CreateOutputTarBuffer ( Stream outputStream, int blockFactor ) : TarBuffer
outputStream Stream Output stream to write to.
blockFactor int Blocking factor to apply
return TarBuffer

Initialize() public method

Initialization common to all constructors.
public Initialize ( int archiveBlockFactor ) : void
archiveBlockFactor int
return void

IsEndOfArchiveBlock() public static method

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
public static IsEndOfArchiveBlock ( byte block ) : bool
block byte The data block to check.
return bool

ReadBlock() public method

Read a block from the input stream.
public ReadBlock ( ) : byte[]
return byte[]

SkipBlock() public method

Skip over a block on the input stream.
public SkipBlock ( ) : void
return void

TarBuffer() protected method

Construct a default TarBuffer
protected TarBuffer ( ) : System
return System

WriteBlock() public method

Write a block of data to the archive.
public WriteBlock ( byte block ) : void
block byte /// The data to write to the archive. ///
return void

WriteBlock() public method

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.
public WriteBlock ( byte buffer, int offset ) : void
buffer byte /// The buffer containing the record data to write. ///
offset int /// The offset of the record data within buffer. ///
return void

WriteFinalRecord() public method

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.
public WriteFinalRecord ( ) : void
return void

WriteRecord() public method

Write a TarBuffer record to the archive.
public WriteRecord ( ) : void
return void