void MdfBlock::UpdateBlockSize(std::FILE *file, size_t bytes) { auto pos = FilePosition(); if (pos <= 0) { throw std::runtime_error("Invalid file position"); } if (file == nullptr) { throw std::runtime_error("File pointer is null"); } if (IsMdf4()) { if (block_length_ != static_cast (bytes)) { block_length_ = static_cast (bytes); pos += 8;
| 826 | } |
| 827 | */ |
| 828 | void MdfBlock::CreateMd4Block() { |
| 829 | const auto *metadata = MetaData(); |
| 830 | if (md_comment_ && md_comment_->BlockType() == "MD") { |
| 831 | // Already done |
| 832 | return; |
| 833 | } |
| 834 | |
| 835 | // Create an MD block and optional copy the text if it was a TX block |
| 836 | auto md4 = std::make_unique<Md4Block>(); |
| 837 | |
| 838 | std::ostringstream root_name; |
| 839 | root_name << BlockType() << "comment"; |
| 840 | |
| 841 | auto xml = CreateXmlFile(); |
| 842 | xml->RootName(root_name.str()); |
| 843 | |
| 844 | if (md_comment_) { |
| 845 | const auto *tx4 = dynamic_cast<const Tx4Block *>(md_comment_.get()); |
| 846 | xml->SetProperty("TX", tx4 != nullptr ? tx4->TxComment() : std::string()); |
| 847 | } |
| 848 | |
| 849 | if (this->BlockType() == "HD") { |
| 850 | xml->SetProperty("TX", std::string()); |
| 851 | } |
| 852 | |
| 853 | md4->XmlSnippet(xml->WriteString(true)); |
| 854 | md_comment_ = std::move(md4); |
| 855 | } |
| 856 | |
| 857 | IMetaData *MdfBlock::CreateMetaData() { |
| 858 | CreateMd4Block(); |
nothing calls this directly
no test coverage detected