Class DeflaterOutputStream
A special stream deflating or compressing the bytes that are
written to it. It uses a Deflater to perform actual deflating.
Authors of the original java version : Tom Tromey, Jochen Hoenicke
Inheritance
Implements
Inherited Members
Namespace: ICSharpCode.SharpZipLib.Zip.Compression.Streams
Assembly: ICSharpCode.SharpZipLib.dll
Syntax
public class DeflaterOutputStream : Stream, IDisposable
Constructors
| Improve this Doc View SourceDeflaterOutputStream(Stream)
Creates a new DeflaterOutputStream with a default Deflater and default buffer size.
Declaration
public DeflaterOutputStream(Stream baseOutputStream)
Parameters
Type | Name | Description |
---|---|---|
System.IO.Stream | baseOutputStream | the output stream where deflated output should be written. |
DeflaterOutputStream(Stream, Deflater)
Creates a new DeflaterOutputStream with the given Deflater and default buffer size.
Declaration
public DeflaterOutputStream(Stream baseOutputStream, Deflater deflater)
Parameters
Type | Name | Description |
---|---|---|
System.IO.Stream | baseOutputStream | the output stream where deflated output should be written. |
Deflater | deflater | the underlying deflater. |
DeflaterOutputStream(Stream, Deflater, Int32)
Creates a new DeflaterOutputStream with the given Deflater and buffer size.
Declaration
public DeflaterOutputStream(Stream baseOutputStream, Deflater deflater, int bufferSize)
Parameters
Type | Name | Description |
---|---|---|
System.IO.Stream | baseOutputStream | The output stream where deflated output is written. |
Deflater | deflater | The underlying deflater to use |
System.Int32 | bufferSize | The buffer size in bytes to use when deflating (minimum value 512) |
Exceptions
Type | Condition |
---|---|
System.ArgumentOutOfRangeException | bufsize is less than or equal to zero. |
System.ArgumentException | baseOutputStream does not support writing |
System.ArgumentNullException | deflater instance is null |
Fields
| Improve this Doc View SourceAESAuthCode
Returns the 10 byte AUTH CODE to be appended immediately following the AES data stream.
Declaration
protected byte[] AESAuthCode
Field Value
Type | Description |
---|---|
System.Byte[] |
baseOutputStream_
Base stream the deflater depends on.
Declaration
protected Stream baseOutputStream_
Field Value
Type | Description |
---|---|
System.IO.Stream |
cryptoTransform_
The CryptoTransform currently being used to encrypt the compressed data.
Declaration
protected ICryptoTransform cryptoTransform_
Field Value
Type | Description |
---|---|
System.Security.Cryptography.ICryptoTransform |
deflater_
The deflater which is used to deflate the stream.
Declaration
protected Deflater deflater_
Field Value
Type | Description |
---|---|
Deflater |
Properties
| Improve this Doc View SourceCanPatchEntries
Allows client to determine if an entry can be patched after its added
Declaration
public bool CanPatchEntries { get; }
Property Value
Type | Description |
---|---|
System.Boolean |
CanRead
Gets value indicating stream can be read from
Declaration
public override bool CanRead { get; }
Property Value
Type | Description |
---|---|
System.Boolean |
Overrides
CanSeek
Gets a value indicating if seeking is supported for this stream This property always returns false
Declaration
public override bool CanSeek { get; }
Property Value
Type | Description |
---|---|
System.Boolean |
Overrides
CanWrite
Get value indicating if this stream supports writing
Declaration
public override bool CanWrite { get; }
Property Value
Type | Description |
---|---|
System.Boolean |
Overrides
IsStreamOwner
Gets or sets a flag indicating ownership of underlying stream. When the flag is true System.IO.Stream.Dispose() will close the underlying stream also.
Declaration
public bool IsStreamOwner { get; set; }
Property Value
Type | Description |
---|---|
System.Boolean |
Remarks
The default value is true.
Length
Get current length of stream
Declaration
public override long Length { get; }
Property Value
Type | Description |
---|---|
System.Int64 |
Overrides
Position
Gets the current position within the stream.
Declaration
public override long Position { get; set; }
Property Value
Type | Description |
---|---|
System.Int64 |
Overrides
Exceptions
Type | Condition |
---|---|
System.NotSupportedException | Any attempt to set position |
ZipCryptoEncoding
The encoding used for the ZipCrypto passwords. Defaults to DefaultZipCryptoEncoding.
Declaration
public Encoding ZipCryptoEncoding { get; set; }
Property Value
Type | Description |
---|---|
System.Text.Encoding |
Methods
| Improve this Doc View SourceDeflate()
Deflates everything in the input buffers. This will call
def.deflate()
until all bytes from the input buffers
are processed.
Declaration
protected void Deflate()
Dispose(Boolean)
Calls Finish() and closes the underlying stream when IsStreamOwner is true.
Declaration
protected override void Dispose(bool disposing)
Parameters
Type | Name | Description |
---|---|---|
System.Boolean | disposing |
Overrides
EncryptBlock(Byte[], Int32, Int32)
Encrypt a block of data
Declaration
protected void EncryptBlock(byte[] buffer, int offset, int length)
Parameters
Type | Name | Description |
---|---|---|
System.Byte[] | buffer | Data to encrypt. NOTE the original contents of the buffer are lost |
System.Int32 | offset | Offset of first byte in buffer to encrypt |
System.Int32 | length | Number of bytes in buffer to encrypt |
Finish()
Finishes the stream by calling finish() on the deflater.
Declaration
public virtual void Finish()
Exceptions
Type | Condition |
---|---|
SharpZipBaseException | Not all input is deflated |
FinishAsync(CancellationToken)
Finishes the stream by calling finish() on the deflater.
Declaration
public virtual async Task FinishAsync(CancellationToken ct)
Parameters
Type | Name | Description |
---|---|---|
System.Threading.CancellationToken | ct | The System.Threading.CancellationToken that can be used to cancel the operation. |
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task |
Exceptions
Type | Condition |
---|---|
SharpZipBaseException | Not all input is deflated |
Flush()
Flushes the stream by calling Flush on the deflater and then on the underlying stream. This ensures that all bytes are flushed.
Declaration
public override void Flush()
Overrides
GetAuthCodeIfAES()
Get the Auth code for AES encrypted entries
Declaration
protected void GetAuthCodeIfAES()
Read(Byte[], Int32, Int32)
Read a block of bytes from stream
Declaration
public override int Read(byte[] buffer, int offset, int count)
Parameters
Type | Name | Description |
---|---|---|
System.Byte[] | buffer | The buffer to store read data in. |
System.Int32 | offset | The offset to start storing at. |
System.Int32 | count | The maximum number of bytes to read. |
Returns
Type | Description |
---|---|
System.Int32 | The actual number of bytes read. Zero if end of stream is detected. |
Overrides
Exceptions
Type | Condition |
---|---|
System.NotSupportedException | Any access |
ReadByte()
Read a byte from stream advancing position by one
Declaration
public override int ReadByte()
Returns
Type | Description |
---|---|
System.Int32 | The byte read cast to an int. THe value is -1 if at the end of the stream. |
Overrides
Exceptions
Type | Condition |
---|---|
System.NotSupportedException | Any access |
Seek(Int64, SeekOrigin)
Sets the current position of this stream to the given value. Not supported by this class!
Declaration
public override long Seek(long offset, SeekOrigin origin)
Parameters
Type | Name | Description |
---|---|---|
System.Int64 | offset | The offset relative to the |
System.IO.SeekOrigin | origin | The System.IO.SeekOrigin to seek from. |
Returns
Type | Description |
---|---|
System.Int64 | The new position in the stream. |
Overrides
Exceptions
Type | Condition |
---|---|
System.NotSupportedException | Any access |
SetLength(Int64)
Sets the length of this stream to the given value. Not supported by this class!
Declaration
public override void SetLength(long value)
Parameters
Type | Name | Description |
---|---|---|
System.Int64 | value | The new stream length. |
Overrides
Exceptions
Type | Condition |
---|---|
System.NotSupportedException | Any access |
Write(Byte[], Int32, Int32)
Writes bytes from an array to the compressed stream.
Declaration
public override void Write(byte[] buffer, int offset, int count)
Parameters
Type | Name | Description |
---|---|---|
System.Byte[] | buffer | The byte array |
System.Int32 | offset | The offset into the byte array where to start. |
System.Int32 | count | The number of bytes to write. |
Overrides
WriteByte(Byte)
Writes a single byte to the compressed output stream.
Declaration
public override void WriteByte(byte value)
Parameters
Type | Name | Description |
---|---|---|
System.Byte | value | The byte value. |