sisong / HDiffPatch

a C\C++ library and command-line tools for Diff & Patch between binary files or directories(folder); cross-platform; runs fast; create small delta/differential; support large files and limit memory requires when diff & patch.
Other
1.52k stars 280 forks source link

Feature request: partial patch #346

Closed JeWe37 closed 1 year ago

JeWe37 commented 1 year ago

I would like to be able to read only a specific section (offset, length) of a patched file, but with the current APIs I need to patch the entire file to do that, which introduces a lot of latency and/or requires a lot of space-inefficient caching.

sisong commented 1 year ago

HDiffPatch does not support partial patch now;
You may need to modify and implement it yourself;
From your requirements description, it's like in-place update? refer discussion #36 .

JeWe37 commented 1 year ago

Assuming the translation is correct that seems so

I have done a bit of experimenting with this myself and getting a sketch implemented for the old APIs(patch(...)) was relatively easy, but I can't say I understand the code of the new APIs well enough to do the same for those. The algorithm I came up with was essentially the same as is outlined in that issue, basically just have a sorted list for the covers and run length encoding sequences, then whenever a specific segment is read do a binary search for each and apply the values till the end of the range.

I'll close this as a duplicate.