BTDB.KVDBLayer.InMemoryFileCollection.File.RandomRead C# (CSharp) Method

RandomRead() public method

public RandomRead ( byte data, int offset, int size, ulong position, bool doNotCache ) : void
data byte
offset int
size int
position ulong
doNotCache bool
return void
            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;
                }
            }