System.IO.Compression.OutputWindow.CopyTo C# (CSharp) Method

CopyTo() public method

public CopyTo ( byte output, int offset, int length ) : int
output byte
offset int
length int
return int
        public int CopyTo(byte[] output, int offset, int length) {
            int end;
            if (length > this.bytesUsed) {
                end = this.end;
                length = this.bytesUsed;
            }
            else {
                end = ((this.end - this.bytesUsed) + length) & 0x7fff;
            }
            int num2 = length;
            int num3 = length - end;
            if (num3 > 0) {
                Array.Copy(this.window, 0x8000 - num3, output, offset, num3);
                offset += num3;
                length = end;
            }
            Array.Copy(this.window, end - length, output, offset, length);
            this.bytesUsed -= num2;
            return num2;
        }

Usage Example

Esempio n. 1
0
        public int Inflate(byte[] bytes, int offset, int length)
        {
            // copy bytes from output to outputbytes if we have available bytes
            // if buffer is not filled up. keep decoding until no input are available
            // if decodeBlock returns false. Throw an exception.
            int count = 0;

            do
            {
                int copied = 0;
                if (_uncompressedSize == -1)
                {
                    copied = _output.CopyTo(bytes, offset, length);
                }
                else
                {
                    if (_uncompressedSize > _currentInflatedCount)
                    {
                        length = (int)Math.Min(length, _uncompressedSize - _currentInflatedCount);
                        copied = _output.CopyTo(bytes, offset, length);
                        _currentInflatedCount += copied;
                    }
                    else
                    {
                        _state = InflaterState.Done;
                        _output.ClearBytesUsed();
                    }
                }
                if (copied > 0)
                {
                    if (_hasFormatReader)
                    {
                        _formatReader.UpdateWithBytesRead(bytes, offset, copied);
                    }

                    offset += copied;
                    count  += copied;
                    length -= copied;
                }

                if (length == 0)
                {   // filled in the bytes array
                    break;
                }
                // Decode will return false when more input is needed
            } while (!Finished() && Decode());

            if (_state == InflaterState.VerifyingFooter)
            {  // finished reading CRC
                // In this case finished is true and output window has all the data.
                // But some data in output window might not be copied out.
                if (_output.AvailableBytes == 0)
                {
                    _formatReader.Validate();
                }
            }

            return(count);
        }
All Usage Examples Of System.IO.Compression.OutputWindow::CopyTo