Example #1
0
 public File(int Id, string Name, FileSystem.Directory Parent)
 {
     this.FileID   = Id;
     this.FileName = Name;
     this.Parent   = Parent;
 }
Example #2
0
        public void ToFileSystem()
        {
            List <FileSystem.Directory> directoryList = new List <FileSystem.Directory>();

            directoryList.Add(new FileSystem.Directory("/", true));
            directoryList[0].DirectoryID = (ushort)61440;
            uint dirParentId = (uint)this.fnt.directoryTable[0].dirParentID;

            for (int index = 1; (long)index < (long)dirParentId; ++index)
            {
                directoryList.Add(new FileSystem.Directory((ushort)(61440 + index)));
            }
            for (int index = 1; (long)index < (long)dirParentId; ++index)
            {
                directoryList[index].Parent = directoryList[(int)this.fnt.directoryTable[index].dirParentID - 61440];
            }
            for (int index1 = 0; (long)index1 < (long)dirParentId; ++index1)
            {
                for (int index2 = 0; (long)index2 < (long)dirParentId; ++index2)
                {
                    if (directoryList[index1] == directoryList[index2].Parent)
                    {
                        directoryList[index1].SubDirectories.Add(directoryList[index2]);
                    }
                }
            }
            uint   num            = dirParentId * 8U;
            ushort dirEntryFileId = this.fnt.directoryTable[0].dirEntryFileID;

            FileSystem.Directory Parent1 = (FileSystem.Directory)null;
            foreach (EntryNameTableEntry entryNameTableEntry in this.fnt.entryNameTable)
            {
                for (int index = 1; (long)index < (long)dirParentId; ++index)
                {
                    if ((int)num == (int)this.fnt.directoryTable[index].dirEntryStart)
                    {
                        Parent1 = directoryList[index];
                        break;
                    }
                }
                switch (entryNameTableEntry)
                {
                case EntryNameTableEndOfDirectoryEntry _:
                    Parent1 = (FileSystem.Directory)null;
                    ++num;
                    break;

                case EntryNameTableFileEntry _:
                    Parent1.Files.Add(new FileSystem.File((int)dirEntryFileId++, ((EntryNameTableFileEntry)entryNameTableEntry).entryName, Parent1));
                    num += 1U + (uint)entryNameTableEntry.entryNameLength;
                    break;

                case EntryNameTableDirectoryEntry _:
                    directoryList[(int)((EntryNameTableDirectoryEntry)entryNameTableEntry).directoryID - 61440].DirectoryName = ((EntryNameTableDirectoryEntry)entryNameTableEntry).entryName;
                    num += (uint)(3 + ((int)entryNameTableEntry.entryNameLength & (int)sbyte.MaxValue));
                    break;
                }
            }
            FileSystem.Directory Parent2 = new FileSystem.Directory("", true);
            directoryList[0].IsRoot        = false;
            directoryList[0].DirectoryName = "data";
            directoryList[0].Parent        = Parent2;
            Parent2.SubDirectories.Add(directoryList[0]);
            Parent2.IsVirtualDirectory = true;
            for (int index = 0; index < this.main_ovt.Length; ++index)
            {
                Parent2.Files.Add(new FileSystem.File((int)(ushort)this.main_ovt[index].file_id, "overlay9_" + this.main_ovt[index].id.ToString("d4") + ".bin", Parent2));
            }
            for (int index = 0; index < this.sub_ovt.Length; ++index)
            {
                Parent2.Files.Add(new FileSystem.File((int)(ushort)this.sub_ovt[index].file_id, "overlay7_" + this.sub_ovt[index].id.ToString("d4") + ".bin", Parent2));
            }
            Parent2.Files.Add(new FileSystem.File(-1, "arm9.bin", Parent2));
            Parent2.Files.Add(new FileSystem.File(-2, "arm7.bin", Parent2));
            Parent2.GetFileByID(-1).Data = this.main_rom;
            Parent2.GetFileByID(-2).Data = this.sub_rom;
            for (int Id = 0; Id < this.fat.Length; ++Id)
            {
                Parent2.GetFileByID(Id).Data = this.FileData[Id];
            }
        }