From 4efe91e552d6d7870e2ec99be7ea8f41a151d7e6 Mon Sep 17 00:00:00 2001 From: Kemal Setya Adhi Date: Sun, 29 Oct 2023 11:18:32 +0700 Subject: [PATCH] Move ``ReadExactly`` from duplicate ``StreamExtension`` class --- .../Binary/StreamExtensions.cs | 16 +++++++++++++++- .../PatchCore/PatchCore.cs | 19 ------------------- 2 files changed, 15 insertions(+), 20 deletions(-) diff --git a/Hi3Helper.SharpHDiffPatch/Binary/StreamExtensions.cs b/Hi3Helper.SharpHDiffPatch/Binary/StreamExtensions.cs index a87c917..2bffdad 100644 --- a/Hi3Helper.SharpHDiffPatch/Binary/StreamExtensions.cs +++ b/Hi3Helper.SharpHDiffPatch/Binary/StreamExtensions.cs @@ -4,10 +4,24 @@ namespace Hi3Helper.SharpHDiffPatch { - public static class StreamExtensions + public static class StreamExtension { private static byte[] StringBuffer = new byte[4 << 10]; + public static int ReadExactly(this Stream stream, byte[] buffer, int offset, int count) + { + int totalRead = 0; + while (totalRead < buffer.Length) + { + int read = stream.Read(buffer, offset, count); + if (read == 0) return totalRead; + + totalRead += read; + } + + return totalRead; + } + public static string ReadStringToNull(this Stream reader) { int currentValue; diff --git a/Hi3Helper.SharpHDiffPatch/PatchCore/PatchCore.cs b/Hi3Helper.SharpHDiffPatch/PatchCore/PatchCore.cs index ba0c50d..fd3dff1 100644 --- a/Hi3Helper.SharpHDiffPatch/PatchCore/PatchCore.cs +++ b/Hi3Helper.SharpHDiffPatch/PatchCore/PatchCore.cs @@ -31,25 +31,6 @@ internal struct CoverHeader internal RLERefClipStruct[] rleRefStruct; } -#if !NET7_0_OR_GREATER - internal static class StreamExtension - { - public static int ReadExactly(this Stream stream, byte[] buffer, int offset, int count) - { - int totalRead = 0; - while (totalRead < buffer.Length) - { - int read = stream.Read(buffer, offset, count); - if (read == 0) return totalRead; - - totalRead += read; - } - - return totalRead; - } - } -#endif - internal interface IPatchCore { void SetTDirPatcher(TDirPatcher input);