private void SwitchCurrentBuffer() { if (currentBufferIndex == file.NumBuffers()) { currentBuffer = file.AddBuffer(BUFFER_SIZE); } else { currentBuffer = (byte[])file.GetBuffer(currentBufferIndex); } bufferPosition = 0; bufferStart = (long)BUFFER_SIZE * (long)currentBufferIndex; bufferLength = currentBuffer.Length; }
private void SwitchCurrentBuffer(bool enforceEOF) { if (currentBufferIndex >= file.NumBuffers()) { // end of file reached, no more buffers left if (enforceEOF) { throw new System.IO.IOException("Read past EOF"); } else { // Force EOF if a read takes place at this position currentBufferIndex--; bufferPosition = BUFFER_SIZE; } } else { currentBuffer = (byte[])file.GetBuffer(currentBufferIndex); bufferPosition = 0; bufferStart = (long)BUFFER_SIZE * (long)currentBufferIndex; long buflen = length - bufferStart; bufferLength = buflen > BUFFER_SIZE?BUFFER_SIZE:(int)buflen; } }