C# Class ICSharpCode.SharpZipLib.Tar.TarInputStream

The TarInputStream reads a UNIX tar archive as an InputStream. methods are provided to position at each successive entry in the archive, and the read each entry as a normal input stream using read().
Inheritance: Stream
Show file Open project: icsharpcode/SharpZipLib Class Usage Examples

Protected Properties

Property Type Description
entryFactory IEntryFactory
entryOffset long
entrySize long
hasHitEOF bool
readBuffer byte[]
tarBuffer TarBuffer

Public Methods

Method Description
CopyEntryContents ( Stream outputStream ) : void

Copies the contents of the current tar archive entry directly into an output stream.

Flush ( ) : void

Flushes the baseInputStream

GetNextEntry ( ) : TarEntry

Get the next entry in this tar archive. This will skip over any remaining data in the current entry, if there is one, and place the input stream at the header of the next entry, and read the header and instantiate a new TarEntry from the header bytes and return that entry. If there are no more entries in the archive, null will be returned to indicate that the end of the archive has been reached.

Mark ( int markLimit ) : void

Since we do not support marking just yet, we do nothing.

Read ( byte buffer, int offset, int count ) : int

Reads bytes from the current tar archive entry. This method is aware of the boundaries of the current entry in the archive and will deal with them appropriately

ReadByte ( ) : int

Reads a byte from the current tar archive entry.

Reset ( ) : void

Since we do not support marking just yet, we do nothing.

Seek ( long offset, SeekOrigin origin ) : long

Set the streams position. This operation is not supported and will throw a NotSupportedException

SetEntryFactory ( IEntryFactory factory ) : void

Set the entry factory for this instance.

SetLength ( long value ) : void

Sets the length of the stream This operation is not supported and will throw a NotSupportedException

Skip ( long skipCount ) : void

Skip bytes in the input buffer. This skips bytes in the current entry's data, not the entire archive, and will stop at the end of the current entry's data if the number to skip extends beyond that point.

TarInputStream ( Stream inputStream ) : System

Construct a TarInputStream with default block factor

TarInputStream ( Stream inputStream, int blockFactor ) : System

Construct a TarInputStream with user specified block factor

Write ( byte buffer, int offset, int count ) : void

Writes a block of bytes to this stream using data from a buffer. This operation is not supported and will throw a NotSupportedException

WriteByte ( byte value ) : void

Writes a byte to the current position in the file stream. This operation is not supported and will throw a NotSupportedException

Protected Methods

Method Description
Dispose ( bool disposing ) : void

Closes this stream. Calls the TarBuffer's close() method. The underlying stream is closed by the TarBuffer.

SkipToNextEntry ( ) : void

Private Methods

Method Description
GetRecordSize ( ) : int

Method Details

CopyEntryContents() public method

Copies the contents of the current tar archive entry directly into an output stream.
public CopyEntryContents ( Stream outputStream ) : void
outputStream Stream /// The OutputStream into which to write the entry's data. ///
return void

Dispose() protected method

Closes this stream. Calls the TarBuffer's close() method. The underlying stream is closed by the TarBuffer.
protected Dispose ( bool disposing ) : void
disposing bool
return void

Flush() public method

Flushes the baseInputStream
public Flush ( ) : void
return void

GetNextEntry() public method

Get the next entry in this tar archive. This will skip over any remaining data in the current entry, if there is one, and place the input stream at the header of the next entry, and read the header and instantiate a new TarEntry from the header bytes and return that entry. If there are no more entries in the archive, null will be returned to indicate that the end of the archive has been reached.
public GetNextEntry ( ) : TarEntry
return TarEntry

Mark() public method

Since we do not support marking just yet, we do nothing.
public Mark ( int markLimit ) : void
markLimit int /// The limit to mark. ///
return void

Read() public method

Reads bytes from the current tar archive entry. This method is aware of the boundaries of the current entry in the archive and will deal with them appropriately
public Read ( byte buffer, int offset, int count ) : int
buffer byte /// The buffer into which to place bytes read. ///
offset int /// The offset at which to place bytes read. ///
count int /// The number of bytes to read. ///
return int

ReadByte() public method

Reads a byte from the current tar archive entry.
public ReadByte ( ) : int
return int

Reset() public method

Since we do not support marking just yet, we do nothing.
public Reset ( ) : void
return void

Seek() public method

Set the streams position. This operation is not supported and will throw a NotSupportedException
Any access
public Seek ( long offset, SeekOrigin origin ) : long
offset long The offset relative to the origin to seek to.
origin SeekOrigin The to start seeking from.
return long

SetEntryFactory() public method

Set the entry factory for this instance.
public SetEntryFactory ( IEntryFactory factory ) : void
factory IEntryFactory The factory for creating new entries
return void

SetLength() public method

Sets the length of the stream This operation is not supported and will throw a NotSupportedException
Any access
public SetLength ( long value ) : void
value long The new stream length.
return void

Skip() public method

Skip bytes in the input buffer. This skips bytes in the current entry's data, not the entire archive, and will stop at the end of the current entry's data if the number to skip extends beyond that point.
public Skip ( long skipCount ) : void
skipCount long /// The number of bytes to skip. ///
return void

SkipToNextEntry() protected method

protected SkipToNextEntry ( ) : void
return void

TarInputStream() public method

Construct a TarInputStream with default block factor
public TarInputStream ( Stream inputStream ) : System
inputStream Stream stream to source data from
return System

TarInputStream() public method

Construct a TarInputStream with user specified block factor
public TarInputStream ( Stream inputStream, int blockFactor ) : System
inputStream Stream stream to source data from
blockFactor int block factor to apply to archive
return System

Write() public method

Writes a block of bytes to this stream using data from a buffer. This operation is not supported and will throw a NotSupportedException
Any access
public Write ( byte buffer, int offset, int count ) : void
buffer byte The buffer containing bytes to write.
offset int The offset in the buffer of the frist byte to write.
count int The number of bytes to write.
return void

WriteByte() public method

Writes a byte to the current position in the file stream. This operation is not supported and will throw a NotSupportedException
Any access
public WriteByte ( byte value ) : void
value byte The byte value to write.
return void

Property Details

entryFactory protected property

Factory used to create TarEntry or descendant class instance
protected IEntryFactory entryFactory
return IEntryFactory

entryOffset protected property

Number of bytes read for this entry so far
protected long entryOffset
return long

entrySize protected property

Size of this entry as recorded in header
protected long entrySize
return long

hasHitEOF protected property

Flag set when last block has been read
protected bool hasHitEOF
return bool

readBuffer protected property

Buffer used with calls to Read()
protected byte[] readBuffer
return byte[]

tarBuffer protected property

Working buffer
protected TarBuffer,ICSharpCode.SharpZipLib.Tar tarBuffer
return TarBuffer