public static void unpackSFAR(DLCPackage dlc) { if (dlc == null || dlc.Files == null) { return; } string[] patt = { "pcc", "bik", "tfc", "afc", "cnd", "tlk", "bin", "dlc" }; string file = dlc.FileName; //full path string t1 = Path.GetDirectoryName(file); //cooked string t2 = Path.GetDirectoryName(t1); //DLC_Name string t3 = Path.GetDirectoryName(t2); //DLC string t4 = Path.GetDirectoryName(t3); //BioGame string gamebase = Path.GetDirectoryName(t4); //Mass Effect3 DebugOutput.PrintLn("Extracting DLC with gamebase : " + gamebase); DebugOutput.PrintLn("DLC name : " + t2); if (dlc.Files.Length > 1) { List <int> Indexes = new List <int>(); for (int i = 0; i < dlc.Files.Length; i++) { string DLCpath = dlc.Files[i].FileName; for (int j = 0; j < patt.Length; j++) { if (DLCpath.ToLower().EndsWith(patt[j].Trim().ToLower()) && patt[j].Trim().ToLower() != "") { string relPath = GetRelativePath(DLCpath); string outpath = gamebase + relPath; DebugOutput.PrintLn("Extracting file #" + i.ToString("d4") + ": " + outpath); if (!Directory.Exists(Path.GetDirectoryName(outpath))) { Directory.CreateDirectory(Path.GetDirectoryName(outpath)); } if (!File.Exists(outpath)) { using (FileStream fs = new FileStream(outpath, FileMode.Create)) dlc.DecompressEntryAsync(i, fs).Wait(); } Indexes.Add(i); Application.DoEvents(); break; } } } dlc.DeleteEntries(Indexes); } // AutoTOC AutoTOC.prepareToCreateTOC(t2 + "\\PCConsoleTOC.bin"); DebugOutput.PrintLn("DLC Done."); }
private void unpackSFARToolStripMenuItem_Click(object sender, EventArgs e) { if (DLC == null || DLC.Files == null) { return; } string result = "pcc; tfc; afc; cnd; tlk; bin; bik; dlc"; string unpackFolder; result = Microsoft.VisualBasic.Interaction.InputBox("Please enter pattern for unpacking, keep default to unpack everything.", "ME3 Explorer", "pcc; tfc; afc; cnd; tlk; bin; bik; dlc", 0, 0); if (result == "") { return; } DebugOutput.PrintLn("result : " + result); var dialog = new CommonOpenFileDialog(); dialog.IsFolderPicker = true; dialog.EnsurePathExists = true; dialog.Title = "Choose a folder to unpack to. Select ME3 directory to unpack to proper folder"; if (dialog.ShowDialog() == CommonFileDialogResult.Ok) { unpackFolder = dialog.FileName; } else { return; } if (!unpackFolder.EndsWith("\\")) { unpackFolder = unpackFolder + "\\"; } DebugOutput.PrintLn("Extracting DLC to : " + unpackFolder); result = result.Trim(); if (result.EndsWith(";")) { result = result.Substring(0, result.Length - 1); } string[] patt = result.Split(';'); string file = DLC.FileName; //full path string t1 = Path.GetDirectoryName(file); //cooked string t2 = Path.GetDirectoryName(t1); //DLC_Name string t3 = Path.GetDirectoryName(t2); //DLC string t4 = Path.GetDirectoryName(t3); //BioGame DebugOutput.PrintLn("DLC name : " + t2); if (DLC.Files.Length > 1) { List <int> Indexes = new List <int>(); for (int i = 0; i < DLC.Files.Length; i++) { string DLCpath = DLC.Files[i].FileName; for (int j = 0; j < patt.Length; j++) { if (DLCpath.ToLower().EndsWith(patt[j].Trim().ToLower()) && patt[j].Trim().ToLower() != "") { string relPath = GetRelativePath(DLCpath); string outpath = unpackFolder + relPath; DebugOutput.PrintLn("Extracting file #" + i.ToString("d4") + ": " + outpath); if (!Directory.Exists(Path.GetDirectoryName(outpath))) { Directory.CreateDirectory(Path.GetDirectoryName(outpath)); } using (FileStream fs = new FileStream(outpath, FileMode.Create)) DLC.DecompressEntry(i).WriteTo(fs); Indexes.Add(i); Application.DoEvents(); break; } } } DLC.DeleteEntries(Indexes); } // AutoTOC AutoTOC.prepareToCreateTOC(t2 + "\\PCConsoleTOC.bin"); MessageBox.Show("SFAR Unpacked."); }