using System.IO; using System.Text; namespace IgniteEngine.IO { /// /// Class to read from a of binary. /// public class BinaryReader : System.IO.BinaryReader { /// /// The length of the stream. /// public long Length => BaseStream.Length; /// /// Creates a new instance of the class. /// /// The stream to read from. public BinaryReader(Stream input) : base(input) { } /// /// Reads a string from the binary stream. /// /// The length of the bytes to read. /// The string that was read. public string ReadString(int length) { var ret = string.Empty; var offset = 0; var buffer = ReadBytes(length); while (offset < length && buffer[offset] != 0x00) { offset++; } if (length > 0) { ret = Encoding.UTF8.GetString(buffer, 0, offset); } return ret; } } }