| 64 | } |
| 65 | |
| 66 | void Finish() override |
| 67 | { |
| 68 | // write version information |
| 69 | { |
| 70 | FilesContainerW writer(m_filename); |
| 71 | auto w = writer.GetWriter(VERSION_FILE_TAG); |
| 72 | version::WriteVersion(*w, m_versionDate); |
| 73 | } |
| 74 | |
| 75 | // write own mwm header |
| 76 | m_header.SetBounds(m_bounds); |
| 77 | { |
| 78 | FilesContainerW writer(m_filename, FileWriter::OP_WRITE_EXISTING); |
| 79 | auto w = writer.GetWriter(HEADER_FILE_TAG); |
| 80 | m_header.Save(*w); |
| 81 | } |
| 82 | |
| 83 | // write region info |
| 84 | { |
| 85 | FilesContainerW writer(m_filename, FileWriter::OP_WRITE_EXISTING); |
| 86 | auto w = writer.GetWriter(REGION_INFO_FILE_TAG); |
| 87 | m_regionData.Serialize(*w); |
| 88 | } |
| 89 | |
| 90 | // assume like we close files |
| 91 | Flush(); |
| 92 | |
| 93 | { |
| 94 | FilesContainerW writer(m_filename, FileWriter::OP_WRITE_EXISTING); |
| 95 | auto w = writer.GetWriter(FEATURES_FILE_TAG); |
| 96 | |
| 97 | size_t const startOffset = w->Pos(); |
| 98 | CHECK(coding::IsAlign8(startOffset), ()); |
| 99 | |
| 100 | feature::DatSectionHeader header; |
| 101 | header.Serialize(*w); |
| 102 | |
| 103 | uint64_t bytesWritten = static_cast<uint64_t>(w->Pos()); |
| 104 | coding::WritePadding(*w, bytesWritten); |
| 105 | |
| 106 | header.m_featuresOffset = base::asserted_cast<uint32_t>(w->Pos() - startOffset); |
| 107 | ReaderSource<ModelReaderPtr> src(std::make_unique<FileReader>(m_dataFile.GetName())); |
| 108 | rw::ReadAndWrite(src, *w); |
| 109 | header.m_featuresSize = base::asserted_cast<uint32_t>(w->Pos() - header.m_featuresOffset - startOffset); |
| 110 | |
| 111 | auto const endOffset = w->Pos(); |
| 112 | w->Seek(startOffset); |
| 113 | header.Serialize(*w); |
| 114 | w->Seek(endOffset); |
| 115 | } |
| 116 | |
| 117 | // File Writer finalization function with adding section to the main mwm file. |
| 118 | auto const finalizeFn = [this](std::unique_ptr<TmpFile> && tmpFile, std::string const & tag) |
| 119 | { |
| 120 | auto & w = tmpFile->GetWriter(); |
| 121 | w.Flush(); |
| 122 | FilesContainerW writer(m_filename, FileWriter::OP_WRITE_EXISTING); |
| 123 | writer.Write(w.GetName(), tag); |
no test coverage detected