public static void Load(WadFile wad, string path) { if (!File.Exists(path)) { throw new FileNotFoundException("Wad file was not found."); } using (var stream = File.Open(path, FileMode.Open, FileAccess.Read, FileShare.Read)) { Load(wad, stream); } }
public static bool Save(WadFile wad, string path, WadVersion version) { if (File.Exists(path)) { return(false); } using (var stream = File.Open(path, FileMode.CreateNew, FileAccess.Write, FileShare.None)) { Save(wad, stream, version); return(true); } }
public static void Save(WadFile wad, Stream stream, WadVersion version) { switch (version) { // Wad2 (Quake I) case WadVersion.Wad2: { Wad2.Wad.Save(wad, stream); return; } // Wad3 (GoldSource) case WadVersion.Wad3: { Wad3.Wad.Save(wad, stream); return; } } throw new WadVersionNotSupportedException((uint)version); }
public static void Load(WadFile wad, Stream stream) { if (stream == null) { throw new ArgumentNullException("stream"); } var reader = new BinaryReader(stream); var startPos = reader.BaseStream.Position; //4 bytes = 1 int uint version = reader.ReadUInt32(); reader.BaseStream.Position = startPos; switch (version) { // Wad2 (Quake I) case (uint)WadVersion.Wad2: { Wad2.Wad.Load(wad, stream); Debug.Log("Loaded Wad2 file"); } break; // Wad3 (GoldSource) case (uint)WadVersion.Wad3: { Wad3.Wad.Load(wad, stream); Debug.Log("Loaded Wad3 file"); } break; default: //throw new WadVersionNotSupportedException(version); break; } }