Exemple #1
0
        private void DoStuff()
        {
            Predicate <string> adder = t => !t.EndsWith("backup") && !t.EndsWith(".tfc") && !t.EndsWith(".sfar");

            ProgressUpdater.ChangeProgressBar(0, MainListView.Items.Count);
            for (int i = 0; i < MainListView.Items.Count; i++)
            {
                if (cts.IsCancellationRequested)
                {
                    DebugOutput.PrintLn("Extraction cancelled!");
                    return;
                }
                bool ischecked = false;
                this.Invoke(new Action(() => ischecked = MainListView.GetItemChecked(i)));
                if (ischecked)
                {
                    DLCInfo dlc = DLCs[i];
                    if (dlc.isBaseGame == false)
                    {
                        if (dlc.isBackupPresent && dlc.UseExtracted == false)
                        {
                            // KFreon: Delete extracted and restore from backup
                            StatusUpdater.UpdateText("Deleting old files and restoring backup for: " + dlc.Name);
                            File.Delete(dlc.sfar);
                            dlc.ExtractedFiles.ForEach(t => File.Delete(t));
                            File.Copy(dlc.BackupFileName, dlc.sfar);
                        }
                        else if (dlc.BackupRequested == true)
                        {
                            // KFreon: Backup sfar
                            StatusUpdater.UpdateText("Backing up: " + dlc.Name);
                            File.Copy(dlc.sfar, Path.ChangeExtension(dlc.sfar, ".backup"));
                        }
                        else if (dlc.UseExtracted == true)
                        {
                            FilesToAddToTree.AddRange(dlc.Files.Where(a => adder(a)));
                            ProgressUpdater.IncrementBar();
                            continue;
                        }

                        // KFreon: Extract
                        StatusUpdater.UpdateText("Extracting DLC: " + dlc.Name);

                        if (File.Exists(dlc.sfar))
                        {
                            DLCExtractHelper(dlc.sfar);
                            dlc.GetFiles();
                        }
                        else
                        {
                            DebugOutput.PrintLn("DLC: " + dlc.sfar + "  failed.");
                        }
                    }
                    FilesToAddToTree.AddRange(dlc.Files.Where(a => adder(a)));
                }
                ProgressUpdater.IncrementBar();
            }
        }