SharpHDiffPatch.Core
2.2.8
dotnet add package SharpHDiffPatch.Core --version 2.2.8
NuGet\Install-Package SharpHDiffPatch.Core -Version 2.2.8
<PackageReference Include="SharpHDiffPatch.Core" Version="2.2.8" />
paket add SharpHDiffPatch.Core --version 2.2.8
#r "nuget: SharpHDiffPatch.Core, 2.2.8"
// Install SharpHDiffPatch.Core as a Cake Addin #addin nuget:?package=SharpHDiffPatch.Core&version=2.2.8 // Install SharpHDiffPatch.Core as a Cake Tool #tool nuget:?package=SharpHDiffPatch.Core&version=2.2.8
SharpHDiffPatch
SharpHDiffPatch is a patching library for HDiffPatch format written in C#, purposedly as a port of HPatchZ implementation (from HDiffPatch by housisong). This project doesn't support making diff file and only works for patching.
Supporting file and directory patching with these compression formats:
- BZip2
- Deflate
- Zstd
- LZMA2 (not LZMA)
- No Compression.
Unfortunately, the HDIFFSF20
(Single Compressed) format is still unsupported. But we are planning to add it in the future.
This project is used as a part submodule of our main project: Collapse Launcher.
Usage Example
Patching with a simple progress indicator
using SharpHDiffPatch.Core;
using SharpHDiffPatch.Core.Event;
string oldPath = "C:\\test\\Music1.pck";
string diffPath = "C:\\test\\Music1.pck.hdiff";
string newPath = "C:\\test\\Music1.pck.new";
// Initialize the patcher instance
HDiffPatch patcher = new HDiffPatch();
// Set the verbosity of the logging
// Available Options: Quiet, Info (default), Verbose, Debug
HDiffPatch.LogVerbosity = Verbosity.Verbose;
// Subscribe an event listener to logging
EventListener.LoggerEvent += EventListener_LoggerEvent;
// Subscribe an event listener to patching progress
EventListener.PatchEvent += EventListener_PatchEvent;
// Initialize the diff file
patcher.Initialize(diffPath);
// Start the patching process
// This method has some arguments you can tweak as below:
// Patch(string inputPath, string outputPath, bool useBufferedPatch,
// CancellationToken token = default, bool useFullBuffer = false,
// bool useFastBuffer = false)
//
// Description:
// - inputPath -> Path of the old/source file/folder.
// - outputPath -> Path of the new/target file/folder.
// - useBufferedPatch -> Use array-based buffer for RLE Control and Code clips.
// - token -> Cancellation token.
// - useFullBuffer -> Buffer the RLE New Data to the MemoryStream.
// - useFastBuffer -> Buffer the RLE Control and Code clips to ArrayPool.
patcher.Patch(inputPath, outputPath, true, default, false, true);
// Unsubscribe an event listener to logging
EventListener.LoggerEvent -= EventListener_LoggerEvent;
// Unsubscribe an event listener to patching progress
EventListener.PatchEvent -= EventListener_PatchEvent;
// Implement logging listener
private void EventListener_LoggerEvent(object? sender, LoggerEvent e)
{
string label = e.LogLevel switch
{
Verbosity.Info => $"[Info] ",
Verbosity.Verbose => $"[Verbose] ",
Verbosity.Debug => $"[Debug] ",
_ => ""
};
Console.WriteLine($"{label}{e.Message}");
}
// Implement patching progress listener
private void EventListener_PatchEvent(object? sender, PatchEvent e)
{
Console.Write($"Patching: {e.ProgressPercentage}% | {SummarizeSizeSimple(e.CurrentSizePatched)}/{SummarizeSizeSimple(e.TotalSizeToBePatched)} @{SummarizeSizeSimple(e.Speed)}/s \r");
}
Get the New file size from diff file.
using SharpHDiffPatch.Core;
string diffPath = "C:\\test\\Music1.pck.hdiff";
long newFileSize = HDiffPatch.GetHDiffNewSize(diffPath);
Console.WriteLine($"The new file size is: {newFileSize} bytes");
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net5.0 was computed. net5.0-windows was computed. net6.0 is compatible. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 is compatible. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 is compatible. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net9.0 is compatible. |
.NET Core | netcoreapp2.0 was computed. netcoreapp2.1 was computed. netcoreapp2.2 was computed. netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
.NET Standard | netstandard2.0 is compatible. netstandard2.1 was computed. |
.NET Framework | net461 was computed. net462 was computed. net463 was computed. net47 was computed. net471 was computed. net472 was computed. net48 was computed. net481 was computed. |
MonoAndroid | monoandroid was computed. |
MonoMac | monomac was computed. |
MonoTouch | monotouch was computed. |
Tizen | tizen40 was computed. tizen60 was computed. |
Xamarin.iOS | xamarinios was computed. |
Xamarin.Mac | xamarinmac was computed. |
Xamarin.TVOS | xamarintvos was computed. |
Xamarin.WatchOS | xamarinwatchos was computed. |
-
.NETStandard 2.0
- System.Buffers (>= 4.5.1)
- System.Memory (>= 4.5.5)
- ZstdSharp.Port (>= 0.8.1)
-
net6.0
- Hi3Helper.ZstdNet (>= 1.6.2)
- ZstdSharp.Port (>= 0.8.1)
-
net7.0
- Hi3Helper.ZstdNet (>= 1.6.2)
- ZstdSharp.Port (>= 0.8.1)
-
net8.0
- Hi3Helper.ZstdNet (>= 1.6.2)
- ZstdSharp.Port (>= 0.8.1)
-
net9.0
- Hi3Helper.ZstdNet (>= 1.6.2)
- ZstdSharp.Port (>= 0.8.1)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories (1)
Showing the top 1 popular GitHub repositories that depend on SharpHDiffPatch.Core:
Repository | Stars |
---|---|
CollapseLauncher/Collapse
An Advanced Launcher for miHoYo/HoYoverse Games
|