public static ThpsWad FromList(string filename) { if (!File.Exists(filename)) { throw new Exception($"Not found: {filename}"); } string[] lines = File.ReadAllLines(filename); string path = Path.ChangeExtension(filename, ""); ThpsWad wad = new ThpsWad(); foreach (string s in lines) { if (s != "") { ThpsWadEntry en = new ThpsWadEntry(Path.Combine(path, s.Trim())); wad.Entries.Add(en); } } wad.RecalcOffsets(); return(wad); }
public ThpsWadEntry(uint c, int off, int s) { checksum = c; size = s; offset = off; name = ThpsWad.GetName(checksum); }
public ThpsWadEntry(BinaryReader br) { checksum = br.ReadUInt32(); if (checksum != 0) { offset = br.ReadInt32(); size = br.ReadInt32(); name = ThpsWad.GetName(checksum); } }
/// <summary> /// Static method to create ThpsWad object from HED/WAD files. /// </summary> /// <param name="hedFile">Path to HED</param> /// <param name="wadFile">Path to WAD</param> /// <returns>ThpsWad object.</returns> public static ThpsWad FromFile(string hedFile, string wadFile) { if (!File.Exists(hedFile)) { throw new Exception($"Not found: {hedFile}"); } if (!File.Exists(wadFile)) { throw new Exception($"Not found: {wadFile}"); } using (BinaryReader hed = new BinaryReader(File.OpenRead(hedFile))) { using (BinaryReader wad = new BinaryReader(File.OpenRead(wadFile))) { return(ThpsWad.FromReader(hed, wad)); } } }
public static ThpsWad FromFolder(string path) { if (!Directory.Exists(path)) { throw new Exception($"Not found: {path}"); } string[] lines = Directory.GetFiles(path); ThpsWad wad = new ThpsWad(); foreach (string s in lines) { if (s != "") { ThpsWadEntry en = new ThpsWadEntry(s); wad.Entries.Add(en); } } wad.RecalcOffsets(); return(wad); }
/// <summary> /// Static method to create ThpsWad object from a given filename for either HED or WAD. Extensions are added automatically. /// </summary> /// <param name="file">Path to file.</param> /// <returns>ThpsWad object.</returns> public static ThpsWad FromFile(string file) { return(ThpsWad.FromFile(Path.ChangeExtension(file, ".hed"), Path.ChangeExtension(file, ".wad"))); }