summaryrefslogtreecommitdiff
path: root/split_patch_writer.h
diff options
context:
space:
mode:
authorAlex Deymo <deymo@google.com>2017-10-26 16:19:33 +0200
committerAlex Deymo <deymo@google.com>2017-10-27 13:52:46 +0200
commit4dadd8b4439358585be374226357b35aece52f17 (patch)
treecd92dfcebf2e1598284bf47a2506afdaae8ddc6f /split_patch_writer.h
parente4458302223554ed97c799d95d4197e042f6dfbb (diff)
downloadbsdiff-4dadd8b4439358585be374226357b35aece52f17.tar.gz
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
Diffstat (limited to 'split_patch_writer.h')
-rw-r--r--split_patch_writer.h5
1 files changed, 4 insertions, 1 deletions
diff --git a/split_patch_writer.h b/split_patch_writer.h
index 5aaabce..395f999 100644
--- a/split_patch_writer.h
+++ b/split_patch_writer.h
@@ -33,7 +33,7 @@ class SplitPatchWriter : public PatchWriterInterface {
// corresponding AddControlEntry() is not supported and will fail. The reason
// for this is because which underlying patch takes the bytes depends on the
// control entries.
- bool Init() override;
+ bool Init(size_t new_size) override;
bool WriteDiffStream(const uint8_t* data, size_t size) override;
bool WriteExtraStream(const uint8_t* data, size_t size) override;
bool AddControlEntry(const ControlEntry& entry) override;
@@ -53,6 +53,9 @@ class SplitPatchWriter : public PatchWriterInterface {
const uint8_t* data,
size_t size);
+ // The size of the new file for the patch we are writing.
+ size_t new_size_{0};
+
// The size of each chunk of the new file written to.
uint64_t new_chunk_size_;
std::vector<PatchWriterInterface*> patches_;