void TestDecompression() { // Test expanding files by index Console.WriteLine("Testing file expansion by TOC index"); for (int i = 0; i < pSarc.TOC.Count - 1; i++) { WriteFile(pSarc.DecompressFile(i)); } Console.Write("Press any key to continue ..."); Console.ReadKey(); // Test expanding files by name Console.WriteLine("Testing file expansion by file name"); for (int i = 0; i < pSarc.TOC.Count - 1; i++) { WriteFile(pSarc.DecompressFile(pSarc.TOC[i].FileName)); } Console.Write("Press any key to continue ..."); Console.ReadKey(); // Test expanding by foreach Console.WriteLine("Testing file expansion using foreach on TOC"); foreach (TOCEntry tocEntry in pSarc.TOC) { WriteFile(pSarc.DecompressFile(tocEntry.FileName)); } Console.Write("Press any key to continue ..."); Console.ReadKey(); }
/// <summary> /// Decompress a .Pak file /// </summary> /// <param name="p_strFileName">The file's name</param> private void DecompressPAKFile(string p_strFileName) { //Throw exection if the file isn't a .pak if (!p_strFileName.Contains(".pak")) { throw new Exception(string.Format("The file {0} isn't a .pak file", p_strFileName)); } using (PSARC psaDecompresser = new PSARC(p_strFileName)) { psaDecompresser.ReadManifest(); if (psaDecompresser.TOC.Count != psaDecompresser.m_hdrPSHeader.TocEntries) { throw new Exception("TOC Count does not meet expected value"); } foreach (TOCEntry tocEntry in psaDecompresser.TOC) { //Skip the manifest files if (tocEntry.FileName.Contains("manifest")) { continue; } WriteFile(psaDecompresser.DecompressFile(tocEntry.FileName)); } } Console.WriteLine(string.Format(" Files: {0} is successfully uncompress", p_strFileName)); }
public void LoadMBINsFromPak(string pakPath) { var pak = new PSARC(pakPath); _paks.Add(pak); foreach (var entry in pak.TOC) { if (Path.GetExtension(entry.FileName)?.ToLower() == ".mbin") { _lazyMBINs[entry.FileName] = delegate { var decompressed = pak.DecompressFile(entry.FileName); var stream = new MemoryStream(decompressed.BinaryFile); return(new MBINMemory { mbin = new MBINFile(stream), mem = stream }); } } ; } }