Пример #1
0
        public List <TOCBinFile.Entry> UpdateTOCbin(bool Rebuild = false)
        {
            DebugOutput.PrintLn("File opened\nSearching TOCbin...");
            int f = -1;

            for (int i = 0; i < Files.Length; i++)
            {
                if (Files[i].FileName.Contains("PCConsoleTOC.bin"))
                {
                    f = i;
                }
            }
            if (f == -1)
            {
                DebugOutput.PrintLn("Couldnt Find PCConsoleTOC.bin");
                return(null);
            }
            int IndexTOC = f;

            DebugOutput.PrintLn("Found PCConsoleTOC.bin(" + f + ")!\nLoading Entries...");
            TOCBinFile TOC = new TOCBinFile(new MemoryStream(DecompressEntry(f).ToArray()));

            DebugOutput.PrintLn("Checking Entries...");
            int count = 0;

            if (TOC.Entries == null)
            {
                DebugOutput.PrintLn("No TOC entries found. Oh dear...");
            }
            for (int i = 0; i < TOC.Entries.Count; i++)
            {
                TOCBinFile.Entry e = TOC.Entries[i];
                f = -1;
                for (int j = 0; j < Files.Length; j++)
                {
                    if (Files[j].FileName.Replace('/', '\\').Contains(e.name))
                    {
                        f = j;
                    }
                }

                ////////////////////////////// KFREON TEMPORARY STUFF WV :)
                if (f == -1)
                {
                    List <string> parts = new List <string>(this.MyFileName.Split('\\'));
                    parts.RemoveAt(parts.Count - 1);
                    parts.RemoveAt(parts.Count - 1);
                    string path = String.Join("\\", parts) + "\\" + e.name;
                    if (File.Exists(path))
                    {
                        FileInfo fi = new FileInfo(path);
                        if (fi.Length == e.size)
                        {
                            DebugOutput.PrintLn((count++) + " : Entry is correct " + e.name);
                        }
                        else
                        {
                            e.size = (int)fi.Length;
                            DebugOutput.PrintLn((count++) + " : Entry will be updated " + e.name);
                            TOC.Entries[i] = e;
                        }
                    }
                    else
                    {
                        DebugOutput.PrintLn((count++) + " : Entry not found " + e.name);
                    }
                }  /////////////////////////////// END KFREON BLATHER
                else
                {
                    if (Files[f].UncompressedSize == e.size)
                    {
                        DebugOutput.PrintLn((count++) + " : Entry is correct " + e.name);
                    }
                    else if (Files[f].UncompressedSize != e.size)
                    {
                        e.size = (int)Files[f].UncompressedSize;
                        DebugOutput.PrintLn((count++) + " : Entry will be updated " + e.name);
                        TOC.Entries[i] = e;
                    }
                }
            }
            DebugOutput.PrintLn("Replacing TOC back...");
            ReplaceEntry(TOC.Save().ToArray(), IndexTOC);
            if (Rebuild)
            {
                DebugOutput.PrintLn("Reopening SFAR...");
                Load(MyFileName);
                DebugOutput.PrintLn("Rebuild...");
                ReBuild();
            }
            return(TOC.Entries);
        }
Пример #2
0
        public List <TOCBinFile.Entry> UpdateTOCbin(bool Rebuild = false)
        {
            int f = -1;

            for (int i = 0; i < Files.Length; i++)
            {
                if (Files[i].FileName.Contains("PCConsoleTOC.bin"))
                {
                    f = i;
                }
            }
            if (f == -1)
            {
                return(null);
            }
            int        IndexTOC = f;
            TOCBinFile TOC      = new TOCBinFile(new MemoryStream(DecompressEntry(f).ToArray()));
            int        count    = 0;

            //if (TOC.Entries == null)
            //    DebugOutput.PrintLn("No TOC entries found. Oh dear...");
            for (int i = 0; i < TOC.Entries.Count; i++)
            {
                TOCBinFile.Entry e = TOC.Entries[i];
                f = -1;
                for (int j = 0; j < Files.Length; j++)
                {
                    if (Files[j].FileName.Replace('/', '\\').Contains(e.name))
                    {
                        f = j;
                    }
                }

                if (f == -1)
                {
                    List <string> parts = new List <string>(this.FileName.Split('\\'));
                    parts.RemoveAt(parts.Count - 1);
                    parts.RemoveAt(parts.Count - 1);
                    string path = string.Join("\\", parts) + "\\" + e.name;
                    if (File.Exists(path))
                    {
                        FileInfo fi = new FileInfo(path);
                        if (fi.Length != e.size)

                        {
                            e.size         = (int)fi.Length;
                            TOC.Entries[i] = e;
                        }
                    }
                    //else
                    //    DebugOutput.PrintLn((count++) + " : Entry not found " + e.name);
                }
                else
                {
                    if (Files[f].UncompressedSize != e.size)
                    {
                        e.size         = (int)Files[f].UncompressedSize;
                        TOC.Entries[i] = e;
                    }
                }
            }
            ReplaceEntry(TOC.Save().ToArray(), IndexTOC);
            if (Rebuild)
            {
                Load(FileName);
                ReBuild();
            }
            return(TOC.Entries);
        }