| 37 | } |
| 38 | |
| 39 | uint64_t DataBlock::CopyDataToBuffer(std::streambuf& buffer, |
| 40 | std::vector<uint8_t> &dest, |
| 41 | uint64_t &buffer_index) const { |
| 42 | SetFilePosition(buffer, DataPosition()); |
| 43 | const uint64_t data_size = DataSize(); |
| 44 | if (data_size == 0) { |
| 45 | return 0; |
| 46 | } |
| 47 | if (dest.size() < (buffer_index + data_size)) { |
| 48 | throw std::runtime_error("Buffer overflow detected."); |
| 49 | } |
| 50 | |
| 51 | const uint64_t reads = buffer.sgetn( |
| 52 | reinterpret_cast<char*>(dest.data()) + buffer_index, |
| 53 | static_cast<std::streamsize>(data_size)); |
| 54 | buffer_index += reads; |
| 55 | return reads; |
| 56 | } |
| 57 | |
| 58 | bool DataBlock::Data(const std::vector<uint8_t> &data) { |
| 59 | data_ = data; |
nothing calls this directly
no test coverage detected