DecompressEntry() public method

public DecompressEntry ( int Index ) : MemoryStream
Index int
return System.IO.MemoryStream
コード例 #1
0
ファイル: SubtitleScanner.cs プロジェクト: Dybuk/ME3Explorer
 public void ScanDLCfolder2()
 {
     DebugOutput.PrintLn("\n\nDLC Scan for packed files...\n", true);
     string dir = ME3Directory.DLCPath;
     string[] files = Directory.GetFiles(dir, "*.sfar", SearchOption.AllDirectories);
     if (files.Length == 0)
         return;
     pbar1.Maximum = files.Length - 1;
     int count = 0;
     foreach (string file in files)
         if (!file.ToLower().Contains("patch"))
         {
             DebugOutput.PrintLn("Scan file #" + count + " : " + file, count % 10 == 0);
             try
             {
                 DLCPackage dlc = new DLCPackage(file);
                 DebugOutput.PrintLn("found " + dlc.Files.Length + " files : " + file);
                 for (int j = 0; j < dlc.Files.Length; j++)
                 {
                     if (dlc.Files[j].FileName.ToLower().EndsWith(".pcc"))
                     {
                         string filename = dlc.Files[j].FileName;
                         DebugOutput.PrintLn(" " + j.ToString("d4") + " / " + dlc.Files.Length.ToString("d4") + " : opening " + Path.GetFileName(filename),true);
                         MemoryStream mem = dlc.DecompressEntry(j);
                         File.WriteAllBytes("temp.pcc", mem.ToArray());
                         PCCObject pcc = new PCCObject("temp.pcc");
                         for (int i = 0; i < pcc.Exports.Count; i++)
                             if (pcc.Exports[i].ClassName == "BioConversation")
                             {
                                 DebugOutput.PrintLn("Found dialog \"" + pcc.Exports[i].ObjectName + "\"", false);
                                 BioConversation Dialog = new BioConversation(pcc, i);
                                 foreach (BioConversation.EntryListStuct e in Dialog.EntryList)
                                 {
                                     string text = talkFile.findDataById(e.refText);
                                     if (text.Length != 7 && text != "No Data")
                                     {
                                         EntryStruct t = new EntryStruct();
                                         t.inDLC = true;
                                         t.text = text;
                                         t.ID = e.refText;
                                         t.indexpcc = i;
                                         t.pathafc = "";//Todo
                                         t.pathdlc = file;
                                         t.pathpcc = filename;
                                         t.convname = pcc.Exports[i].ObjectName;
                                         if (e.SpeakerIndex >= 0 && e.SpeakerIndex < Dialog.SpeakerList.Count)
                                             t.speaker = pcc.getNameEntry(Dialog.SpeakerList[e.SpeakerIndex]);
                                         else
                                             t.speaker = "unknown";
                                         if (t.speaker == null || t.speaker == "")
                                             t.speaker = "unknown";
                                         Entries.Add(t);
                                         DebugOutput.PrintLn("Requ.: (" + t.speaker + ") " + t.text, false);
                                     }
                                 }
                                 foreach (BioConversation.ReplyListStruct e in Dialog.ReplyList)
                                 {
                                     string text = talkFile.findDataById(e.refText);
                                     if (text.Length != 7 && text != "No Data")
                                     {
                                         EntryStruct t = new EntryStruct();
                                         t.inDLC = true;
                                         t.text = text;
                                         t.ID = e.refText;
                                         t.indexpcc = i;
                                         t.pathafc = "";//Todo
                                         t.pathdlc = file;
                                         t.pathpcc = filename;
                                         t.convname = pcc.Exports[i].ObjectName;
                                         Entries.Add(t);
                                         DebugOutput.PrintLn("Reply: " + t.text, false);
                                     }
                                 }
                             }
                     }
                 }
                 if (count % 10 == 0)
                 {
                     Application.DoEvents();
                     pbar1.Value = count;
                 }
                 count++;
             }
             catch (Exception ex)
             {
                 DebugOutput.PrintLn("=====ERROR=====\n" + ex.ToString() + "\n=====ERROR=====");
             }
         }
     if (File.Exists("temp.pcc"))
         File.Delete("temp.pcc");
 }
コード例 #2
0
ファイル: DLCEditor2.cs プロジェクト: Dybuk/ME3Explorer
        private void unpackSFAR(DLCPackage DLC)
        {
            AutoTOC.AutoTOC toc = new AutoTOC.AutoTOC();
            if (DLC == null || DLC.Files == null)
                return;
            string result = "pcc; tfc; afc; cnd; tlk; bin; bik; dlc";
            if (result == "")
                return;
            result = result.Trim();
            if (result.EndsWith(";"))
                result = result.Substring(0, result.Length - 1);
            string[] patt = result.Split(';');
            string file = DLC.MyFileName;                   //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.DecompressEntry(i).WriteTo(fs);
                            Indexes.Add(i);
                            Application.DoEvents();
                            break;
                        }
                }
                DLC.DeleteEntry(Indexes);
            }

            // AutoTOC
            DebugOutput.PrintLn("Updating DLC's PCConsoleTOC.bin");
            List<string> FileNames = toc.GetFiles(t2 + "\\");
            List<string> tet = new List<string>(t2.Split('\\'));
            string remov = String.Join("\\", tet.ToArray());
            for (int i = 0; i < FileNames.Count; i++)
                FileNames[i] = FileNames[i].Substring(remov.Length + 1);
            string[] ts = t2.Split('\\');
            tet.Clear();
            tet.AddRange(ts);
            string basepath = String.Join("\\", tet.ToArray()) + '\\';
            string tocfile = t2 + "\\PCConsoleTOC.bin";
            toc.CreateTOC(basepath, tocfile, FileNames.ToArray());
            DebugOutput.PrintLn("DLC Done.");
        }
コード例 #3
0
        public static List<string> DLCExtractHelper(string file)
        {
            // KFreon: Ditching this stuff for Fobs ExtractAllDLC function in Texplorer2.cs
            // NOTE that the files are normally collected here, now done in Texplorer2.cs
            return new List<string>();




            List<string> ExtractedFiles = new List<string>();
            string[] dlcname = file.Split('\\');
            DebugOutput.PrintLn("Temp extracting DLC: " + dlcname[dlcname.Length - 3]);
            DLCPackage dlc = new DLCPackage(file);
            List<string> dlcpath = new List<string>(dlc.MyFileName.Split('\\'));
            dlcpath.RemoveRange(dlcpath.Count - 5, 5);
            string dlcExtractionPath = String.Join("\\", dlcpath.ToArray());

            List<int> Indicies = new List<int>();
            for (int i = 0; i < dlc.Files.Count(); i++)
            {
                DLCPackage.FileEntryStruct entry = dlc.Files[i];
                if (Path.GetExtension(entry.FileName).ToLower() == ".pcc" || Path.GetExtension(entry.FileName).ToLower() == ".tfc")
                {
                    DebugOutput.PrintLn("Extracting: " + dlc.Files[i].FileName);
                    try
                    {
                        Directory.CreateDirectory(Path.GetDirectoryName(dlcExtractionPath + dlc.Files[i].FileName));
                        using (FileStream fs = new FileStream(dlcExtractionPath + dlc.Files[i].FileName, FileMode.CreateNew))
                            dlc.DecompressEntry(i).WriteTo(fs);

                        Indicies.Add(i);
                    }
                    catch (Exception e)
                    {
                        DebugOutput.PrintLn("File " + dlcExtractionPath + entry.FileName + " already exists.  Extra: " + e.Message);
                        Console.WriteLine(e.Message);
                    }
                    ExtractedFiles.Add(dlcExtractionPath + entry.FileName);
                }
            }
            dlc.DeleteEntry(Indicies);
            return ExtractedFiles;
        }