public void LEReadWriteTest() { var ra = new RandomAccess(new byte[] { 1, 2, 3, 4 }); int value = ra.LongLE(); ra.JumpAbsolute(0); ra.WriteLongLE(value); ra.JumpAbsolute(0); int value2 = ra.LongLE(); Assert.AreEqual(value, value2); }
/// <summary> /// Instantiates a new TIME from the given binary reader. /// </summary> /// <remarks> /// The byte stream is read in the following order: /// <list type="bullet"> /// <item>Centiseconds</item> /// <item>Seconds</item> /// <item>Minutes</item> /// <item>Hours</item> /// </list> /// </remarks> /// <param name="rx"></param> public TpsTime(RandomAccess rx) { if (rx == null) { throw new ArgumentNullException(nameof(rx)); } // Time, mask encoded int time = rx.LongLE(); // Hours 0 - 23 int hours = (time & 0x7F000000) >> 24; // Minutes 0 - 59 int mins = (time & 0x00FF0000) >> 16; // Seconds 0 - 59 int secs = (time & 0x0000FF00) >> 8; // Centiseconds (seconds/100) 0 - 99 int centi = time & 0x000000FF; Value = new TimeSpan(0, hours, mins, secs, centi * 10); }
public TpsHeader(RandomAccess rx) { Data = rx ?? throw new ArgumentNullException(nameof(rx)); Address = rx.LongLE(); if (Address != 0) { throw new NotATopSpeedFileException("File does not start with 0x00000000. It is not a TopSpeed file or it may be encrypted."); } HeaderSize = rx.ShortLE(); var header = rx.Read(HeaderSize - 6); FileLength1 = header.LongLE(); FileLength2 = header.LongLE(); MagicNumber = header.FixedLengthString(4); Zeroes = header.ShortLE(); LastIssuedRow = header.LongBE(); Changes = header.LongLE(); ManagementPageReference = header.ToFileOffset(header.LongLE()); PageStart = header.ToFileOffset(header.LongArrayLE((0x110 - 0x20) / 4)); PageEnd = header.ToFileOffset(header.LongArrayLE((0x200 - 0x110) / 4)); }
public void ShouldParseLongLittleEndian(int value, byte[] data) { var rx = new RandomAccess(data); var parsed = rx.LongLE(); Assert.AreEqual(value, parsed); }
/// <summary> /// Instantiates a new LONG from the given binary reader. /// </summary> /// <param name="rx"></param> public TpsLong(RandomAccess rx) { if (rx == null) { throw new ArgumentNullException(nameof(rx)); } Value = rx.LongLE(); }
public TpsBlob(RandomAccess rx) { if (rx == null) { throw new ArgumentNullException(nameof(rx)); } Value = rx.ReadBytes(rx.LongLE()); }
public TpsPage(RandomAccess rx) { if (rx == null) { throw new ArgumentNullException(nameof(rx)); } Records = new List <TpsRecord>(); Address = rx.LongLE(); Size = rx.ShortLE(); var header = rx.Read(Size - 6); SizeUncompressed = header.ShortLE(); SizeUncompressedWithoutHeader = header.ShortLE(); RecordCount = header.ShortLE(); Flags = header.Byte(); CompressedData = header.Read(Size - 13); }