wabbajack/Wabbajack.Installer/Utilities/BinaryPatching.cs

19 lines
623 B
C#
Raw Normal View History

2021-09-27 12:42:46 +00:00
using System.IO;
2022-10-23 21:28:44 +00:00
using System.Threading;
2021-09-27 12:42:46 +00:00
using System.Threading.Tasks;
using Octodiff.Core;
using Octodiff.Diagnostics;
2022-10-23 21:28:44 +00:00
using Wabbajack.Hashing.xxHash64;
2021-09-27 12:42:46 +00:00
2021-10-23 16:51:17 +00:00
namespace Wabbajack.Installer.Utilities;
public class BinaryPatching
2021-09-27 12:42:46 +00:00
{
2022-10-23 21:28:44 +00:00
public static async ValueTask<Hash> ApplyPatch(Stream input, Stream deltaStream, Stream output, CancellationToken? token = null)
2021-09-27 12:42:46 +00:00
{
2021-10-23 16:51:17 +00:00
var deltaApplier = new DeltaApplier();
deltaApplier.Apply(input, new BinaryDeltaReader(deltaStream, new NullProgressReporter()), output);
2022-10-23 21:28:44 +00:00
output.Position = 0;
return await output.Hash(token ?? CancellationToken.None);
2021-09-27 12:42:46 +00:00
}
}