4 Commits
Author SHA1 Message Date
Tianjie Xu 18480eb706 Implement a simple logger for bsdiff
The logger supports LOG & PLOG. It also adds a std::endl at the end of
the stream so that we don't need to add it manually at the callsite.

Test: run bsdiff and check the logs.
Change-Id: Ice94902a501532ceaeb480c3576e752e435cab70
2017-11-30 12:28:06 -08:00
Alex Deymo 4dadd8b443 Pass the size of the new file to the PatchWriterInterface::Init()
Most patch formats include the size of the new file in the header.
To help streaming the patch to disk while generating it, this CL
passes the size of the new file to the patch writer on initialization.

To do this, we also move the Init() call to the patch writer to the
DiffEncoder, which makes more sense since the Close() call is also made
from the DiffEnconder.

Bug: None
Test: Updated tests to check for this value.
Change-Id: Idfaedbd492d68ab6e6cb2c1cb3883947f068c3aa
2017-10-27 13:52:46 +02:00
Alex Deymo aefc253cd9 Add some more checkings to the DiffEncoder.
Check that we don't attempt to use the region outside the old file.
While this is supported by our decoder, there's no reason why we should
do that and it often means a bug in the encoder.

Bug: None
Test: Added unittests that would fail without the fixes.
Change-Id: Ifd6d8763ae4e6b3f29a5a1289f22900a278dd1b0
2017-10-26 15:37:57 +02:00
Alex Deymo 68c0e7f206 Reduce PatchWriterInterface functionality.
The recently introduced PatchWriterInterface had both the patch file
format logic and the diff/extra streams selection from the control
entries. While this simplifies the bsdiff main algorithm and makes
invalid usages of the BsdiffPatchWriter evident, writing alternative
PatchWriterInterface classes required to replicate the diff/extra
stream selection logic.

This patch splits out the diff/extra stream generation and all the
checks around those to a new helper class DiffEncoder. The public
interface PatchWriterInterface now has two methods to accept the diff
and extra stream data, and does not compute them.

Bug: 34220646
Test: Added unittests. Ran bsdiff on some pairs of files obtaining the same result as before.
Change-Id: I5f303c06f1e10910eb00dcfda38c6811977a91cf
2017-10-09 12:50:33 +02:00