Show / Hide Table of Contents

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
System.Object
System.MarshalByRefObject
System.IO.Stream
DeflaterOutputStream
GZipOutputStream
ZipOutputStream
Implements
System.IDisposable
Inherited Members
System.IO.Stream.Null
System.IO.Stream.BeginRead(System.Byte[], System.Int32, System.Int32, System.AsyncCallback, System.Object)
System.IO.Stream.BeginWrite(System.Byte[], System.Int32, System.Int32, System.AsyncCallback, System.Object)
System.IO.Stream.Close()
System.IO.Stream.CopyTo(System.IO.Stream)
System.IO.Stream.CopyTo(System.IO.Stream, System.Int32)
System.IO.Stream.CopyToAsync(System.IO.Stream)
System.IO.Stream.CopyToAsync(System.IO.Stream, System.Int32)
System.IO.Stream.CopyToAsync(System.IO.Stream, System.Int32, System.Threading.CancellationToken)
System.IO.Stream.CreateWaitHandle()
System.IO.Stream.Dispose()
System.IO.Stream.EndRead(System.IAsyncResult)
System.IO.Stream.EndWrite(System.IAsyncResult)
System.IO.Stream.FlushAsync()
System.IO.Stream.ObjectInvariant()
System.IO.Stream.ReadAsync(System.Byte[], System.Int32, System.Int32)
System.IO.Stream.ReadAsync(System.Byte[], System.Int32, System.Int32, System.Threading.CancellationToken)
System.IO.Stream.Synchronized(System.IO.Stream)
System.IO.Stream.WriteAsync(System.Byte[], System.Int32, System.Int32)
System.IO.Stream.CanTimeout
System.IO.Stream.ReadTimeout
System.IO.Stream.WriteTimeout
System.MarshalByRefObject.GetLifetimeService()
System.MarshalByRefObject.InitializeLifetimeService()
System.MarshalByRefObject.MemberwiseClone(System.Boolean)
System.Object.Equals(System.Object)
System.Object.Equals(System.Object, System.Object)
System.Object.GetHashCode()
System.Object.GetType()
System.Object.MemberwiseClone()
System.Object.ReferenceEquals(System.Object, System.Object)
System.Object.ToString()
Namespace: ICSharpCode.SharpZipLib.Zip.Compression.Streams
Assembly: ICSharpCode.SharpZipLib.dll
Syntax
public class DeflaterOutputStream : Stream, IDisposable

Constructors

| Improve this Doc View Source

DeflaterOutputStream(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.

| Improve this Doc View Source

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.

| Improve this Doc View Source

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 Source

_stringCodec

Declaration
protected StringCodec _stringCodec
Field Value
Type Description
StringCodec
| Improve this Doc View Source

AESAuthCode

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[]
| Improve this Doc View Source

baseOutputStream_

Base stream the deflater depends on.

Declaration
protected Stream baseOutputStream_
Field Value
Type Description
System.IO.Stream
| Improve this Doc View Source

cryptoTransform_

The CryptoTransform currently being used to encrypt the compressed data.

Declaration
protected ICryptoTransform cryptoTransform_
Field Value
Type Description
System.Security.Cryptography.ICryptoTransform
| Improve this Doc View Source

deflater_

The deflater which is used to deflate the stream.

Declaration
protected Deflater deflater_
Field Value
Type Description
Deflater

Properties

| Improve this Doc View Source

CanPatchEntries

Allows client to determine if an entry can be patched after its added

Declaration
public bool CanPatchEntries { get; }
Property Value
Type Description
System.Boolean
| Improve this Doc View Source

CanRead

Gets value indicating stream can be read from

Declaration
public override bool CanRead { get; }
Property Value
Type Description
System.Boolean
Overrides
System.IO.Stream.CanRead
| Improve this Doc View Source

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
System.IO.Stream.CanSeek
| Improve this Doc View Source

CanWrite

Get value indicating if this stream supports writing

Declaration
public override bool CanWrite { get; }
Property Value
Type Description
System.Boolean
Overrides
System.IO.Stream.CanWrite
| Improve this Doc View Source

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.

| Improve this Doc View Source

Length

Get current length of stream

Declaration
public override long Length { get; }
Property Value
Type Description
System.Int64
Overrides
System.IO.Stream.Length
| Improve this Doc View Source

Position

Gets the current position within the stream.

Declaration
public override long Position { get; set; }
Property Value
Type Description
System.Int64
Overrides
System.IO.Stream.Position
Exceptions
Type Condition
System.NotSupportedException

Any attempt to set position

| Improve this Doc View Source

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 Source

Deflate()

Deflates everything in the input buffers. This will call

def.deflate()
until all bytes from the input buffers

are processed.

Declaration
protected void Deflate()
| Improve this Doc View Source

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
System.IO.Stream.Dispose(System.Boolean)
| Improve this Doc View Source

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

| Improve this Doc View Source

Finish()

Finishes the stream by calling finish() on the deflater.

Declaration
public virtual void Finish()
Exceptions
Type Condition
SharpZipBaseException

Not all input is deflated

| Improve this Doc View Source

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

| Improve this Doc View Source

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
System.IO.Stream.Flush()
| Improve this Doc View Source

FlushAsync(CancellationToken)

Asynchronously clears all buffers for this stream, causes any buffered data to be written to the underlying device, and monitors cancellation requests.

Declaration
public override async Task FlushAsync(CancellationToken cancellationToken)
Parameters
Type Name Description
System.Threading.CancellationToken cancellationToken

The token to monitor for cancellation requests. The default value is System.Threading.CancellationToken.None.

Returns
Type Description
System.Threading.Tasks.Task
Overrides
System.IO.Stream.FlushAsync(System.Threading.CancellationToken)
| Improve this Doc View Source

GetAuthCodeIfAES()

Get the Auth code for AES encrypted entries

Declaration
protected void GetAuthCodeIfAES()
| Improve this Doc View Source

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
System.IO.Stream.Read(System.Byte[], System.Int32, System.Int32)
Exceptions
Type Condition
System.NotSupportedException

Any access

| Improve this Doc View Source

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
System.IO.Stream.ReadByte()
Exceptions
Type Condition
System.NotSupportedException

Any access

| Improve this Doc View Source

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 origin to seek.

System.IO.SeekOrigin origin

The System.IO.SeekOrigin to seek from.

Returns
Type Description
System.Int64

The new position in the stream.

Overrides
System.IO.Stream.Seek(System.Int64, System.IO.SeekOrigin)
Exceptions
Type Condition
System.NotSupportedException

Any access

| Improve this Doc View Source

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
System.IO.Stream.SetLength(System.Int64)
Exceptions
Type Condition
System.NotSupportedException

Any access

| Improve this Doc View Source

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
System.IO.Stream.Write(System.Byte[], System.Int32, System.Int32)
| Improve this Doc View Source

WriteAsync(Byte[], Int32, Int32, CancellationToken)

Asynchronously writes a sequence of bytes to the current stream, advances the current position within this stream by the number of bytes written, and monitors cancellation requests.

Declaration
public override async Task WriteAsync(byte[] buffer, int offset, int count, CancellationToken ct)
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.

System.Threading.CancellationToken ct

The token to monitor for cancellation requests. The default value is System.Threading.CancellationToken.None.

Returns
Type Description
System.Threading.Tasks.Task
Overrides
System.IO.Stream.WriteAsync(System.Byte[], System.Int32, System.Int32, System.Threading.CancellationToken)
| Improve this Doc View Source

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.

Overrides
System.IO.Stream.WriteByte(System.Byte)

Implements

System.IDisposable
  • Improve this Doc
  • View Source
In This Article
Back to top Copyright © 2000-2022 SharpZipLib Contributors