System.IO.Compression.Inflater.Finished C# (CSharp) Méthode

Finished() public méthode

Returns true if the end of the stream has been reached.
public Finished ( ) : bool
Résultat bool
        public bool Finished()
        {
            return _finished && _zlibStream.AvailIn == 0 && _zlibStream.AvailOut == 0;
        }

Usage Example

Exemple #1
0
        public override int Read(byte[] array, int offset, int count)
        {
            EnsureDecompressionMode();
            ValidateParameters(array, offset, count);
            EnsureNotDisposed();

            int bytesRead;
            int currentOffset  = offset;
            int remainingCount = count;

            while (true)
            {
                bytesRead       = _inflater.Inflate(array, currentOffset, remainingCount);
                currentOffset  += bytesRead;
                remainingCount -= bytesRead;

                if (remainingCount == 0)
                {
                    break;
                }

                if (_inflater.Finished())
                {
                    // if we finished decompressing, we can't have anything left in the outputwindow.
                    Debug.Assert(_inflater.AvailableOutput == 0, "We should have copied all stuff out!");
                    break;
                }

                Debug.Assert(_inflater.NeedsInput(), "We can only run into this case if we are short of input");

                int bytes = _stream.Read(_buffer, 0, _buffer.Length);
                if (bytes <= 0)
                {
                    break;
                }
                else if (bytes > _buffer.Length)
                {
                    // The stream is either malicious or poorly implemented and returned a number of
                    // bytes larger than the buffer supplied to it.
                    throw new InvalidDataException(SR.GenericInvalidData);
                }

                _inflater.SetInput(_buffer, 0, bytes);
            }

            return(count - remainingCount);
        }
All Usage Examples Of System.IO.Compression.Inflater::Finished