Esempio n. 1
0
        public static Bnd3FileEntry Read(Stream inputStream, int fileSize, string fileName)
        {
            Bnd3FileEntry result = new Bnd3FileEntry();
            BinaryReader  reader = new BinaryReader(inputStream, Encoding.UTF8, true);

            result.FileName  = fileName;
            result.EntryData = reader.ReadBytes(fileSize);
            return(result);
        }
Esempio n. 2
0
        private void Read(Stream inputStream)
        {
            BinaryReader reader    = new BinaryReader(inputStream, Encoding.GetEncoding("Shift-JIS"), true);
            string       signature = reader.ReadString(4);

            if (signature != Bnd3Signature)
            {
                throw new Exception("Unknown signature");
            }
            string id      = reader.ReadString(8);
            int    version = reader.ReadInt32();

            if (version != 0x74 && version != 0x54 && version != 0x5c && version != 0x7c && version != 0x78)
            {
                throw new InvalidDataException();
            }

            int recordCount     = reader.ReadInt32();
            int totalHeaderSize = reader.ReadInt32(); // Either zero or the unaligned end of the last record's name before the first record's data.

            reader.Skip(8);

            if (version == 0x5c)
            {
            }
            long p = reader.GetPosition();

            for (int i = 0; i < recordCount; i++)
            {
                reader.Skip(4);
                int fileSize       = reader.ReadInt32();
                int fileOffset     = reader.ReadInt32();
                int fileId         = reader.ReadInt32();
                int hmm            = reader.ReadInt32();
                int fileNameOffset = reader.ReadInt32();
                if (version != 0x78)
                {
                    int fileSize2 = reader.ReadInt32();
                }

                long offset = reader.GetPosition();

                string fileName = "";
                if (fileNameOffset > 0)
                {
                    reader.Seek(fileNameOffset);
                    fileName = reader.ReadNullTerminatedString();
                }

                reader.Seek(fileOffset);
                _entries.Add(Bnd3FileEntry.Read(inputStream, fileSize, fileName));
                reader.Seek(offset);
            }
        }