Exemple #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);
        }
Exemple #2
0
        public Int32 CopyFrom(InputBuffer input, Int32 length)
        {
            length = Math.Min(Math.Min(length, 32768 - this.bytesUsed), input.AvailableBytes);
            Int32 num = 32768 - this.end;
            Int32 num2;

            if (length > num)
            {
                num2 = input.CopyTo(this.window, this.end, num);
                if (num2 == num)
                {
                    num2 += input.CopyTo(this.window, 0, length - num);
                }
            }
            else
            {
                num2 = input.CopyTo(this.window, this.end, length);
            }
            this.end        = (this.end + num2 & 32767);
            this.bytesUsed += num2;
            return(num2);
        }
        // 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;
        }