More Util cleanup - move an extension method to a more appropriate file and remove an unused method
This commit is contained in:
parent
a9aa65397c
commit
01506da244
|
@ -1,5 +1,6 @@
|
|||
using System;
|
||||
using System.IO;
|
||||
using System.Text;
|
||||
|
||||
namespace BizHawk.Common.IOExtensions
|
||||
{
|
||||
|
@ -22,6 +23,18 @@ namespace BizHawk.Common.IOExtensions
|
|||
return outStream.ToArray();
|
||||
}
|
||||
|
||||
// Read bytes from a BinaryReader and translate them into the UTF-8 string they represent.
|
||||
public static string ReadStringFixedAscii(this BinaryReader r, int bytes)
|
||||
{
|
||||
var read = new byte[bytes];
|
||||
for (var b = 0; b < bytes; b++)
|
||||
{
|
||||
read[b] = r.ReadByte();
|
||||
}
|
||||
|
||||
return Encoding.UTF8.GetString(read);
|
||||
}
|
||||
|
||||
public static void CopyTo(this Stream src, Stream dest)
|
||||
{
|
||||
int size = (src.CanSeek) ? Math.Min((int)(src.Length - src.Position), 0x2000) : 0x2000;
|
||||
|
|
|
@ -81,35 +81,6 @@ namespace BizHawk.Common
|
|||
return 0;
|
||||
}
|
||||
|
||||
// Read bytes from a BinaryReader and translate them into the UTF-8 string they represent.
|
||||
public static string ReadStringFixedAscii(this BinaryReader r, int bytes)
|
||||
{
|
||||
var read = new byte[bytes];
|
||||
for (var b = 0; b < bytes; b++)
|
||||
{
|
||||
read[b] = r.ReadByte();
|
||||
}
|
||||
|
||||
return Encoding.UTF8.GetString(read);
|
||||
}
|
||||
|
||||
public static string ReadStringAsciiZ(this BinaryReader r)
|
||||
{
|
||||
var sb = new StringBuilder();
|
||||
for (;;)
|
||||
{
|
||||
int b = r.ReadByte();
|
||||
if (b <= 0)
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
sb.Append((char)b);
|
||||
}
|
||||
|
||||
return sb.ToString();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Converts bytes to an uppercase string of hex numbers in upper case without any spacing or anything
|
||||
/// //could be extension method
|
||||
|
|
Loading…
Reference in New Issue