NeedsInput() public method

public NeedsInput ( ) : bool
return bool
コード例 #1
0
 private void WriteDeflaterOutput()
 {
     while (!_deflater.NeedsInput())
     {
         int compressedBytes = _deflater.GetDeflateOutput(_buffer);
         if (compressedBytes > 0)
         {
             _stream.Write(_buffer, 0, compressedBytes);
         }
     }
 }
コード例 #2
0
        internal void InternalWrite(byte[] array, int offset, int count, bool isAsync)
        {
            int currentOffest  = offset;
            int remainingCount = count;
            int bytesCompressed;

            // compressed the bytes we already passed to the deflater
            while (!deflater.NeedsInput())
            {
                bytesCompressed = deflater.GetDeflateOutput(buffer);
                if (bytesCompressed != 0)
                {
                    if (isAsync)
                    {
                        IAsyncResult result = _stream.BeginWrite(buffer, 0, bytesCompressed, null, null);
                        _stream.EndWrite(result);
                    }
                    else
                    {
                        _stream.Write(buffer, 0, bytesCompressed);
                    }
                }
            }

            deflater.SetInput(array, offset, count);

            // compressed the new input
            while (!deflater.NeedsInput())
            {
                bytesCompressed = deflater.GetDeflateOutput(buffer);
                if (bytesCompressed != 0)
                {
                    if (isAsync)
                    {
                        IAsyncResult result = _stream.BeginWrite(buffer, 0, bytesCompressed, null, null);
                        _stream.EndWrite(result);
                    }
                    else
                    {
                        _stream.Write(buffer, 0, bytesCompressed);
                    }
                }
            }
        }