| 120 | } |
| 121 | |
| 122 | void Sr4Block::ReadData(std::streambuf& buffer) const { |
| 123 | const uint64_t count = DataSize(); |
| 124 | if (block_list_.empty() || count == 0) { |
| 125 | data_list_.clear(); |
| 126 | return; |
| 127 | } |
| 128 | try { |
| 129 | data_list_.resize(static_cast<size_t>(count), 0); |
| 130 | } catch (const std::exception& ) { |
| 131 | // No room in memory for the block. |
| 132 | data_list_.clear(); |
| 133 | return; |
| 134 | } |
| 135 | |
| 136 | // The block list should only contain one block. |
| 137 | // A SD block is uncompressed data block |
| 138 | uint64_t index = 0; |
| 139 | for (const auto &block : block_list_) { |
| 140 | const auto *list = dynamic_cast<const DataListBlock *>(block.get()); |
| 141 | const auto *data = dynamic_cast<const DataBlock *>(block.get()); |
| 142 | if (list != nullptr) { |
| 143 | list->CopyDataToBuffer( buffer, data_list_, index); |
| 144 | } else if (block != nullptr) { |
| 145 | data->CopyDataToBuffer(buffer, data_list_, index); |
| 146 | } |
| 147 | } |
| 148 | } |
| 149 | |
| 150 | void Sr4Block::ClearData() { |
| 151 | DataListBlock::ClearData(); |
nothing calls this directly
no test coverage detected