static public void unpackAllDLC(string GamePath, bool ipc = false) { string DLCDir = Path.Combine(GamePath, "BIOGame", "DLC"); if (!Directory.Exists(DLCDir)) { return; } List <string> sfarFiles = Directory.GetFiles(DLCDir, "Default.sfar", SearchOption.AllDirectories).ToList(); int totalSfars = sfarFiles.Count; for (int i = 0; i < sfarFiles.Count; i++) { if (File.Exists(Path.Combine(Path.GetDirectoryName(sfarFiles[i]), "Mount.dlc"))) { sfarFiles.RemoveAt(i--); } } if (sfarFiles.Count() == 0) { return; } if (ipc) { Console.WriteLine("[IPC]STAGE_WEIGHT STAGE_UNPACKDLC " + string.Format("{0:0.000000}", ((float)sfarFiles.Count / totalSfars))); Console.Out.Flush(); } int totalNumFiles = 0; int currentProgress = 0; for (int i = 0; i < sfarFiles.Count; i++) { string DLCname = Path.GetFileName(Path.GetDirectoryName(Path.GetDirectoryName(sfarFiles[i]))); totalNumFiles += getNumberOfFiles(sfarFiles[i]); } for (int i = 0; i < sfarFiles.Count; i++) { string DLCname = Path.GetFileName(Path.GetDirectoryName(Path.GetDirectoryName(sfarFiles[i]))); string outPath = Path.Combine(DLCDir, DLCname); SFAR dlc = new SFAR(); if (ipc) { Console.WriteLine("[IPC]PROCESSING_FILE " + sfarFiles[i]); Console.Out.Flush(); } dlc.extract(sfarFiles[i], outPath, ipc, ref currentProgress, totalNumFiles); } }
static void Main(string[] args) { var options = new Options(); if (CommandLine.Parser.Default.ParseArguments(args, options)) { if (options.SFARPath == null && options.GamePath == null) { Console.WriteLine("This program requires --gamepath or --sfarpath, or both depending on the chosen options."); EndProgram(1); } if (options.SFARPath != null) { //We're extracting a single SFAR //Validation... if (options.ExtractEntireArchive && options.ExtractList != null && options.ExtractList.Length > 0) { Console.WriteLine("Ambiguous input: --extractfilenames and --gamepath were both specified. You can only use one."); EndProgram(1); } if ((!options.ExtractEntireArchive && options.ExtractList == null) || (options.ExtractList != null && options.ExtractList.Length == 0)) { Console.WriteLine("No extraction operation was specified. Use --ExtractEntireArchive or a list following --ExtractFilenames."); EndProgram(1); } if (options.ExtractEntireArchive && options.ExtractList != null && options.ExtractList.Length > 0) { Console.WriteLine("Ambiguous input: --ExtractEntireArchive and --ExtractFilenames were both specified. You can only use one of these options."); EndProgram(1); } if (!File.Exists(options.SFARPath)) { Console.WriteLine("Specified SFAR file doesn't exist: " + options.SFARPath); EndProgram(1); } SFAR sfar = new SFAR(); Console.WriteLine("OutputPath: " + options.OutputPath); if (options.ExtractList != null && options.ExtractList.Length > 0) { //Extract a list of files sfar.extractfiles(options.SFARPath, options.OutputPath, options.ExtractList, true); } else { //extract the whole archive int numFiles = SFAR.getNumberOfFiles(options.SFARPath); int currentProgress = 0; Console.WriteLine("Extracting archive: " + options.SFARPath + "... " + numFiles + " files"); sfar.extract(options.SFARPath, options.OutputPath, false, ref currentProgress, numFiles, true, options.KeepArchiveIntact); } } else if (options.GamePath != null) { Console.WriteLine("Extracting all DLC from game directory: " + options.GamePath); SFAR.unpackAllDLC(options.GamePath); EndProgram(0); } // Values are available here // if (options.Verbose) Console.WriteLine("Filename: {0}", options.InputFile); } EndProgram(0); }