Esempio n. 1
0
        public Narc LoadNarc(BinaryReader reader)
        {
            reader.BaseStream.Seek(4L, SeekOrigin.Begin);
            magic       = reader.ReadInt32();
            narcSize    = reader.ReadUInt32();
            sectionSize = reader.ReadInt16();
            sectionNum  = reader.ReadInt16();
            reader.ReadInt32();
            fatbSize = reader.ReadUInt32();
            fatbNum  = reader.ReadUInt32();
            fatb     = new NarcFat_s();
            uint fatbStartOffset = (uint)reader.BaseStream.Position;

            fatb.ReadFat(reader, fatbNum);
            reader.ReadInt32();
            fntbSize                   = reader.ReadUInt32();
            fntbStartOffset            = (uint)reader.BaseStream.Position;
            fntb                       = new NarcFnt_s();
            treeSystem                 = fntb.ReadFnt(reader, fntbSize, fntbStartOffset, fatb);
            reader.BaseStream.Position = fntbStartOffset + fntbSize;
            figm.magicId               = reader.ReadChars(4);
            figm.sizeFigm              = reader.ReadInt32();
            figm.startFigm             = (int)reader.BaseStream.Position;
            figm.fileData              = new List <ClosableMemoryStream>();
            for (int fileCounter = 0; fileCounter < fatbNum; fileCounter++)
            {
                ClosableMemoryStream actualFileStream = new ClosableMemoryStream();
                //MessageBox.Show(fntb.getpad().ToString());
                reader.BaseStream.Position = fatb.getFileStartAt(fileCounter) + fntbStartOffset + fntbSize;
                Utils.loadStream(reader, fatb.getFileEndAt(fileCounter) - fatb.getFileStartAt(fileCounter), actualFileStream);
                figm.fileData.Add(actualFileStream);
            }
            return(this);
        }
Esempio n. 2
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);
            }