ME3Explorer.Unreal.DLCPackage.DeleteEntries C# (CSharp) Method

DeleteEntries() public method

public DeleteEntries ( List Index ) : void
Index List
return void
        public void DeleteEntries(List<int> Index)
        {
            try
            {
                Index.Sort();
                Index.Reverse();
                FileStream fs = new FileStream(FileName, FileMode.Open, FileAccess.Read);
                DebugOutput.PrintLn("Searching TOC...");
                int f = FindTOC();
                if (f == -1)
                    return;
                DebugOutput.PrintLn("Found TOC, deleting lines...");
                MemoryStream m = DecompressEntry(f, fs);
                string toc = Encoding.UTF8.GetString(m.ToArray(), 0, (int)m.Length);
                fs.Close();
                for (int i = 0; i < Index.Count; i++)
                {
                    FileEntryStruct e = Files[Index[i]];
                    string file = e.FileName + "\r\n";
                    toc = toc.Replace(file, "");
                }
                DebugOutput.PrintLn("Replacing TOC...");
                ReplaceEntry(Encoding.ASCII.GetBytes(toc), f);
                DebugOutput.PrintLn("Deleting Entry from Filelist...");
                List<FileEntryStruct> l = new List<FileEntryStruct>();
                l.AddRange(Files);
                for (int i = 0; i < Index.Count; i++)
                {
                    l.RemoveAt(Index[i]);
                    Header.FileCount--;
                }
                Files = l.ToArray();
                DebugOutput.PrintLn("Rebuilding...");
                ReBuild();
                DebugOutput.PrintLn("Done.");
            }
            catch (Exception ex)
            {
                DebugOutput.PrintLn("ERROR\n" + ex.Message);
            }
        }

Usage Example

示例#1
0
        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.");
        }