-
Notifications
You must be signed in to change notification settings - Fork 66
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
38 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
# Release Notes | ||
|
||
## 1.0.0 | ||
|
||
* Initial release. | ||
* Port of bsdiff 4.3 to managed code. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
## About | ||
|
||
BsDiff is a 100% managed implementation of Colin Percival's [bsdiff algorithm](https://www.daemonology.net/bsdiff/). | ||
It provides functions to create a patch between two binary files and to apply that patch (to the first file, producing the second file). | ||
The patch is usually much smaller than the size of the second file, so this can be used to optimize download size. | ||
|
||
## Usage | ||
|
||
Given two existing files, you can create a patch as follows: | ||
|
||
```csharp | ||
var oldFileBytes = File.ReadAllBytes("oldFile"); | ||
var newFileBytes = File.ReadAllBytes("newFile"); | ||
using var outputStream = File.Create("patchFile"); | ||
BinaryPatch.Create(oldFileBytes, newFileBytes, outputStream); | ||
``` | ||
|
||
You can then apply the patch to the old file to produce the new file: | ||
|
||
```csharp | ||
using var oldFile = File.OpenRead("oldFile"); | ||
using var newFile = File.Create("newFile"); | ||
BinaryPatch.Apply(oldFile, () => File.OpenRead("patchFile"), newFile); | ||
``` |