Пример #1
0
        private static int loadSubFiles(BinaryReader reader, Nds.NdsFat_s FAT, List <Common.FileInfo_s> fileInfoList, ref MainDir_s actualMainDir, ref SubDir_s actualSubDir)
        {
            int type;

            Common.FileInfo_s actualFileInfo = new Common.FileInfo_s();
            if (actualSubDir.Files == null)
            {
                actualSubDir.Files = new List <Common.FileInfo_s>();
            }
            type = actualSubDir.Type;
            actualFileInfo.Name   = new string(Encoding.GetEncoding("shift_jis").GetChars(reader.ReadBytes(type)));
            actualFileInfo.ID     = actualMainDir.FFile_ID;
            actualFileInfo.Offset = FAT.getFileStartAt((int)actualFileInfo.ID);
            actualFileInfo.Size   = FAT.getFileEndAt((int)actualFileInfo.ID) - actualFileInfo.Offset;
            long num5 = reader.BaseStream.Position;

            reader.BaseStream.Seek((long)actualFileInfo.Offset, SeekOrigin.Begin);
            actualFileInfo.FileData = new ClosableMemoryStream();
            Utils.loadStream(reader, actualFileInfo.Size, actualFileInfo.FileData);
            reader.BaseStream.Seek((long)actualFileInfo.Offset, SeekOrigin.Begin);
            FAT.setFileStreamAt((int)actualFileInfo.ID, actualFileInfo.FileData);
            reader.BaseStream.Seek(num5, SeekOrigin.Begin);
            actualMainDir.FFile_ID = (ushort)(actualMainDir.FFile_ID + 1);
            actualSubDir.Files.Add(actualFileInfo);
            fileInfoList.Add(actualFileInfo);
            return(type);
        }
Пример #2
0
 public static Common.Folder_s Order_Folder(List <MainDir_s> tables, int idFolder, string nameFolder)
 {
     Common.Folder_s _s = new Common.Folder_s {
         Name  = nameFolder,
         ID    = (ushort)idFolder,
         Files = tables[idFolder & 0xfff].SubDir.Files
     };
     if (_s.Files != null)
     {
         for (int i = 0; i < _s.Files.Count; i++)
         {
             Common.FileInfo_s _s2 = _s.Files[i];
             _s2.Parent_ID = (ushort)idFolder;
             _s.Files[i]   = _s2;
         }
     }
     if (tables[idFolder & 0xfff].SubDir.Folders != null)
     {
         _s.Folders = new List <Common.Folder_s>();
         foreach (Common.Folder_s _s3 in tables[idFolder & 0xfff].SubDir.Folders)
         {
             _s.Folders.Add(Order_Folder(tables, (int)_s3.ID, _s3.Name));
         }
     }
     return(_s);
 }
Пример #3
0
 private static Common.Folder_s updateParentIDFiles(int idFolder, Common.Folder_s actualFolder)
 {
     for (int i = 0; i < actualFolder.Files.Count; i++)
     {
         Common.FileInfo_s actualFile = actualFolder.Files[i];
         actualFile.Parent_ID  = (ushort)idFolder;
         actualFolder.Files[i] = actualFile;
     }
     return(actualFolder);
 }
Пример #4
0
            public Common.Folder_s ReadFnt(BinaryReader reader, uint size, uint offset, NarcFat_s FAT)
            {
                Common.Folder_s folderStruct = new Common.Folder_s();
                long            position     = reader.BaseStream.Position;

                Fnt_Data = new byte[size];
                Fnt_Data = reader.ReadBytes((int)size);
                reader.BaseStream.Position = offset;
                int index = 0;

                SubDir_Off = reader.ReadUInt32();
                reader.BaseStream.Position = offset;
                MainDir = new List <MainDir_s>();
                List <Common.FileInfo_s> fileInfoList = new List <Common.FileInfo_s>();

                while (reader.BaseStream.Position < (position + SubDir_Off))
                {
                    MainDir_s actualDir = new MainDir_s {
                        startOffset = reader.ReadUInt32(),
                        firstFileId = reader.ReadUInt16(),
                        parentId    = reader.ReadUInt16()
                    };
                    long num3 = reader.BaseStream.Position;
                    reader.BaseStream.Position = offset + actualDir.startOffset;
                    Array.Resize <byte>(ref actualDir.SubDir.Type2, index + 1);
                    actualDir.SubDir.Type2[index] = reader.ReadByte();
                    actualDir.SubDir.Type         = actualDir.SubDir.Type2[index];
                    actualDir.SubDir.Parent_ID    = actualDir.firstFileId;
                    while (actualDir.SubDir.Type != 0)
                    {
                        int type;
                        if (actualDir.SubDir.Type < 0x80)
                        {
                            Common.FileInfo_s _s3 = new Common.FileInfo_s();
                            if (actualDir.SubDir.Files == null)
                            {
                                actualDir.SubDir.Files = new List <Common.FileInfo_s>();
                            }
                            type       = actualDir.SubDir.Type;
                            _s3.Name   = new string(Encoding.GetEncoding("shift_jis").GetChars(reader.ReadBytes(type)));
                            pad       += _s3.Name.Length;
                            _s3.ID     = actualDir.firstFileId;
                            _s3.Offset = FAT.getFileStartAt((int)_s3.ID);
                            _s3.Size   = FAT.getFileEndAt((int)_s3.ID) - _s3.Offset;
                            long num5 = reader.BaseStream.Position;
                            reader.BaseStream.Seek((long)_s3.Offset, SeekOrigin.Begin);
                            _s3.FileData = new ClosableMemoryStream();
                            Utils.loadStream(reader, _s3.Size, _s3.FileData);
                            reader.BaseStream.Seek((long)_s3.Offset, SeekOrigin.Begin);
                            FAT.setFileStreamAt((int)_s3.ID, _s3.FileData);
                            reader.BaseStream.Seek(num5, SeekOrigin.Begin);
                            actualDir.firstFileId = (ushort)(actualDir.firstFileId + 1);
                            actualDir.SubDir.Files.Add(_s3);
                            fileInfoList.Add(_s3);
                        }
                        if (actualDir.SubDir.Type > 0x80)
                        {
                            Common.Folder_s _s4 = new Common.Folder_s();
                            if (actualDir.SubDir.Folders == null)
                            {
                                actualDir.SubDir.Folders = new List <Common.Folder_s>();
                            }
                            type     = actualDir.SubDir.Type - 0x80;
                            _s4.Name = new string(Encoding.GetEncoding("shift_jis").GetChars(reader.ReadBytes(type)));
                            pad     += _s4.Name.Length;
                            _s4.ID   = reader.ReadUInt16();
                            actualDir.SubDir.Folders.Add(_s4);
                        }
                        index++;
                        Array.Resize <byte>(ref actualDir.SubDir.Type2, index + 1);
                        actualDir.SubDir.Type2[index] = reader.ReadByte();
                        pad++;
                        actualDir.SubDir.Type = actualDir.SubDir.Type2[index];
                    }
                    MainDir.Add(actualDir);
                    reader.BaseStream.Position = num3;
                }
                folderStruct    = Order_Folder(MainDir, 0, "root");
                folderStruct.ID = 0xf000;
                return(folderStruct);
            }