public override int Read(byte[] buffer, int offset, int count)
{
// Basic checks.
if(null == buffer) throw new ArgumentNullException("buffer", "Buffer cannot be null.");
if(offset < 0) throw new ArgumentOutOfRangeException("offset", "Non-negative number required.");
if(count < 0) throw new ArgumentOutOfRangeException("count", "Non-negative number required.");
if((buffer.Length - offset) < count) {
throw new ArgumentException("Offset and length were out of bounds for the array or count is greater than the number of elements from index to the end of the source collection.");
}
if(!this._isOpen) throw new ObjectDisposedException("Stream is closed.");
// Test for end of stream (or beyond end)
if(_position >= _length) {
return 0;
}
// Read bytes into the buffer.
int blockIdx = _position / _blockSize;
int blockOffset = _position % _blockSize;
return ReadInner(buffer, offset, count, blockIdx, blockOffset);
}