Class Inflater
Inflater is used to decompress data that has been compressed according to the "deflate" standard described in rfc1951.
By default Zlib (rfc1950) headers and footers are expected in the input. You can use constructor
public Inflater(bool noHeader)
passing true
if there is no Zlib header information
The usage is as following. First you have to set some input with
SetInput()
, then Inflate() it. If inflate doesn't
inflate any bytes there may be three reasons:
- IsNeedingInput() returns true because the input buffer is empty.
You have to provide more input with
. NOTE: IsNeedingInput() also returns true when, the stream is finished.SetInput()
- IsNeedingDictionary() returns true, you have to provide a preset
dictionary with
.SetDictionary()
- IsFinished returns true, the inflater has finished.
author of the original java version : John Leuner, Jochen Hoenicke
Inheritance
Inherited Members
Namespace: ICSharpCode.SharpZipLib.Zip.Compression
Assembly: ICSharpCode.SharpZipLib.dll
Syntax
public class Inflater
Constructors
| Improve this Doc View SourceInflater()
Creates a new inflater or RFC1951 decompressor RFC1950/Zlib headers and footers will be expected in the input data
Declaration
public Inflater()
Inflater(Boolean)
Creates a new inflater.
Declaration
public Inflater(bool noHeader)
Parameters
Type | Name | Description |
---|---|---|
System.Boolean | noHeader | True if no RFC1950/Zlib header and footer fields are expected in the input data This is used for GZIPed/Zipped input. For compatibility with Sun JDK you should provide one byte of input more than needed in this case. |
Properties
| Improve this Doc View SourceAdler
Gets the adler checksum. This is either the checksum of all uncompressed bytes returned by inflate(), or if needsDictionary() returns true (and thus no output was yet produced) this is the adler checksum of the expected dictionary.
Declaration
public int Adler { get; }
Property Value
Type | Description |
---|---|
System.Int32 | the adler checksum. |
IsFinished
Returns true, if the inflater has finished. This means, that no input is needed and no output can be produced.
Declaration
public bool IsFinished { get; }
Property Value
Type | Description |
---|---|
System.Boolean |
IsNeedingDictionary
Returns true, if a preset dictionary is needed to inflate the input.
Declaration
public bool IsNeedingDictionary { get; }
Property Value
Type | Description |
---|---|
System.Boolean |
IsNeedingInput
Returns true, if the input buffer is empty. You should then call setInput(). NOTE: This method also returns true when the stream is finished.
Declaration
public bool IsNeedingInput { get; }
Property Value
Type | Description |
---|---|
System.Boolean |
RemainingInput
Gets the number of unprocessed input bytes. Useful, if the end of the stream is reached and you want to further process the bytes after the deflate stream.
Declaration
public int RemainingInput { get; }
Property Value
Type | Description |
---|---|
System.Int32 | The number of bytes of the input which have not been processed. |
TotalIn
Gets the total number of processed compressed input bytes.
Declaration
public long TotalIn { get; }
Property Value
Type | Description |
---|---|
System.Int64 | The total number of bytes of processed input bytes. |
TotalOut
Gets the total number of output bytes returned by Inflate().
Declaration
public long TotalOut { get; }
Property Value
Type | Description |
---|---|
System.Int64 | the total number of output bytes. |
Methods
| Improve this Doc View SourceInflate(Byte[])
Inflates the compressed stream to the output buffer. If this returns 0, you should check, whether IsNeedingDictionary(), IsNeedingInput() or IsFinished() returns true, to determine why no further output is produced.
Declaration
public int Inflate(byte[] buffer)
Parameters
Type | Name | Description |
---|---|---|
System.Byte[] | buffer | the output buffer. |
Returns
Type | Description |
---|---|
System.Int32 | The number of bytes written to the buffer, 0 if no further output can be produced. |
Exceptions
Type | Condition |
---|---|
System.ArgumentOutOfRangeException | if buffer has length 0. |
System.FormatException | if deflated stream is invalid. |
Inflate(Byte[], Int32, Int32)
Inflates the compressed stream to the output buffer. If this returns 0, you should check, whether needsDictionary(), needsInput() or finished() returns true, to determine why no further output is produced.
Declaration
public int Inflate(byte[] buffer, int offset, int count)
Parameters
Type | Name | Description |
---|---|---|
System.Byte[] | buffer | the output buffer. |
System.Int32 | offset | the offset in buffer where storing starts. |
System.Int32 | count | the maximum number of bytes to output. |
Returns
Type | Description |
---|---|
System.Int32 | the number of bytes written to the buffer, 0 if no further output can be produced. |
Exceptions
Type | Condition |
---|---|
System.ArgumentOutOfRangeException | if count is less than 0. |
System.ArgumentOutOfRangeException | if the index and / or count are wrong. |
System.FormatException | if deflated stream is invalid. |
Reset()
Resets the inflater so that a new stream can be decompressed. All pending input and output will be discarded.
Declaration
public void Reset()
SetDictionary(Byte[])
Sets the preset dictionary. This should only be called, if needsDictionary() returns true and it should set the same dictionary, that was used for deflating. The getAdler() function returns the checksum of the dictionary needed.
Declaration
public void SetDictionary(byte[] buffer)
Parameters
Type | Name | Description |
---|---|---|
System.Byte[] | buffer | The dictionary. |
SetDictionary(Byte[], Int32, Int32)
Sets the preset dictionary. This should only be called, if needsDictionary() returns true and it should set the same dictionary, that was used for deflating. The getAdler() function returns the checksum of the dictionary needed.
Declaration
public void SetDictionary(byte[] buffer, int index, int count)
Parameters
Type | Name | Description |
---|---|---|
System.Byte[] | buffer | The dictionary. |
System.Int32 | index | The index into buffer where the dictionary starts. |
System.Int32 | count | The number of bytes in the dictionary. |
Exceptions
Type | Condition |
---|---|
System.InvalidOperationException | No dictionary is needed. |
SharpZipBaseException | The adler checksum for the buffer is invalid |
SetInput(Byte[])
Sets the input. This should only be called, if needsInput() returns true.
Declaration
public void SetInput(byte[] buffer)
Parameters
Type | Name | Description |
---|---|---|
System.Byte[] | buffer | the input. |
SetInput(Byte[], Int32, Int32)
Sets the input. This should only be called, if needsInput() returns true.
Declaration
public void SetInput(byte[] buffer, int index, int count)
Parameters
Type | Name | Description |
---|---|---|
System.Byte[] | buffer | The source of input data |
System.Int32 | index | The index into buffer where the input starts. |
System.Int32 | count | The number of bytes of input to use. |
Exceptions
Type | Condition |
---|---|
System.InvalidOperationException | No input is needed. |
System.ArgumentOutOfRangeException | The index and/or count are wrong. |