public Verifier(Stream rs, SRecordReader sr, bool apply) { this.romStream = rs; this.patchReader = sr; this.apply = apply; this.dispose = false; }
/// <summary> /// Dump the contents of an SRecord file. Mostly intended for development use. /// </summary> private static bool TryDumpSRecordFile(string path) { bool result = true; SRecord record; SRecordReader reader = new SRecordReader(path); reader.Open(); BlobList list = new BlobList(); while (reader.TryReadNextRecord(out record)) { if (!record.IsValid) { Trace.WriteLine(record.ToString()); result = false; continue; } list.ProcessRecord(record); Trace.WriteLine(record.ToString()); } Trace.WriteLine("Aggregated:"); foreach (Blob blob in list.Blobs) { Trace.WriteLine(blob.ToString()); } return(result); }
public Verifier(string patchPath, string romPath, bool apply) { this.patchPath = patchPath; this.romPath = romPath; this.apply = apply; this.patchReader = new SRecordReader(patchPath); this.romStream = File.OpenRead(romPath); this.dispose = true; }
public void Dispose() { if (dispose) { if (this.patchReader != null) { this.patchReader.Dispose(); this.patchReader = null; } if (this.romStream != null) { this.romStream.Dispose(); this.romStream = null; } } }
/// <summary> /// Constructor for external mods /// </summary> /// <param name="modPath"></param> public Mod(string modPath) { this.patchList = new List<Patch>(); this.ModAuthor = "Unknown Author"; this.ModBuild = "Unknown Build"; //MemoryStream modMemStream = new MemoryStream(); //using (FileStream fileStream = File.OpenRead(modPath)) //{ // modMemStream.SetLength(fileStream.Length); // fileStream.Read(modMemStream.GetBuffer(), 0, (int)fileStream.Length); //} FileInfo f = new FileInfo(modPath); FileSize = f.Length; FileName = f.Name; FilePath = modPath; isResource = false; reader = new SRecordReader(modPath);//modMemStream, modPath); TryReadPatches(); TryReversePatches(); }
/// <summary> /// Constructor for embedded mods /// </summary> /// <param name="s"></param> /// <param name="modPath"></param> public Mod(Stream s, string modPath) { this.patchList = new List<Patch>(); this.ModAuthor = "Unknown Author"; this.ModBuild = "Unknown Build"; reader = new SRecordReader(s, modPath); FileName = modPath; isResource = true; modStream = s; TryReadPatches(); TryReversePatches(); }
/// <summary> /// Constructor for external mods /// </summary> /// <param name="modPath"></param> public Mod(string modPath) { isAuthd = false; this.patchList = new List<Patch>(); this.ModAuthor = "Unknown Author"; this.ModBuild = "Unknown Build"; FileInfo f = new FileInfo(modPath); FileSize = f.Length; FileName = f.Name; FilePath = modPath; isResource = false; reader = new SRecordReader(modPath); TryReadPatches(); TryReversePatches(); }
/// <summary> /// Dump the contents of an SRecord file. Mostly intended for development use. /// </summary> private static bool TryDumpSRecordFile(string path) { bool result = true; SRecord record; SRecordReader reader = new SRecordReader(path); reader.Open(); BlobList list = new BlobList(); while (reader.TryReadNextRecord(out record)) { if (!record.IsValid) { Trace.WriteLine(record.ToString()); result = false; continue; } list.ProcessRecord(record); Trace.WriteLine(record.ToString()); } Trace.WriteLine("Aggregated:"); foreach (Blob blob in list.Blobs) { Trace.WriteLine(blob.ToString()); } return result; }