public long ImportBsnesTraceLogsBinary(IEnumerable <string> filenames) { var importer = new BsnesTraceLogImporter(Project.Data.GetSnesApi()); foreach (var file in filenames) { using Stream source = File.OpenRead(file); const int bytesPerPacket = 22; var buffer = new byte[bytesPerPacket]; int bytesRead; while ((bytesRead = source.Read(buffer, 0, bytesPerPacket)) > 0) { Debug.Assert(bytesRead == 22); importer.ImportTraceLogLineBinary(buffer); } } return(importer.CurrentStats.NumRomBytesModified); }
public long ImportBsnesTraceLogs(string[] fileNames) { var importer = new BsnesTraceLogImporter(Project.Data.GetSnesApi()); // TODO: differentiate between binary-formatted and text-formatted files // probably look for a newline within 80 characters // call importer.ImportTraceLogLineBinary() var largeFilesReader = controllerFactory.GetLargeFileReaderProgressController(); // caution: trace logs can be gigantic, even a few seconds can be > 1GB // inside here, performance becomes critical. largeFilesReader.Filenames = new List <string>(fileNames); largeFilesReader.LineReadCallback = line => importer.ImportTraceLogLine(line); largeFilesReader.Run(); if (importer.CurrentStats.NumRomBytesModified > 0) { MarkChanged(); } return(importer.CurrentStats.NumRomBytesModified); }