From 1b799bccb9edf9b044acef789dd31e2e14c218d8 Mon Sep 17 00:00:00 2001 From: Bradley Grainger Date: Sat, 11 Feb 2023 07:27:15 -0800 Subject: [PATCH] Rename BinaryPatchUtility to BinaryPatch. --- src/BsDiff/{BinaryPatchUtility.cs => BinaryPatch.cs} | 2 +- src/BsDiffTool/Program.cs | 8 ++++---- src/BsPatchTool/Program.cs | 2 +- tests/BsDiff.Tests/BinaryPatchTests.cs | 4 ++-- 4 files changed, 8 insertions(+), 8 deletions(-) rename src/BsDiff/{BinaryPatchUtility.cs => BinaryPatch.cs} (99%) diff --git a/src/BsDiff/BinaryPatchUtility.cs b/src/BsDiff/BinaryPatch.cs similarity index 99% rename from src/BsDiff/BinaryPatchUtility.cs rename to src/BsDiff/BinaryPatch.cs index b945134..d94ec21 100644 --- a/src/BsDiff/BinaryPatchUtility.cs +++ b/src/BsDiff/BinaryPatch.cs @@ -30,7 +30,7 @@ ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -public class BinaryPatchUtility +public class BinaryPatch { /// /// Creates a binary patch (in bsdiff format) that can be used diff --git a/src/BsDiffTool/Program.cs b/src/BsDiffTool/Program.cs index f4bf729..b2fdac0 100644 --- a/src/BsDiffTool/Program.cs +++ b/src/BsDiffTool/Program.cs @@ -26,7 +26,7 @@ public static void Main(string[] args) try { using (var output = new FileStream(patchFile, FileMode.Create)) - BinaryPatchUtility.Create(File.ReadAllBytes(oldFile), File.ReadAllBytes(newFile), output); + BinaryPatch.Create(File.ReadAllBytes(oldFile), File.ReadAllBytes(newFile), output); } catch (FileNotFoundException ex) { @@ -58,7 +58,7 @@ private static void CheckImplementation(string oldFile, string newFile) // run C# implementation var portTime = Stopwatch.StartNew(); using (var output = new FileStream(portPatchFileName, FileMode.Create)) - BinaryPatchUtility.Create(File.ReadAllBytes(oldFile), File.ReadAllBytes(newFile), output); + BinaryPatch.Create(File.ReadAllBytes(oldFile), File.ReadAllBytes(newFile), output); portTime.Stop(); Console.WriteLine("Patches created in {0} (reference) and {1} (C# port).", referenceTime.Elapsed, portTime.Elapsed); @@ -81,13 +81,13 @@ private static void CheckImplementation(string oldFile, string newFile) Console.Write("Applying reference patch with port binary..."); using (var input = new FileStream(oldFile, FileMode.Open, FileAccess.Read, FileShare.Read)) using (var output = new FileStream(outputFilePaths[2], FileMode.Create)) - BinaryPatchUtility.Apply(input, () => new FileStream(referencePatchFileName, FileMode.Open, FileAccess.Read, FileShare.Read), output); + BinaryPatch.Apply(input, () => new FileStream(referencePatchFileName, FileMode.Open, FileAccess.Read, FileShare.Read), output); Console.WriteLine("done."); Console.Write("Applying port patch with port binary..."); using (var input = new FileStream(oldFile, FileMode.Open, FileAccess.Read, FileShare.Read)) using (var output = new FileStream(outputFilePaths[3], FileMode.Create)) - BinaryPatchUtility.Apply(input, () => new FileStream(portPatchFileName, FileMode.Open, FileAccess.Read, FileShare.Read), output); + BinaryPatch.Apply(input, () => new FileStream(portPatchFileName, FileMode.Open, FileAccess.Read, FileShare.Read), output); Console.WriteLine("done."); var errors = 0; diff --git a/src/BsPatchTool/Program.cs b/src/BsPatchTool/Program.cs index 4297bad..79966b9 100644 --- a/src/BsPatchTool/Program.cs +++ b/src/BsPatchTool/Program.cs @@ -21,7 +21,7 @@ static void Main(string[] args) { using (var input = new FileStream(oldFile, FileMode.Open, FileAccess.Read, FileShare.Read)) using (var output = new FileStream(newFile, FileMode.Create)) - BinaryPatchUtility.Apply(input, () => new FileStream(patchFile, FileMode.Open, FileAccess.Read, FileShare.Read), output); + BinaryPatch.Apply(input, () => new FileStream(patchFile, FileMode.Open, FileAccess.Read, FileShare.Read), output); } catch (FileNotFoundException ex) { diff --git a/tests/BsDiff.Tests/BinaryPatchTests.cs b/tests/BsDiff.Tests/BinaryPatchTests.cs index 167c975..f448f53 100644 --- a/tests/BsDiff.Tests/BinaryPatchTests.cs +++ b/tests/BsDiff.Tests/BinaryPatchTests.cs @@ -123,7 +123,7 @@ public void ApplyFirstSentencePatch() private static void AssertCreatePatch(byte[] oldData, byte[] newData, int expectedLengthLow, int expectedLengthHigh) { using var outputStream = new MemoryStream(); - BinaryPatchUtility.Create(oldData, newData, outputStream); + BinaryPatch.Create(oldData, newData, outputStream); var patch = outputStream.ToArray(); Assert.InRange(patch.Length, expectedLengthLow, expectedLengthHigh); AssertHeader(patch.AsSpan(0, 32), newData.Length); @@ -139,7 +139,7 @@ private static void AssertApplyPatch(byte[] oldData, byte[] newData, byte[] patc { using var inputStream = new MemoryStream(oldData); using var outputStream = new MemoryStream(); - BinaryPatchUtility.Apply(inputStream, () => new MemoryStream(patch), outputStream); + BinaryPatch.Apply(inputStream, () => new MemoryStream(patch), outputStream); Assert.Equal(newData, outputStream.ToArray()); } }