diff --git a/BitStream.cs b/BitStream.cs index 4da6621..c6599eb 100644 --- a/BitStream.cs +++ b/BitStream.cs @@ -59,7 +59,7 @@ namespace SabreTools.Compression public byte? ReadBitLSB() => ReadBitInternal(false); /// - /// Read a full byte, if possible + /// Read a byte, if possible /// /// The next byte, null on error or end of stream public byte? ReadByte() @@ -82,7 +82,7 @@ namespace SabreTools.Compression } /// - /// Read a full UInt16, if possible + /// Read a UInt16, if possible /// /// The next UInt16, null on error or end of stream public ushort? ReadUInt16() @@ -105,7 +105,7 @@ namespace SabreTools.Compression } /// - /// Read a full UInt32, if possible + /// Read a UInt32, if possible /// /// The next UInt32, null on error or end of stream public uint? ReadUInt32() @@ -128,7 +128,7 @@ namespace SabreTools.Compression } /// - /// Read a full UInt64, if possible + /// Read a UInt64, if possible /// /// The next UInt64, null on error or end of stream public ulong? ReadUInt64() @@ -150,6 +150,30 @@ namespace SabreTools.Compression throw new NotImplementedException(); } + /// + /// Read bytes, if possible + /// + /// Number of bytes to read + /// The next paramref name="bytes"/> bytes, null on error or end of stream + public byte[] ReadBytes(int bytes) + { + // If we don't have a value cached + if (_lastRead == null) + { + try + { + return _source.ReadBytes(bytes); + } + catch + { + return null; + } + } + + // Otherwise, assemble the value from the next bits + throw new NotImplementedException(); + } + /// /// Read a single bit, if possible ///