| 611 | } |
| 612 | |
| 613 | uint64_t MdfBlock::Write(std::streambuf& buffer) { |
| 614 | SetLastFilePosition(buffer); |
| 615 | file_position_ = GetFilePosition(buffer); |
| 616 | |
| 617 | uint64_t bytes = 0; |
| 618 | if (IsMdf4()) { |
| 619 | bytes += WriteStr(buffer, block_type_, 4); |
| 620 | const std::vector<uint8_t> reserved(4, 0); |
| 621 | bytes += WriteByte(buffer, reserved); |
| 622 | bytes += WriteNumber(buffer, block_length_); |
| 623 | uint64_t link_count = link_list_.size(); |
| 624 | bytes += WriteNumber(buffer, link_count); |
| 625 | for (auto link : link_list_) { |
| 626 | bytes += WriteNumber(buffer, link); |
| 627 | } |
| 628 | } else { |
| 629 | bytes += WriteStr(buffer, block_type_, 2); |
| 630 | bytes += WriteNumber(buffer, block_size_); |
| 631 | link_count_ = link_list_.size(); |
| 632 | for (auto link : link_list_) { |
| 633 | const auto link32 = static_cast<uint32_t>(link); |
| 634 | bytes += WriteNumber(buffer, link32); |
| 635 | } |
| 636 | } |
| 637 | return bytes; |
| 638 | } |
| 639 | |
| 640 | uint64_t MdfBlock::Update(std::streambuf& buffer) const { |
| 641 | SetFilePosition(buffer, FilePosition()); |
no test coverage detected