private byte[] ReadDataNoCaching(long pos, int size)
{
persistentSource.Data.Position = pos;
var read = 0;
var buf = new byte[size];
do
{
int dataRead = persistentSource.Data.Read(buf, read, buf.Length - read);
if (dataRead == 0) // nothing read, EOF, probably truncated write,
{
throw new InvalidDataException("Could not read complete data, the data file is corrupt");
}
read += dataRead;
} while (read < buf.Length);
return buf;
}