Advertisement
GAMELASTER

Some C# parsing...

Jun 14th, 2015
429
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.58 KB | None | 0 0
  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.  
  8. namespace recParser
  9. {
  10.     class Program
  11.     {
  12.         static void Main(string[] args)
  13.         {
  14.             /*gamiee has been here ^^*/
  15.             BinaryReader br = new BinaryReader(File.OpenRead("ais_2013-06-20_190159.rec"));
  16.             while (br.BaseStream.Position != br.BaseStream.Length)
  17.             {
  18.                 byte[] header = br.ReadBytes(2); //precita 2 byte
  19.                 Array.Reverse(header); //otoci kvoli big endianu
  20.                 byte[] goodHeader = { 255, 255 }; //0xFFFF
  21.                 if (!header.SequenceEqual(goodHeader)) //porovnava headre
  22.                 {
  23.                     Console.WriteLine("Wrong header!");
  24.                     Console.ReadLine();
  25.                 }
  26.                 //timestamp by mal mat asi 4byte?!?
  27.                 byte[] time = br.ReadBytes(4);
  28.                 Array.Reverse(time);
  29.                 Int32 timestamp = BitConverter.ToInt32(time, 0);
  30.                 //ziskat datetime z unixoveho timestampu ide troska inak v c#
  31.                 DateTime datetime = new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc);
  32.                 datetime = datetime.AddSeconds(timestamp);
  33.                 //dlzka
  34.                 byte[] dataLenght = br.ReadBytes(2);
  35.                 Array.Reverse(dataLenght);
  36.                 Int16 dataLen = BitConverter.ToInt16(dataLenght, 0);
  37.                 byte[] data = br.ReadBytes(dataLen);
  38.                 Array.Reverse(data);
  39.             }
  40.         }
  41.     }
  42. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement