static public void unpackAllDLC(bool ipc)
        {
            if (!Directory.Exists(GameData.DLCData))
            {
                return;
            }

            List <string> sfarFiles  = Directory.GetFiles(GameData.DLCData, "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(GameData.DLCData, DLCname);
                ME3DLC dlc     = new ME3DLC();
                if (ipc)
                {
                    Console.WriteLine("[IPC]PROCESSING_FILE " + sfarFiles[i]);
                    Console.Out.Flush();
                }
                dlc.extract(sfarFiles[i], outPath, ipc, ref currentProgress, totalNumFiles);
            }
        }
Beispiel #2
0
        static public void unpackAllDLC(MainWindow mainWindow, Installer installer)
        {
            if (!Directory.Exists(GameData.DLCData))
            {
                if (mainWindow != null)
                {
                    MessageBox.Show("No DLCs need to be extracted.");
                }
                return;
            }

            List <string> sfarFiles = Directory.GetFiles(GameData.DLCData, "Default.sfar", SearchOption.AllDirectories).ToList();

            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)
            {
                if (mainWindow != null)
                {
                    MessageBox.Show("No DLCs need to be extracted.");
                }
                return;
            }

            long diskFreeSpace = Misc.getDiskFreeSpace(GameData.GamePath);
            long diskUsage     = 0;

            for (int i = 0; i < sfarFiles.Count; i++)
            {
                diskUsage += new FileInfo(sfarFiles[i]).Length;
            }
            diskUsage = (long)(diskUsage * 2.5);
            if (diskUsage > diskFreeSpace)
            {
                if (mainWindow != null)
                {
                    MessageBox.Show("You have not enough disk space remaining. You need about " + Misc.getBytesFormat(diskUsage) + " free.");
                }
                return;
            }

            string tmpDlcDir = Path.Combine(GameData.GamePath, "BIOGame", "DLCTemp");

            if (Directory.Exists(tmpDlcDir))
            {
                Directory.Delete(tmpDlcDir, true);
            }
            Directory.CreateDirectory(tmpDlcDir);
            string originInstallFiles = Path.Combine(GameData.DLCData, "__metadata");

            if (Directory.Exists(originInstallFiles))
            {
                Directory.Move(originInstallFiles, tmpDlcDir + "\\__metadata");
            }
            for (int i = 0; i < sfarFiles.Count; i++)
            {
                string DLCname = Path.GetFileName(Path.GetDirectoryName(Path.GetDirectoryName(sfarFiles[i])));
                string outPath = Path.Combine(tmpDlcDir, DLCname);
                Directory.CreateDirectory(outPath);
                ME3DLC dlc = new ME3DLC(mainWindow);
                if (mainWindow != null)
                {
                    mainWindow.updateStatusLabel("SFAR extracting - DLC " + (i + 1) + " of " + sfarFiles.Count);
                }
                if (installer != null)
                {
                    installer.updateStatusPrepare("Extracting DLC ... " + (i + 1) + " of " + sfarFiles.Count);
                }
                dlc.extract(sfarFiles[i], outPath);
            }

            sfarFiles = Directory.GetFiles(GameData.DLCData, "Default.sfar", SearchOption.AllDirectories).ToList();
            for (int i = 0; i < sfarFiles.Count; i++)
            {
                if (File.Exists(Path.Combine(Path.GetDirectoryName(sfarFiles[i]), "Mount.dlc")))
                {
                    string source = Path.GetDirectoryName(Path.GetDirectoryName(sfarFiles[i]));
                    Directory.Move(source, tmpDlcDir + "\\" + Path.GetFileName(source));
                }
            }

            Directory.Delete(GameData.DLCData, true);
            Directory.Move(tmpDlcDir, GameData.DLCData);
        }
Beispiel #3
0
        static public void unpackAllDLC(MainWindow mainWindow, Installer installer, bool ipc)
        {
            if (!Directory.Exists(GameData.DLCData))
            {
                if (mainWindow != null)
                {
                    MessageBox.Show("No DLCs need to be extracted.");
                }
                return;
            }

            List <string> sfarFiles  = Directory.GetFiles(GameData.DLCData, "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)
            {
                if (mainWindow != null)
                {
                    MessageBox.Show("No DLCs need to be extracted.");
                }
                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]);
            }

            if (mainWindow != null)
            {
                long diskFreeSpace = Misc.getDiskFreeSpace(GameData.GamePath);
                long diskUsage     = 0;
                for (int i = 0; i < sfarFiles.Count; i++)
                {
                    diskUsage += new FileInfo(sfarFiles[i]).Length;
                }
                diskUsage = (long)(diskUsage * 2.5);
                if (diskUsage > diskFreeSpace)
                {
                    if (mainWindow != null)
                    {
                        MessageBox.Show("You have not enough disk space remaining. You need about " + Misc.getBytesFormat(diskUsage) + " free.");
                    }
                }
            }

            for (int i = 0; i < sfarFiles.Count; i++)
            {
                string DLCname = Path.GetFileName(Path.GetDirectoryName(Path.GetDirectoryName(sfarFiles[i])));
                string outPath = Path.Combine(GameData.DLCData, DLCname);
                ME3DLC dlc     = new ME3DLC(mainWindow, installer);
                if (mainWindow != null)
                {
                    mainWindow.updateStatusLabel("SFAR extracting - DLC " + (i + 1) + " of " + sfarFiles.Count);
                }
                if (ipc)
                {
                    Console.WriteLine("[IPC]PROCESSING_FILE " + sfarFiles[i]);
                    Console.Out.Flush();
                }
                dlc.extract(sfarFiles[i], outPath, ipc, ref currentProgress, totalNumFiles);
            }
        }