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.");
}