| 349 | } |
| 350 | |
| 351 | bool ReadCache::GetNextByte(uint8_t &input) { |
| 352 | if ( file_index_ < data_size_) { |
| 353 | if (file_buffer_.empty()) { |
| 354 | // Read direct from the file |
| 355 | input = buffer_.sbumpc(); |
| 356 | } else { |
| 357 | // Read from buffer in case of DZ block |
| 358 | input = file_buffer_[file_index_]; |
| 359 | } |
| 360 | ++file_index_; |
| 361 | ++data_count_; |
| 362 | return true; |
| 363 | } |
| 364 | |
| 365 | if (block_index_ >= block_list_.size()) { |
| 366 | return false; |
| 367 | } |
| 368 | |
| 369 | auto* current_block = block_list_[block_index_]; |
| 370 | ++block_index_; |
| 371 | if (current_block == nullptr) { |
| 372 | return false; |
| 373 | } |
| 374 | file_index_ = 0; |
| 375 | data_size_ = current_block->DataSize(); |
| 376 | if (current_block->BlockType() == "DZ") { |
| 377 | // Need a temp buffer in between |
| 378 | try { |
| 379 | file_buffer_.resize(static_cast<size_t>(data_size_) ); |
| 380 | } catch (const std::exception&) { |
| 381 | return false; |
| 382 | } |
| 383 | |
| 384 | uint64_t temp_index = 0; |
| 385 | current_block->CopyDataToBuffer(buffer_,file_buffer_, temp_index); |
| 386 | } else { |
| 387 | // Read from the file directly |
| 388 | SetFilePosition(buffer_, current_block->DataPosition()); |
| 389 | file_buffer_.clear(); // Indicate that we read from the file directly |
| 390 | } |
| 391 | // Read in the data form file to |
| 392 | if (file_index_ >= data_size_) { |
| 393 | return false; |
| 394 | } |
| 395 | if (file_buffer_.empty()) { |
| 396 | input = buffer_.sbumpc(); |
| 397 | } else { |
| 398 | input = file_buffer_[file_index_]; |
| 399 | } |
| 400 | ++file_index_; |
| 401 | ++data_count_; |
| 402 | return true; |
| 403 | } |
| 404 | |
| 405 | uint64_t ReadCache::ParseRecordId() { |
| 406 | if (dg4_block_ == nullptr) { |
nothing calls this directly
no test coverage detected