public static ReplayFile FromFileSystemEntry(FileSystemEntry entry, bool onlyHeader = false) { using (var stream = entry.Open()) using (var reader = new BinaryReader(stream, Encoding.Unicode, true)) { var result = new ReplayFile { Header = ReplayHeader.Parse(reader) }; if (onlyHeader) { return(result); } var chunks = new List <ReplayChunk>(); while (reader.BaseStream.Position < reader.BaseStream.Length) { chunks.Add(ReplayChunk.Parse(reader)); } result.Chunks = chunks; if (result.Header.NumTimecodes != chunks[chunks.Count - 1].Header.Timecode) { throw new InvalidDataException(); } return(result); } }
internal static ReplayChunk Parse(BinaryReader reader) { var result = new ReplayChunk { Header = ReplayChunkHeader.Parse(reader) }; var numUniqueArgumentTypes = reader.ReadByte(); // Pairs of {argument type, count}. var argumentCounts = new (OrderArgumentType argumentType, byte count)[numUniqueArgumentTypes];