Exemple #1
0
        public List <string> GetNames(Stream input, FNTHeader fntHeader)
        {
            using (var br = new BinaryReaderX(input, true))
            {
                var firstDirecOffset = br.ReadUInt32();
                var firstFilePos     = br.ReadUInt16();
                var direcCount       = br.ReadByte();
                var parentDir        = br.ReadByte();

                //need samples with multi directories
                if (direcCount > 1)
                {
                    throw new System.Exception("Seems like the archive has more than one directory. Create an issue on our github with this errored file as sample!");
                }

                var names = new List <string>();
                while (br.BaseStream.Position < br.BaseStream.Length)
                {
                    var id = br.ReadByte();
                    if ((id & 0x80) == 1)
                    {
                        throw new System.Exception("Seems like the archive has more than one directory. Create an issue on our github with this errored file as sample!");
                    }

                    var stringLength = id & 0x7f;
                    names.Add(br.ReadString(stringLength));
                }

                return(names);
            }
        }
Exemple #2
0
        public NARC(Stream input)
        {
            _stream = input;
            using (var br = new BinaryReaderX(input, true))
            {
                //Header
                genHeader = br.ReadStruct <GenericHeader>();

                //FAT
                fatHeader = br.ReadStruct <FATHeader>();
                var entries = br.ReadMultiple <FATEntry>((int)fatHeader.fileCount);

                //FNT
                fntHeader = br.ReadStruct <FNTHeader>();
                nameP     = br.ReadBytes((int)(fntHeader.secSize - 8));
                var names = GetNames(new MemoryStream(nameP), fntHeader);

                //GMIF - FileData
                gmifHeader = br.ReadStruct <FIMGHeader>();
                var dataOffset = br.BaseStream.Position;
                for (int i = 0; i < fatHeader.fileCount; i++)
                {
                    Files.Add(new NARCFileInfo
                    {
                        State    = ArchiveFileState.Archived,
                        FileName = names[i],
                        FileData = new SubStream(br.BaseStream, dataOffset + entries[i].startOffset, entries[i].endOffset - entries[i].startOffset),
                        entry    = entries[i]
                    });
                }
            }
        }