| 80 | } |
| 81 | |
| 82 | void ObjectFileWriter::close() { |
| 83 | if (file == nullptr) { |
| 84 | LOGGER.error("File not opened: {}", filePath); |
| 85 | return; |
| 86 | } |
| 87 | |
| 88 | if (fseek(file.get(), sizeof(FileHeader), SEEK_SET) != 0) { |
| 89 | LOGGER.error("File seek failed: {}", filePath); |
| 90 | return; |
| 91 | } |
| 92 | |
| 93 | ContentHeader content_header = { |
| 94 | .recordVersion = this->recordVersion, |
| 95 | .recordSize = this->recordSize, |
| 96 | .recordCount = this->recordsWritten |
| 97 | }; |
| 98 | |
| 99 | if (fwrite(&content_header, sizeof(ContentHeader), 1, file.get()) != 1) { |
| 100 | LOGGER.error("Failed to write content header to {}", filePath); |
| 101 | } |
| 102 | |
| 103 | file = nullptr; |
| 104 | } |
| 105 | |
| 106 | bool ObjectFileWriter::write(void* data) { |
| 107 | if (file == nullptr) { |