public void LoadLevel(string name) { LastLoadName = name; dlf = new DLF_IO(); using (FileStream fs = new FileStream(ArxPaths.GetDlfPath(name), FileMode.Open, FileAccess.Read)) { dlf.LoadFrom(DLF_IO.EnsureUnpacked(fs)); } llf = new LLF_IO(); using (FileStream fs = new FileStream(ArxPaths.GetLlfPath(name), FileMode.Open, FileAccess.Read)) { llf.LoadFrom(LLF_IO.EnsureUnpacked(fs)); } fts = new FTS_IO(); using (FileStream fs = new FileStream(ArxPaths.GetFtsPath(name), FileMode.Open, FileAccess.Read)) { fts.LoadFrom(FTS_IO.EnsureUnpacked(fs)); } }
public void TestIOReadWrite() { DirectoryInfo ftsDir = new DirectoryInfo(@"F:\Program Files\Arx Libertatis\paks\game\graph\levels"); DirectoryInfo dlfLlfDir = new DirectoryInfo(@"F:\Program Files\Arx Libertatis\paks\graph\levels"); string name = levelName.text; var dlf = Path.Combine(dlfLlfDir.FullName, name, name + ".dlf"); var llf = Path.Combine(dlfLlfDir.FullName, name, name + ".llf"); var fts = Path.Combine(ftsDir.FullName, name, "fast.fts"); //DEBUG: use unpacked versions of files for now dlf += ".unpacked"; llf += ".unpacked"; fts += ".unpacked"; var DLF = new DLF_IO(); byte[] dlfBytesIn; using (FileStream fs = new FileStream(dlf, FileMode.Open, FileAccess.Read)) { dlfBytesIn = new byte[fs.Length]; fs.Read(dlfBytesIn, 0, dlfBytesIn.Length); fs.Position = 0; DLF.LoadFrom(fs); } MemoryStream dlfOut = new MemoryStream(); DLF.WriteTo(dlfOut); byte[] dlfBytesOut = dlfOut.ToArray(); using (FileStream fs = new FileStream(dlf + ".out", FileMode.Create, FileAccess.Write)) { dlfOut.Position = 0; dlfOut.CopyTo(fs); } var LLF = new LLF_IO(); byte[] llfBytesIn; using (FileStream fs = new FileStream(llf, FileMode.Open, FileAccess.Read)) { llfBytesIn = new byte[fs.Length]; fs.Read(llfBytesIn, 0, llfBytesIn.Length); fs.Position = 0; LLF.LoadFrom(fs); } MemoryStream llfOut = new MemoryStream(); LLF.WriteTo(llfOut); byte[] llfBytesOut = llfOut.ToArray(); var FTS = new FTS_IO(); byte[] ftsBytesIn; using (FileStream fs = new FileStream(fts, FileMode.Open, FileAccess.Read)) { ftsBytesIn = new byte[fs.Length]; fs.Read(ftsBytesIn, 0, ftsBytesIn.Length); fs.Position = 0; FTS.LoadFrom(fs); } MemoryStream ftsOut = new MemoryStream(); FTS.WriteTo(ftsOut); byte[] ftsBytesOut = ftsOut.ToArray(); using (FileStream fs = new FileStream(fts + ".out", FileMode.Create, FileAccess.Write)) { ftsOut.Position = 0; ftsOut.CopyTo(fs); } //compare results compare("dlf", dlfBytesIn, dlfBytesOut); compare("llf", llfBytesIn, llfBytesOut); compare("fts", ftsBytesIn, ftsBytesOut); }