public async Task <ReferencedGarc> GetGarc(GarcReference gr, bool useLz = false, bool edited = false) { var path = this.GetGarcPath(gr, edited); var file = await GarcFile.FromFile(path, useLz); return(new ReferencedGarc(file, gr)); }
public async Task DiffGameText() { using (var fs = new FileStream(Path.Combine(this.path, "GameText.diff.txt"), FileMode.Create, FileAccess.Write, FileShare.None)) using (var sw = new StreamWriter(fs)) { async Task WriteLine(string line = "") { TestContext.Progress.WriteLine(line); await sw.WriteLineAsync(line); } var cfg = ORASConfig.GameConfig; var garcRef = ORASConfig.GameConfig.GetGarcReference(GarcNames.GameText); var origPath = Path.Combine(this.path, $"{garcRef.RomFsPath}.orig"); var newPath = Path.Combine(this.path, garcRef.RomFsPath); var origGarc = await GarcFile.FromFile(origPath); var newGarc = await GarcFile.FromFile(newPath); Assert.AreEqual(origGarc.FileCount, newGarc.FileCount, "Re-written GameText GARC has different file count than original"); for (int file = 0; file < origGarc.FileCount; file++) { await WriteLine($"File #{file} {"-".Repeat( 50 )}"); TextFile origFile = new TextFile(cfg.Version, cfg.Variables); TextFile newFile = new TextFile(cfg.Version, cfg.Variables); origFile.Read(await origGarc.GetFile(file)); newFile.Read(await newGarc.GetFile(file)); Assert.AreEqual(origFile.LineCount, newFile.LineCount, $"File {file} has different number of lines than original"); for (int line = 0; line < origFile.LineCount; line++) { TextFile.LineInfo origInfo = origFile.LineInfos[line]; TextFile.LineInfo newInfo = newFile.LineInfos[line]; string origLine = origFile.Lines[line]; string newLine = newFile.Lines[line]; bool dLength = origInfo.Length != newInfo.Length; bool dOffset = origInfo.Offset != newInfo.Offset; bool dFlag = origInfo.Flag != newInfo.Flag; bool dLine = origLine != newLine; bool diff = dLength || dOffset || dFlag || dLine; if (diff) { await WriteLine($"[DIFF] line #{line}"); if (dLine) { await WriteLine($" Line Difference"); await WriteLine($" Original: {origLine}"); await WriteLine($" New: {newLine}"); } if (dLength) { await WriteLine($" Length Difference"); await WriteLine($" Original: {origInfo.Length}"); await WriteLine($" New: {newInfo.Length}"); } if (dOffset) { await WriteLine($" Offset Difference"); await WriteLine($" Original: {origInfo.Offset}"); await WriteLine($" New: {newInfo.Offset}"); } if (dFlag) { await WriteLine($" Flag Difference"); await WriteLine($" Original: {origInfo.Flag}"); await WriteLine($" New: {newInfo.Flag}"); } } else { // don't bother spamming test output with this await sw.WriteLineAsync($"[SAME] line #{line}"); } } } } }
public ReferencedGarc(GarcFile garc, GarcReference reference) { this.Garc = garc; this.Reference = reference; }