https://github.com/jzebedee/deltaq
Fast and portable delta encoding for .NET in 100% safe, managed code.
https://github.com/jzebedee/deltaq
bsdiff bwt delta diff divsufsort patch sais suffix-array vcdiff xdelta
Last synced: 22 days ago
JSON representation
Fast and portable delta encoding for .NET in 100% safe, managed code.
- Host: GitHub
- URL: https://github.com/jzebedee/deltaq
- Owner: jzebedee
- License: other
- Created: 2014-10-19T04:05:10.000Z (over 11 years ago)
- Default Branch: master
- Last Pushed: 2023-12-04T00:31:29.000Z (over 2 years ago)
- Last Synced: 2026-03-06T09:24:39.937Z (about 2 months ago)
- Topics: bsdiff, bwt, delta, diff, divsufsort, patch, sais, suffix-array, vcdiff, xdelta
- Language: C#
- Homepage:
- Size: 555 KB
- Stars: 44
- Watchers: 4
- Forks: 13
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE.md
Awesome Lists containing this project
README
#  DeltaQ
Fast and portable delta encoding for .NET in 100% safe, managed code.
DeltaQ is available for use as a library in .NET and .NET Framework, and as a cross-platform command-line tool, `dq`, which can be used to perform delta operations (similar to `bsdiff` or `xdelta`).
## Support
Discussion and technical support is available on Discord.
[](https://discord.gg/FkRPyz6kcD)
## Installing
### `dq` command-line tool
[](https://www.nuget.org/packages/DeltaQ.CommandLine)
`> dotnet tool install DeltaQ.CommandLine -g`
### `DeltaQ` library
[](https://www.nuget.org/packages/DeltaQ)
`> dotnet add package DeltaQ`
## Usage
### `dq` command-line tool
#### Create a binary delta (diff) with BsDiff
`dq bsdiff `
Here's an example of `dq` creating a `bsdiff` delta for patching file `app_v1.exe` into `app_v2.exe`:
```
> ls -sh
total 32M
16M app_v1.exe 17M app_v2.exe
> dq bsdiff app_v1.exe app_v2.exe v1_to_v2.delta
Generating BsDiff delta between
Old file: "app_v1.exe"
New file: "app_v2.exe"
Delta file: "v1_to_v2.delta"
Delta size: 4.28 MB (13.49%)
```
#### Apply a binary delta (patch) with BsDiff
`dq bspatch `
Instead of distributing the large `app_v2.exe` when it's time to upgrade, `dq` can recreate it by applying the much smaller delta file `v1_to_v2.delta` to the original `app_v1.exe`:
```
> dq bspatch app_v1.exe v1_to_v2.delta generated_app_v2.exe
Applying BsDiff delta between
Old file: "app_v1.exe"
Delta file: "v1_to_v2.delta"
New file: "generated_app_v2.exe"
```
```
> sha256sum app_v2.exe generated_app_v2.exe
fab165a6e604dc7f9265d13013b6fb06319faec4eaa251a8a6d74a7e30e38dc6 app_v2.exe
fab165a6e604dc7f9265d13013b6fb06319faec4eaa251a8a6d74a7e30e38dc6 generated_app_v2.exe
```
### `DeltaQ` library
The `DeltaQ` package contains all currently supported delta encoding and suffix sorting providers, for use in your own .NET projects.
#### Example: bsdiff and bspatch files
```cs
using System.IO;
using DeltaQ.BsDiff;
using DeltaQ.SuffixSorting;
using DeltaQ.SuffixSorting.LibDivSufSort;
void MakeDelta() {
var oldData = File.ReadAllBytes("oldfile.txt");
var newData = File.ReadAllBytes("newfile.txt");
using var outStream = File.Create("old_to_new.delta");
ISuffixSort suffixSorter = new LibDivSufSort();
Diff.Create(oldData, newData, outStream, suffixSorter);
}
void UseDelta() {
var oldData = File.ReadAllBytes("oldfile.txt");
var deltaData = File.ReadAllBytes("old_to_new.delta");
using var outStream = File.Create("generated_newfile.txt");
Patch.Apply(oldData, deltaData, outStream);
}
```
#### Example: Suffix sorting with LibDivSufSort
```cs
using DeltaQ.SuffixSorting;
using DeltaQ.SuffixSorting.LibDivSufSort;
ISuffixSort suffixSorter = new LibDivSufSort();
ReadOnlySpan text = new byte[] { 1, 2, 3, 4 };
using var ownedSuffixArray = suffixSorter.Sort(text);
ReadOnlySpan sortedSuffixes = ownedSuffixArray.Memory.Span;
```