コード例 #1
0
        private void readFile(string path, int numToRead)
        {
            if (File.Exists(path))
            {
                using (BinaryReader2 reader = new BinaryReader2(File.Open(path, FileMode.Open, FileAccess.Read, FileShare.ReadWrite)))
                {
                    Version = reader.ReadInt32();
                    if (Version == 3)
                    {
                        StartTime = FromLVTime(reader.ReadInt64(), reader.ReadUInt64());
                        int tempRead = 0;
                        while (reader.BaseStream.Position != reader.BaseStream.Length)
                        {
                            DateTime time = FromLVTime(reader.ReadInt64(), reader.ReadUInt64());
                            Int32    l    = reader.ReadInt32();
                            string   s    = System.Text.Encoding.ASCII.GetString(reader.ReadBytes(l));
                            //EntryList.Add(new InfoEntry(time, s));
                            //if (s.StartsWith("Warning <Code> 44008")) ReadWarning44008(s, time);
                            //if (s.StartsWith("Warning <Code> 44004")) ReadWarning44004(s, time);
                            if (s.Contains("FMS Connected:   Qualification") || s.Contains("FMS Connected:   Elimination") || s.Contains("FMS Connected:   Practice") || s.Contains("FMS Connected:   None"))
                            {
                                FMSMatch = true;
                                FMSData  = s;
                            }

                            //Make sure we don't read every line for the listView
                            if (numToRead != -1)
                            {
                                if (FMSMatch)
                                {
                                    if (s.Contains("FMS Event Name: "))
                                    {
                                        break;
                                    }
                                }
                                else if (numToRead < tempRead)
                                {
                                    break;
                                }
                                tempRead++;
                            }
                        }
                    }
                }
            }
        }
コード例 #2
0
ファイル: LogReader.cs プロジェクト: FRC5190/2019Retro
 public LogReader(string path)
 {
     if (File.Exists(path))
     {
         using (BinaryReader2 reader = new BinaryReader2(File.Open(path, FileMode.Open, FileAccess.Read, FileShare.ReadWrite)))
         {
             Version = reader.ReadInt32();
             if (Version == 3)
             {
                 StartTime = FromLVTime(reader.ReadInt64(), reader.ReadUInt64());
                 int i = 0;
                 while (reader.BaseStream.Position != reader.BaseStream.Length)
                 {
                     readEntry(reader, i++);
                 }
             }
             else
             {
                 Console.WriteLine("Invalid file: " + path);
             }
         }
     }
 }