Revenj.Utility.ChunkedMemoryStream.Read C# (CSharp) Method

Read() public method

Read buffer from the stream. Can return less then specified count if remaining block size is less than specified count
public Read ( byte buffer, int offset, int count ) : int
buffer byte copy to buffer
offset int offset in the buffer
count int maximum size to read
return int
        public override int Read(byte[] buffer, int offset, int count)
        {
            var off = CurrentPosition & BlockAnd;
            var min = BlockSize - off;
            if (count < min)
                min = count;
            if (TotalSize - CurrentPosition < min)
                min = TotalSize - CurrentPosition;
            if (min > 0)
            {
                var pos = CurrentPosition >> BlockShift;
                Buffer.BlockCopy(Blocks[pos], off, buffer, offset, min);
                CurrentPosition += min;
            }
            return min;
        }