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...
|
| 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.
|
|
| 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.
|
|
| 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.
|
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.
◆ TarBuffer()
| ICSharpCode.SharpZipLib.Tar.TarBuffer.TarBuffer |
( |
| ) |
|
|
protected |
◆ Close()
| void ICSharpCode.SharpZipLib.Tar.TarBuffer.Close |
( |
| ) |
|
Close the TarBuffer. If this is an output buffer, also flush the current block before closing.
◆ CreateInputTarBuffer() [1/2]
| TarBuffer ICSharpCode.SharpZipLib.Tar.TarBuffer.CreateInputTarBuffer |
( |
Stream | inputStream | ) |
|
|
static |
Create TarBuffer for reading with default BlockFactor.
- Parameters
-
| inputStream | Stream to buffer |
- Returns
- A new TarBuffer suitable for input.
◆ CreateInputTarBuffer() [2/2]
| TarBuffer ICSharpCode.SharpZipLib.Tar.TarBuffer.CreateInputTarBuffer |
( |
Stream | inputStream, |
|
|
int | blockFactor ) |
|
static |
Construct TarBuffer for reading inputStream setting BlockFactor.
- Parameters
-
| inputStream | Stream to buffer |
| blockFactor | Blocking factor to apply |
- Returns
- A new TarBuffer suitable for input.
◆ CreateOutputTarBuffer() [1/2]
| TarBuffer ICSharpCode.SharpZipLib.Tar.TarBuffer.CreateOutputTarBuffer |
( |
Stream | outputStream | ) |
|
|
static |
Construct TarBuffer for writing with default BlockFactor.
- Parameters
-
| outputStream | output stream for buffer |
- Returns
- A new TarBuffer suitable for output.
◆ CreateOutputTarBuffer() [2/2]
| TarBuffer ICSharpCode.SharpZipLib.Tar.TarBuffer.CreateOutputTarBuffer |
( |
Stream | outputStream, |
|
|
int | blockFactor ) |
|
static |
Construct TarBuffer for writing Tar output to streams.
- Parameters
-
| outputStream | Output stream to write to. |
| blockFactor | Blocking factor to apply |
- Returns
- A new TarBuffer suitable for output.
◆ 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.
◆ 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
-
| block | The data block to check. |
- Returns
- Returns true if the block is an EOF block; false otherwise.
◆ 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
-
| block | The 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.
◆ ReadRecord()
| bool ICSharpCode.SharpZipLib.Tar.TarBuffer.ReadRecord |
( |
| ) |
|
|
private |
Read a record from data stream.
- Returns
- false if End-Of-File, else true.
◆ SkipBlock()
| void ICSharpCode.SharpZipLib.Tar.TarBuffer.SkipBlock |
( |
| ) |
|
Skip over a block on the input stream.
◆ WriteBlock() [1/2]
| void ICSharpCode.SharpZipLib.Tar.TarBuffer.WriteBlock |
( |
byte[] | block | ) |
|
Write a block of data to the archive.
- Parameters
-
| block | The data to write to the archive. |
◆ 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
-
| buffer | The buffer containing the record data to write. |
| offset | The offset of the record data within buffer. |
◆ 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.
◆ WriteRecord()
| void ICSharpCode.SharpZipLib.Tar.TarBuffer.WriteRecord |
( |
| ) |
|
|
private |
◆ blockFactor
◆ 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
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
◆ 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: