PseudoBufferedStream.cs 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. using System;
  2. using System.Collections.Generic;
  3. using System.IO;
  4. using System.Linq;
  5. using System.Text;
  6. using System.Threading.Tasks;
  7. namespace FF8
  8. {
  9. //useless class, to remove sooner or later- currently it's ms+br class, but there's no way to control the
  10. class PseudoBufferedStream : MemoryStream
  11. {
  12. BinaryReader br;
  13. public PseudoBufferedStream(byte[] buffer) : base(buffer)
  14. {
  15. br = new BinaryReader(this);
  16. }
  17. public void DisposeAll()
  18. {
  19. br.Close();
  20. br.Dispose();
  21. this.Close();
  22. Dispose();
  23. }
  24. public ushort ReadUShort() => br.ReadUInt16();
  25. public byte[] ReadBytes(uint count) => br.ReadBytes((int)count);
  26. #pragma warning disable 0114
  27. public byte ReadByte() => br.ReadByte(); //ms readbyte returns int
  28. #pragma warning restore 0114
  29. public short ReadShort() => br.ReadInt16();
  30. public uint ReadUInt() => br.ReadUInt32();
  31. public int ReadInt() => br.ReadInt32();
  32. public long Tell() => Position;
  33. }
  34. }