Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Delta Compression in .NET

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).

like image 559
dubs Avatar asked May 04 '12 14:05

dubs


1 Answers

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.

like image 111
ta.speot.is Avatar answered Sep 21 '22 19:09

ta.speot.is