| 76 | } |
| 77 | |
| 78 | void FileReadStream::SetPosition(uint32 seek) |
| 79 | { |
| 80 | #if USE_FILE_POS |
| 81 | // Skip if position won't change |
| 82 | if (GetPosition() == seek) |
| 83 | { |
| 84 | return; |
| 85 | } |
| 86 | |
| 87 | // Try to seek with virtual position |
| 88 | uint32 bufferStartPos = _filePosition - _bufferSize; |
| 89 | if (seek >= GetPosition() && seek < _filePosition) |
| 90 | { |
| 91 | _virtualPosInBuffer = seek - bufferStartPos; |
| 92 | return; |
| 93 | } |
| 94 | #endif |
| 95 | |
| 96 | // Seek |
| 97 | _file->SetPosition(seek); |
| 98 | _filePosition = _file->GetPosition(); |
| 99 | |
| 100 | // Update buffer |
| 101 | _hasError |= _file->Read(_buffer, FILESTREAM_BUFFER_SIZE, &_bufferSize) != 0; |
| 102 | #if USE_FILE_POS |
| 103 | _filePosition += _bufferSize; |
| 104 | #endif |
| 105 | _virtualPosInBuffer = 0; |
| 106 | } |
| 107 | |
| 108 | void FileReadStream::ReadBytes(void* data, uint32 bytes) |
| 109 | { |
no test coverage detected