size_t MdfBlock::Write(std::FILE *file) { if (file == nullptr) { throw std::runtime_error("File pointer is null"); } SetLastFilePosition(file); file_position_ = GetFilePosition(file); size_t bytes = 0; if (IsMdf4()) { bytes += WriteStr(file, block_type_, 4); const std::vector reserved(4, 0); bytes += WriteByte(file, reserved); bytes += WriteNumber(file, bl
| 688 | } |
| 689 | */ |
| 690 | void MdfBlock::SetLastFilePosition(std::streambuf& buffer) const { |
| 691 | constexpr char fill = 0; |
| 692 | auto pos = buffer.pubseekoff(0, std::ios_base::end); |
| 693 | if (pos < 0) { |
| 694 | throw std::ios_base::failure("Failed to set last file position"); |
| 695 | } |
| 696 | if (IsMdf4()) { |
| 697 | // If this is an MDF4 file, fill with empty byte so the position |
| 698 | // has 64-bits alignments. |
| 699 | for (pos = GetFilePosition(buffer); (pos % 8) != 0; |
| 700 | pos = GetFilePosition(buffer)) { |
| 701 | buffer.sputc(fill); |
| 702 | } |
| 703 | } |
| 704 | } |
| 705 | /* |
| 706 | void MdfBlock::SetLastFilePosition(std::FILE *file) const { |
| 707 | Platform::fseek64(file, 0, SEEK_END); |
no test coverage detected