Example #1
0
        public void UpdateTOCbin(bool Rebuild = false)
        {
            //DebugLog.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)
            {
                //DebugLog.PrintLn("Couldnt Find PCConsoleTOC.bin");
                return;
            }
            int IndexTOC = f;
            //DebugLog.PrintLn("Found PCConsoleTOC.bin(" + f + ")!\nLoading Entries...");
            TOCBinFile TOC = new TOCBinFile(new MemoryStream(DecompressEntry(f).ToArray()));
            //DebugLog.PrintLn("Checking Entries...");
            int count = 0;

            if (TOC.Entries == null)
            {
                //DebugLog.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)
                        {
                            //DebugLog.PrintLn((count++) + " : Entry is correct " + e.name);
                        }
                        else
                        {
                            e.size = (int)fi.Length;
                            //DebugLog.PrintLn((count++) + " : Entry will be updated " + e.name);
                            TOC.Entries[i] = e;
                        }
                    }
                    else
                    {
                        //DebugLog.PrintLn((count++) + " : Entry not found " + e.name);
                    }
                }  /////////////////////////////// END KFREON BLATHER
                else
                {
                    if (Files[f].UncompressedSize == e.size)
                    {
                        //DebugLog.PrintLn((count++) + " : Entry is correct " + e.name);
                    }
                    else if (Files[f].UncompressedSize != e.size)
                    {
                        e.size = (int)Files[f].UncompressedSize;
                        //DebugLog.PrintLn((count++) + " : Entry will be updated " + e.name);
                        TOC.Entries[i] = e;
                    }
                }
            }
            //DebugLog.PrintLn("Replacing TOC back...");
            ReplaceEntry(TOC.Save().ToArray(), IndexTOC);
            if (Rebuild)
            {
                //DebugLog.PrintLn("Reopening SFAR...");
                Load(MyFileName);
                //DebugLog.PrintLn("Rebuild...");
                ReBuild();
            }
        }
Example #2
0
        public void UpdateTOCbin(bool Rebuild = false)
        {
            DebugLog.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)
            {
                DebugLog.PrintLn("Couldnt Find PCConsoleTOC.bin");
                return;
            }
            int IndexTOC = f;
            DebugLog.PrintLn("Found PCConsoleTOC.bin(" + f + ")!\nLoading Entries...");
            TOCBinFile TOC = new TOCBinFile(new MemoryStream(DecompressEntry(f).ToArray()));
            DebugLog.PrintLn("Checking Entries...");
            int count = 0;
            if (TOC.Entries == null)
                DebugLog.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)
                            DebugLog.PrintLn((count++) + " : Entry is correct " + e.name);
                        else
                        {
                            e.size = (int)fi.Length;
                            DebugLog.PrintLn((count++) + " : Entry will be updated " + e.name);
                            TOC.Entries[i] = e;
                        }
                    }
                    else
                        DebugLog.PrintLn((count++) + " : Entry not found " + e.name);
                }  /////////////////////////////// END KFREON BLATHER
                else
                {
                    if (Files[f].UncompressedSize == e.size)
                        DebugLog.PrintLn((count++) + " : Entry is correct " + e.name);
                    else if (Files[f].UncompressedSize != e.size)
                    {
                        e.size = (int)Files[f].UncompressedSize;
                        DebugLog.PrintLn((count++) + " : Entry will be updated " + e.name);
                        TOC.Entries[i] = e;
                    }
                }
            }
            DebugLog.PrintLn("Replacing TOC back...");
            ReplaceEntry(TOC.Save().ToArray(), IndexTOC);
            if (Rebuild)
            {
                DebugLog.PrintLn("Reopening SFAR...");
                Load(MyFileName);
                DebugLog.PrintLn("Rebuild...");
                ReBuild();
            }
        }