Has anyone been able to perform compression in a .NET environment to generate deltas between files. I'd like to use this functionality if at all possible, perhaps by using the functionality in msdelta.dll. I'd also be interested in how to generate deltas using other libraries (open source preferably).
I hope this isn't too much of a shameless plug, but I've written a wrapper library around both PatchAPI and MSDelta for my own purposes.
The library is dual-licensed under the MS-PL and DBAD-PL and available on GitHub.
I'm entertaining the notion of publishing the project on NuGet, but for the moment you can download the source and both create and apply deltas.
Creating a delta should be self-explanatory:
var compression = new MsDeltaCompression(); /* or PatchApiCompression(); */
compression.CreateDelta(sourcePath, destinationPath, deltaPath);
And equally self-explanatory (hopefully) is applying a delta:
var compression = new MsDeltaCompression(); /* or PatchApiCompression(); */
compression.ApplyDelta(deltaPath, sourcePath, destinationPath);
Tested on x86, but the P/Invoke signatures should be equally valid for x64 and ia64.
If you've haven't decided on whether you're using PatchAPI or MSDelta, my project's README.md
tries to suggest (briefly) which one you should use, but otherwise the documentation for Microsoft's Delta Compression has this to say about MSDelta vs. PatchAPI:
MSDelta ... can create much smaller compressed files than those produced by other methods. Shipping with Windows Vista, it is the next generation of the technology previously released as PatchAPI (which will continue to be supported).
Emphasis mine.
<your favourite web service framework here>
. If you were looking at functionality similar to RDC I must admit I've never seen RDC before and never intended for this to complement or supplant it. –
Tendinous Fossil SCM has a delta compression algorithm implemented in C, and I've made a port of it on C# here: https://github.com/endel/FossilDelta
To create the delta, you must provide a byte[]
of the origin and target. It is returned as byte[]
, which you can apply later.
byte[] origin = System.IO.File.ReadAllBytes ("old-file");
byte[] target = System.IO.File.ReadAllBytes ("new-file");
byte[] delta = Fossil.Delta.Create(origin, target);
Having the delta, you can apply the changes in the original file like this:
byte[] applied = Fossil.Delta.Apply(origin, delta);
I think it worth mentioning that the author of this algorithm is the same author of SQLite - so it has some credibility.
© 2022 - 2024 — McMap. All rights reserved.