static void PrintArchiveInfo(BA2Archive archive) { Console.WriteLine("Type: " + BA2Loader.GetArchiveType(archive)); Console.WriteLine("Signature: " + Encoding.ASCII.GetString(archive.Header.Signature)); Console.WriteLine("Total files: " + archive.TotalFiles); Console.WriteLine("Size: " + archive.Length / 1024 / 1024 + " MB"); }
public void TestGeneralTwoFiles() { var archive = BA2Loader.Load(SharedData.GetDataPath("GeneralTwoFiles.ba2")); var header = archive.Header; Assert.IsTrue(header.Signature.SequenceEqual(SharedData.ArchiveMagic)); Assert.AreEqual(1U, header.Version); Assert.IsTrue(BA2Loader.GetArchiveType(header.ArchiveType) == BA2Type.General); Assert.AreEqual(2U, header.TotalFiles); Assert.AreEqual(121UL, header.NameTableOffset); var files = archive.FileList; Assert.AreEqual(2, files.Count); Assert.AreEqual("test.txt", files[0]); Assert.AreEqual("wazzup.bin", files[1]); var folder = SharedData.CreateTempDirectory(); archive.Extract("test.txt", folder, false); var testPath = Path.Combine(folder, "test.txt"); Assert.IsTrue(File.Exists(testPath)); TestUtils.AssertExtractedTextFile(archive, archive.GetIndexFromFilename("test.txt"), "test text"); TestUtils.AssertExtractedTextFile(archive, archive.GetIndexFromFilename("wazzup.bin"), "wazzup dude bro?"); // Assert.IsTrue(File.ReadAllLines) }
public void TestGeneralArchiveType() { var archive = BA2Loader.Load(SharedData.GetDataPath("GeneralOneFile.ba2")); Assert.IsInstanceOf <BA2GeneralArchive>(archive); Assert.IsTrue(BA2Loader.GetArchiveType(archive) == BA2Type.General); }
public void TestGeneralOneFile() { var archive = BA2Loader.Load(SharedData.GetDataPath("GeneralOneFile.ba2")); var header = archive.Header; Assert.IsTrue(header.Signature.SequenceEqual(SharedData.ArchiveMagic)); Assert.AreEqual(1U, header.Version); Assert.IsTrue(BA2Loader.GetArchiveType(header.ArchiveType) == BA2Type.General); Assert.AreEqual(1U, header.TotalFiles); Assert.AreEqual(69UL, header.NameTableOffset); var files = archive.FileList; Assert.AreEqual(1, files.Count); Assert.AreEqual(true, archive.ContainsFile("test.txt")); var folder = SharedData.CreateTempDirectory(); archive.Extract("test.txt", folder, false); string path = Path.Combine(folder, "test.txt"); Assert.IsTrue(File.Exists(path)); Assert.AreEqual("test text", File.ReadAllText(path)); }