| 721 | |
| 722 | |
| 723 | void MdfBlock::UpdateLink(std::streambuf& buffer, size_t link_index, int64_t link) { |
| 724 | if (link_index >= link_list_.size()) { |
| 725 | throw std::runtime_error("index is out of bounds"); |
| 726 | } |
| 727 | if (link == link_list_[link_index]) { |
| 728 | return; // No need to update the link |
| 729 | } |
| 730 | |
| 731 | auto pos = FilePosition(); |
| 732 | |
| 733 | // If the block not yet is written, the link will be written later |
| 734 | if (pos > 0) { |
| 735 | if (IsMdf4()) { |
| 736 | pos += 24 + static_cast<int64_t>(link_index * 8); |
| 737 | SetFilePosition(buffer, pos); |
| 738 | WriteNumber(buffer, link); |
| 739 | } else { |
| 740 | pos += 4 + static_cast<int64_t>(link_index * 4); |
| 741 | const auto link32 = static_cast<uint32_t>(link); |
| 742 | SetFilePosition(buffer, pos); |
| 743 | WriteNumber(buffer, link32); |
| 744 | } |
| 745 | } |
| 746 | link_list_[link_index] = link; |
| 747 | } |
| 748 | |
| 749 | void MdfBlock::UpdateBlockSize(std::streambuf& buffer, uint64_t bytes) { |
| 750 | auto pos = FilePosition(); |
no test coverage detected