public void RandomRead(byte[] data, int offset, int size, ulong position, bool doNotCache)
{
while (size > 0)
{
byte[] buf;
lock (_lock)
{
if (position + (ulong)size > (ulong)_writer.GetCurrentPosition()) throw new EndOfStreamException();
buf = _data[(int)(position / OneBufSize)];
}
var bufofs = (int)(position % OneBufSize);
var copy = Math.Min(size, OneBufSize - bufofs);
Array.Copy(buf, bufofs, data, offset, copy);
offset += copy;
size -= copy;
position += (ulong)copy;
}
}