From 01506da2446825ee48b3245b7ad4efdd56620745 Mon Sep 17 00:00:00 2001 From: adelikat Date: Thu, 3 Jul 2014 18:32:41 +0000 Subject: [PATCH] More Util cleanup - move an extension method to a more appropriate file and remove an unused method --- BizHawk.Common/Extensions/IOExtensions.cs | 13 ++++++++++ BizHawk.Common/Util.cs | 29 ----------------------- 2 files changed, 13 insertions(+), 29 deletions(-) diff --git a/BizHawk.Common/Extensions/IOExtensions.cs b/BizHawk.Common/Extensions/IOExtensions.cs index 8d63178a3a..ca14b3a570 100644 --- a/BizHawk.Common/Extensions/IOExtensions.cs +++ b/BizHawk.Common/Extensions/IOExtensions.cs @@ -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; diff --git a/BizHawk.Common/Util.cs b/BizHawk.Common/Util.cs index f7aa038fa8..f41faa0655 100644 --- a/BizHawk.Common/Util.cs +++ b/BizHawk.Common/Util.cs @@ -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(); - } - /// /// Converts bytes to an uppercase string of hex numbers in upper case without any spacing or anything /// //could be extension method