public static void Repack(string inputFolder, string outputPath, bool useCompression) { var unpackedParFolders = Directory.GetDirectories(inputFolder, "*.par.unpack", SearchOption.TopDirectoryOnly); foreach (var folder in unpackedParFolders) { var tempFile = folder.Substring(0, folder.Length - 7); Repack(folder, tempFile, useCompression); } var pacFolder = Path.Combine(inputFolder, "pac"); if (Directory.Exists(pacFolder)) { var unpackedPacFolders = Directory.GetDirectories(pacFolder, "pac_*.bin.unpack", SearchOption.TopDirectoryOnly); foreach (var folder in unpackedPacFolders) { var tempFile = folder.Substring(0, folder.Length - 7); PacFile.Repack(folder, tempFile, useCompression); } } var dir = Path.GetDirectoryName(outputPath); Directory.CreateDirectory(dir); ParFile.Pack(inputFolder, outputPath, useCompression); }
public static void Extract(string inputPath, string outputFolder) { Directory.CreateDirectory(outputFolder); var parFile = new ParFile(); parFile.ReadInfo(inputPath); if (parFile.Root != null) { parFile.Dump(inputPath, outputFolder); } var newParFiles = Directory.GetFiles(outputFolder, "*.par", SearchOption.TopDirectoryOnly); foreach (var file in newParFiles) { var newOutputPath = Path.Combine(outputFolder, $"{Path.GetFileName(file)}.unpack"); Extract(file, newOutputPath); } var pacFolder = Path.Combine(outputFolder, "pac"); if (Directory.Exists(pacFolder)) { var newPacFiles = Directory.GetFiles(pacFolder, "pac_*.bin", SearchOption.TopDirectoryOnly); foreach (var file in newPacFiles) { var newOutputPath = Path.Combine(pacFolder, $"{Path.GetFileName(file)}.unpack"); PacFile.Extract(file, newOutputPath); } } }