System.IO.Compression.InputBuffer.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 num = 0;
            while ((this.bitsInBuffer > 0) && (length > 0)) {
                output[offset++] = (byte)this.bitBuffer;
                this.bitBuffer = this.bitBuffer >> 8;
                this.bitsInBuffer -= 8;
                length--;
                num++;
            }
            if (length == 0) {
                return num;
            }
            int num2 = this.end - this.start;
            if (length > num2) {
                length = num2;
            }
            Array.Copy(this.buffer, this.start, output, offset, length);
            this.start += length;
            return (num + length);
        }

Usage Example

Ejemplo n.º 1
0
        // Copy up to length of bytes from input directly.
        // This is used for uncompressed block.
        public int CopyFrom(InputBuffer input, int length)
        {
            length = Math.Min(Math.Min(length, WindowSize - _bytesUsed), input.AvailableBytes);
            int copied;

            // We might need wrap around to copy all bytes.
            int tailLen = WindowSize - _end;

            if (length > tailLen)
            {
                // copy the first part
                copied = input.CopyTo(_window, _end, tailLen);
                if (copied == tailLen)
                {
                    // only try to copy the second part if we have enough bytes in input
                    copied += input.CopyTo(_window, 0, length - tailLen);
                }
            }
            else
            {
                // only one copy is needed if there is no wrap around.
                copied = input.CopyTo(_window, _end, length);
            }

            _end        = (_end + copied) & WindowMask;
            _bytesUsed += copied;
            return(copied);
        }
All Usage Examples Of System.IO.Compression.InputBuffer::CopyTo