System.IO.Compression.Deflater.GetDeflateOutput C# (CSharp) Method

GetDeflateOutput() private method

private GetDeflateOutput ( byte outputBuffer ) : int
outputBuffer byte
return int
        internal int GetDeflateOutput(byte[] outputBuffer)
        {
            Contract.Ensures(Contract.Result<int>() >= 0 && Contract.Result<int>() <= outputBuffer.Length);

            Debug.Assert(null != outputBuffer, "Can't pass in a null output buffer!");
            Debug.Assert(!NeedsInput(), "GetDeflateOutput should only be called after providing input");
            Debug.Assert(_inputBufferHandle.IsAllocated);

            try
            {
                int bytesRead;
                ReadDeflateOutput(outputBuffer, ZFlushCode.NoFlush, out bytesRead);
                return bytesRead;
            }
            finally
            {
                // Before returning, make sure to release input buffer if necessary:
                if (0 == _zlibStream.AvailIn && _inputBufferHandle.IsAllocated)
                    DeallocateInputBufferHandle();
            }
        }

Usage Example

Exemplo n.º 1
0
 private void WriteDeflaterOutput()
 {
     while (!_deflater.NeedsInput())
     {
         int compressedBytes = _deflater.GetDeflateOutput(_buffer);
         if (compressedBytes > 0)
         {
             _stream.Write(_buffer, 0, compressedBytes);
         }
     }
 }
All Usage Examples Of System.IO.Compression.Deflater::GetDeflateOutput