protected internal void readNewBuffer(int off)
{
/* If the buffer have changed. We need to write it to
* the file before reading a new buffer.
*/
if (byteBufferChanged)
{
flush();
}
// Don't allow to seek beyond end of file if reading only
if (isReadOnly && off >= theFile.Length)
{
throw new System.IO.EndOfStreamException();
}
// Set new offset
offset = off;
theFile.Seek(offset, System.IO.SeekOrigin.Begin);
maxByte = theFile.Read(byteBuffer, 0, byteBuffer.Length);
position = 0;
if (maxByte < byteBuffer.Length)
{
// Not enough data in input file.
isEOFInBuffer = true;
if (maxByte == - 1)
{
maxByte++;
}
}
else
{
isEOFInBuffer = false;
}
}