| 29 | }; |
| 30 | |
| 31 | bool MakeDiffVersion0(FileReader & oldReader, FileReader & newReader, FileWriter & diffFileWriter) |
| 32 | { |
| 33 | std::vector<uint8_t> diffBuf; |
| 34 | MemWriter<std::vector<uint8_t>> diffMemWriter(diffBuf); |
| 35 | |
| 36 | auto const status = bsdiff::CreateBinaryPatch(oldReader, newReader, diffMemWriter); |
| 37 | |
| 38 | if (status != bsdiff::BSDiffStatus::OK) |
| 39 | { |
| 40 | LOG(LERROR, ("Could not create patch with bsdiff:", status)); |
| 41 | return false; |
| 42 | } |
| 43 | |
| 44 | using Deflate = coding::ZLib::Deflate; |
| 45 | Deflate deflate(Deflate::Format::ZLib, Deflate::Level::BestCompression); |
| 46 | |
| 47 | std::vector<uint8_t> deflatedDiffBuf; |
| 48 | deflate(diffBuf.data(), diffBuf.size(), back_inserter(deflatedDiffBuf)); |
| 49 | |
| 50 | // A basic header that holds only version. |
| 51 | WriteToSink(diffFileWriter, static_cast<uint32_t>(VERSION_V0)); |
| 52 | diffFileWriter.Write(deflatedDiffBuf.data(), deflatedDiffBuf.size()); |
| 53 | |
| 54 | return true; |
| 55 | } |
| 56 | |
| 57 | generator::mwm_diff::DiffApplicationResult ApplyDiffVersion0(FileReader & oldReader, FileWriter & newWriter, |
| 58 | ReaderSource<FileReader> & diffFileSource, |
no test coverage detected