diff options
| author | Luke Pulverenti <luke.pulverenti@gmail.com> | 2016-10-26 15:29:56 -0400 |
|---|---|---|
| committer | Luke Pulverenti <luke.pulverenti@gmail.com> | 2016-10-26 15:29:56 -0400 |
| commit | 3d7f75eea3465a34b443cf90d0affe5a637faf5d (patch) | |
| tree | 47be26c509373d62c560f65b2721c3185ba0e78d /DvdLib/BigEndianBinaryReader.cs | |
| parent | 0189f4c49dc89654e6aa10c5dd0fc50a0984bfec (diff) | |
more steps to make provider project portable
Diffstat (limited to 'DvdLib/BigEndianBinaryReader.cs')
| -rw-r--r-- | DvdLib/BigEndianBinaryReader.cs | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/DvdLib/BigEndianBinaryReader.cs b/DvdLib/BigEndianBinaryReader.cs new file mode 100644 index 000000000..56d9db825 --- /dev/null +++ b/DvdLib/BigEndianBinaryReader.cs @@ -0,0 +1,33 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.IO; + +namespace DvdLib +{ + public class BigEndianBinaryReader : BinaryReader + { + public BigEndianBinaryReader(Stream input) + : base(input) + { + } + + public override ushort ReadUInt16() + { + return BitConverter.ToUInt16(ReadAndReverseBytes(2), 0); + } + + public override uint ReadUInt32() + { + return BitConverter.ToUInt32(ReadAndReverseBytes(4), 0); + } + + private byte[] ReadAndReverseBytes(int count) + { + byte[] val = base.ReadBytes(count); + Array.Reverse(val, 0, count); + return val; + } + } +} |
