Skip to content

Commit

Permalink
Move ReadExactly from duplicate StreamExtension class
Browse files Browse the repository at this point in the history
  • Loading branch information
neon-nyan committed Oct 29, 2023
1 parent 5fe6205 commit 4efe91e
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 20 deletions.
16 changes: 15 additions & 1 deletion Hi3Helper.SharpHDiffPatch/Binary/StreamExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
19 changes: 0 additions & 19 deletions Hi3Helper.SharpHDiffPatch/PatchCore/PatchCore.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit 4efe91e

Please sign in to comment.