Fingerprint_Card
Loading...
Searching...
No Matches
ICSharpCode.SharpZipLib.LZW.LzwInputStream Class Reference

This filter stream is used to decompress a LZW format stream. Specifically, a stream that uses the LZC compression method. This file format is usually associated with the .Z file extension. More...

Inheritance diagram for ICSharpCode.SharpZipLib.LZW.LzwInputStream:
Collaboration diagram for ICSharpCode.SharpZipLib.LZW.LzwInputStream:

Public Member Functions

 LzwInputStream (Stream baseInputStream)
 Creates a LzwInputStream.
override int ReadByte ()
 See System.IO.Stream.ReadByte
override int Read (byte[] buffer, int offset, int count)
 Reads decompressed data into the provided buffer byte array.
override void Flush ()
 Flushes the baseInputStream.
override long Seek (long offset, SeekOrigin origin)
 Sets the position within the current stream Always throws a NotSupportedException.
override void SetLength (long value)
 Set the length of the current stream Always throws a NotSupportedException.
override void Write (byte[] buffer, int offset, int count)
 Writes a sequence of bytes to stream and advances the current position This method always throws a NotSupportedException.
override void WriteByte (byte value)
 Writes one byte to the current stream and advances the current position Always throws a NotSupportedException.
override IAsyncResult BeginWrite (byte[] buffer, int offset, int count, AsyncCallback callback, object state)
 Entry point to begin an asynchronous write. Always throws a NotSupportedException.
override void Close ()
 Closes the input stream. When IsStreamOwner is true the underlying stream is also closed.

Properties

bool IsStreamOwner [get, set]
 Get/set flag indicating ownership of underlying stream. When the flag is true Close will close the underlying stream also.
override bool CanRead [get]
 Gets a value indicating whether the current stream supports reading.
override bool CanSeek [get]
 Gets a value of false indicating seeking is not supported for this stream.
override bool CanWrite [get]
 Gets a value of false indicating that this stream is not writeable.
override long Length [get]
 A value representing the length of the stream in bytes.
override long Position [get, set]
 The current position within the stream. Throws a NotSupportedException when attempting to set the position.

Private Member Functions

int ResetBuf (int bitPosition)
 Moves the unread data in the buffer to the beginning and resets the pointers.
void Fill ()
void ParseHeader ()

Private Attributes

Stream baseInputStream
bool isStreamOwner = true
 Flag indicating wether this instance is designated the stream owner. When closing if this flag is true the underlying stream is closed.
bool isClosed
 Flag indicating wether this instance has been closed or not.
readonly byte[] one = new byte[1]
bool headerParsed
int[] tabPrefix
byte[] tabSuffix
readonly int[] zeros = new int[256]
byte[] stack
bool blockMode
int nBits
int maxBits
int maxMaxCode
int maxCode
int bitMask
int oldCode
byte finChar
int stackP
int freeEnt
readonly byte[] data = new byte[1024 * 8]
int bitPos
int end
int got
bool eof

Static Private Attributes

const int TBL_CLEAR = 0x100
const int TBL_FIRST = TBL_CLEAR + 1
const int EXTRA = 64

Detailed Description

This filter stream is used to decompress a LZW format stream. Specifically, a stream that uses the LZC compression method. This file format is usually associated with the .Z file extension.

See http://en.wikipedia.org/wiki/Compress See http://wiki.wxwidgets.org/Development:_Z_File_Format

The file header consists of 3 (or optionally 4) bytes. The first two bytes contain the magic marker "0x1f 0x9d", followed by a byte of flags.

Based on Java code by Ronald Tschalar, which in turn was based on the unlzw.c code in the gzip package.

This sample shows how to unzip a compressed file

using System;
using System.IO;
class MainClass
{
public static void Main(string[] args)
{
using (Stream inStream = new LzwInputStream(File.OpenRead(args[0])))
using (FileStream outStream = File.Create(Path.GetFileNameWithoutExtension(args[0]))) {
byte[] buffer = new byte[4096];
StreamUtils.Copy(inStream, outStream, buffer);
// OR
inStream.Read(buffer, 0, buffer.Length);
// now do something with the buffer
}
}
} <br>
Zwipe.Test.Tools.Entities.File File
Definition ExportsTest.cs:6
Provides simple Stream" utilities.
Definition StreamUtils.cs:45
static void Copy(Stream source, Stream destination, byte[] buffer)
Copy the contents of one Stream to another.
Definition StreamUtils.cs:102
LzwInputStream(Stream baseInputStream)
Creates a LzwInputStream.
Definition LzwInputStream.cs:101
Definition FileSystemScanner.cs:40
Definition LzwConstants.cs:36

Constructor & Destructor Documentation

◆ LzwInputStream()

ICSharpCode.SharpZipLib.LZW.LzwInputStream.LzwInputStream ( Stream baseInputStream)

Creates a LzwInputStream.

Parameters
baseInputStreamThe stream to read compressed data from (baseInputStream LZW format)

Member Function Documentation

◆ BeginWrite()

override IAsyncResult ICSharpCode.SharpZipLib.LZW.LzwInputStream.BeginWrite ( byte[] buffer,
int offset,
int count,
AsyncCallback callback,
object state )

Entry point to begin an asynchronous write. Always throws a NotSupportedException.

Parameters
bufferThe buffer to write data from
offsetOffset of first byte to write
countThe maximum number of bytes to write
callbackThe method to be called when the asynchronous write operation is completed
stateA user-provided object that distinguishes this particular asynchronous write request from other requests
Returns
An IAsyncResult that references the asynchronous write
Exceptions
NotSupportedExceptionAny access

◆ Close()

override void ICSharpCode.SharpZipLib.LZW.LzwInputStream.Close ( )

Closes the input stream. When IsStreamOwner is true the underlying stream is also closed.

◆ Fill()

void ICSharpCode.SharpZipLib.LZW.LzwInputStream.Fill ( )
private
Here is the caller graph for this function:

◆ Flush()

override void ICSharpCode.SharpZipLib.LZW.LzwInputStream.Flush ( )

Flushes the baseInputStream.

◆ ParseHeader()

void ICSharpCode.SharpZipLib.LZW.LzwInputStream.ParseHeader ( )
private
Here is the caller graph for this function:

◆ Read()

override int ICSharpCode.SharpZipLib.LZW.LzwInputStream.Read ( byte[] buffer,
int offset,
int count )

Reads decompressed data into the provided buffer byte array.

Parameters
bufferThe array to read and decompress data into
offsetThe offset indicating where the data should be placed
countThe number of bytes to decompress
Returns
The number of bytes read. Zero signals the end of stream
Here is the call graph for this function:
Here is the caller graph for this function:

◆ ReadByte()

override int ICSharpCode.SharpZipLib.LZW.LzwInputStream.ReadByte ( )

See System.IO.Stream.ReadByte

Returns
Here is the call graph for this function:

◆ ResetBuf()

int ICSharpCode.SharpZipLib.LZW.LzwInputStream.ResetBuf ( int bitPosition)
private

Moves the unread data in the buffer to the beginning and resets the pointers.

Parameters
bitPosition
Returns
Here is the caller graph for this function:

◆ Seek()

override long ICSharpCode.SharpZipLib.LZW.LzwInputStream.Seek ( long offset,
SeekOrigin origin )

Sets the position within the current stream Always throws a NotSupportedException.

Parameters
offsetThe relative offset to seek to.
originThe SeekOrigin defining where to seek from.
Returns
The new position in the stream.
Exceptions
NotSupportedExceptionAny access

◆ SetLength()

override void ICSharpCode.SharpZipLib.LZW.LzwInputStream.SetLength ( long value)

Set the length of the current stream Always throws a NotSupportedException.

Parameters
valueThe new length value for the stream.
Exceptions
NotSupportedExceptionAny access

◆ Write()

override void ICSharpCode.SharpZipLib.LZW.LzwInputStream.Write ( byte[] buffer,
int offset,
int count )

Writes a sequence of bytes to stream and advances the current position This method always throws a NotSupportedException.

Parameters
bufferThew buffer containing data to write.
offsetThe offset of the first byte to write.
countThe number of bytes to write.
Exceptions
NotSupportedExceptionAny access

◆ WriteByte()

override void ICSharpCode.SharpZipLib.LZW.LzwInputStream.WriteByte ( byte value)

Writes one byte to the current stream and advances the current position Always throws a NotSupportedException.

Parameters
valueThe byte to write.
Exceptions
NotSupportedExceptionAny access

Member Data Documentation

◆ baseInputStream

Stream ICSharpCode.SharpZipLib.LZW.LzwInputStream.baseInputStream
private

◆ bitMask

int ICSharpCode.SharpZipLib.LZW.LzwInputStream.bitMask
private

◆ bitPos

int ICSharpCode.SharpZipLib.LZW.LzwInputStream.bitPos
private

◆ blockMode

bool ICSharpCode.SharpZipLib.LZW.LzwInputStream.blockMode
private

◆ data

readonly byte [] ICSharpCode.SharpZipLib.LZW.LzwInputStream.data = new byte[1024 * 8]
private

◆ end

int ICSharpCode.SharpZipLib.LZW.LzwInputStream.end
private

◆ eof

bool ICSharpCode.SharpZipLib.LZW.LzwInputStream.eof
private

◆ EXTRA

const int ICSharpCode.SharpZipLib.LZW.LzwInputStream.EXTRA = 64
staticprivate

◆ finChar

byte ICSharpCode.SharpZipLib.LZW.LzwInputStream.finChar
private

◆ freeEnt

int ICSharpCode.SharpZipLib.LZW.LzwInputStream.freeEnt
private

◆ got

int ICSharpCode.SharpZipLib.LZW.LzwInputStream.got
private

◆ headerParsed

bool ICSharpCode.SharpZipLib.LZW.LzwInputStream.headerParsed
private

◆ isClosed

bool ICSharpCode.SharpZipLib.LZW.LzwInputStream.isClosed
private

Flag indicating wether this instance has been closed or not.

◆ isStreamOwner

bool ICSharpCode.SharpZipLib.LZW.LzwInputStream.isStreamOwner = true
private

Flag indicating wether this instance is designated the stream owner. When closing if this flag is true the underlying stream is closed.

◆ maxBits

int ICSharpCode.SharpZipLib.LZW.LzwInputStream.maxBits
private

◆ maxCode

int ICSharpCode.SharpZipLib.LZW.LzwInputStream.maxCode
private

◆ maxMaxCode

int ICSharpCode.SharpZipLib.LZW.LzwInputStream.maxMaxCode
private

◆ nBits

int ICSharpCode.SharpZipLib.LZW.LzwInputStream.nBits
private

◆ oldCode

int ICSharpCode.SharpZipLib.LZW.LzwInputStream.oldCode
private

◆ one

readonly byte [] ICSharpCode.SharpZipLib.LZW.LzwInputStream.one = new byte[1]
private

◆ stack

byte [] ICSharpCode.SharpZipLib.LZW.LzwInputStream.stack
private

◆ stackP

int ICSharpCode.SharpZipLib.LZW.LzwInputStream.stackP
private

◆ tabPrefix

int [] ICSharpCode.SharpZipLib.LZW.LzwInputStream.tabPrefix
private

◆ tabSuffix

byte [] ICSharpCode.SharpZipLib.LZW.LzwInputStream.tabSuffix
private

◆ TBL_CLEAR

const int ICSharpCode.SharpZipLib.LZW.LzwInputStream.TBL_CLEAR = 0x100
staticprivate

◆ TBL_FIRST

const int ICSharpCode.SharpZipLib.LZW.LzwInputStream.TBL_FIRST = TBL_CLEAR + 1
staticprivate

◆ zeros

readonly int [] ICSharpCode.SharpZipLib.LZW.LzwInputStream.zeros = new int[256]
private

Property Documentation

◆ CanRead

override bool ICSharpCode.SharpZipLib.LZW.LzwInputStream.CanRead
get

Gets a value indicating whether the current stream supports reading.

◆ CanSeek

override bool ICSharpCode.SharpZipLib.LZW.LzwInputStream.CanSeek
get

Gets a value of false indicating seeking is not supported for this stream.

◆ CanWrite

override bool ICSharpCode.SharpZipLib.LZW.LzwInputStream.CanWrite
get

Gets a value of false indicating that this stream is not writeable.

◆ IsStreamOwner

bool ICSharpCode.SharpZipLib.LZW.LzwInputStream.IsStreamOwner
getset

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

The default value is true.

◆ Length

override long ICSharpCode.SharpZipLib.LZW.LzwInputStream.Length
get

A value representing the length of the stream in bytes.

◆ Position

override long ICSharpCode.SharpZipLib.LZW.LzwInputStream.Position
getset

The current position within the stream. Throws a NotSupportedException when attempting to set the position.

Exceptions
NotSupportedExceptionAttempting to set the position

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