Beispiel #1
0
        private void Read()
        {
            var fourCc = _reader.ReadUInt32().ToFourCcString();

            switch (fourCc)
            {
            case "BIGF":
                Version = BigArchiveVersion.BigF;
                break;

            case "BIG4":
                Version = BigArchiveVersion.Big4;
                break;

            default:
                throw new InvalidDataException($"Not a supported BIG format: {fourCc}");
            }

            _reader.ReadBigEndianUInt32(); // Archive Size
            var numEntries = _reader.ReadBigEndianUInt32();

            _reader.ReadBigEndianUInt32(); // First File Offset

            for (var i = 0; i < numEntries; i++)
            {
                var entryOffset = _reader.ReadBigEndianUInt32();
                var entrySize   = _reader.ReadBigEndianUInt32();
                var entryName   = _reader.ReadNullTerminatedString();

                var entry = new BigArchiveEntry(this, entryName, entryOffset, entrySize);

                _entries.Add(entry);
                _entriesDictionary.Add(entryName, entry);
            }
        }
Beispiel #2
0
        private void Read()
        {
            using (var reader = new BinaryReader(_stream, Encoding.ASCII, true))
            {
                //Special case for empty archives/ placeholder archives
                if (reader.BaseStream.Length < 4)
                {
                    var a = reader.ReadByte();
                    var b = reader.ReadByte();

                    if (a == '?' && b == '?')
                    {
                        return;
                    }
                    else
                    {
                        throw new InvalidDataException($"Big archive is too small");
                    }
                }

                var fourCc = reader.ReadFourCc();
                switch (fourCc)
                {
                case "BIGF":
                    Version = BigArchiveVersion.BigF;
                    break;

                case "BIG4":
                    Version = BigArchiveVersion.Big4;
                    break;

                default:
                    throw new InvalidDataException($"Not a supported BIG format: {fourCc}");
                }

                reader.ReadBigEndianUInt32(); // Archive Size
                var numEntries = reader.ReadBigEndianUInt32();
                reader.ReadBigEndianUInt32(); // First File Offset

                for (var i = 0; i < numEntries; i++)
                {
                    var entryOffset = reader.ReadBigEndianUInt32();
                    var entrySize   = reader.ReadBigEndianUInt32();
                    var entryName   = reader.ReadNullTerminatedString();

                    var entry = new BigArchiveEntry(this, entryName, entryOffset, entrySize);

                    _entries.Add(entry);

                    // Overwrite any previous entries with the same name.
                    // Yes, at least one .big file has entries with duplicate names.
                    _entriesDictionary[entryName] = entry;
                }
            }
        }
Beispiel #3
0
        private void Read()
        {
            using (var reader = new BinaryReader(_stream, Encoding.ASCII, true))
            {
                var fourCc = reader.ReadFourCc();
                switch (fourCc)
                {
                case "BIGF":
                    Version = BigArchiveVersion.BigF;
                    break;

                case "BIG4":
                    Version = BigArchiveVersion.Big4;
                    break;

                default:
                    throw new InvalidDataException($"Not a supported BIG format: {fourCc}");
                }

                reader.ReadBigEndianUInt32(); // Archive Size
                var numEntries = reader.ReadBigEndianUInt32();
                reader.ReadBigEndianUInt32(); // First File Offset

                for (var i = 0; i < numEntries; i++)
                {
                    var entryOffset = reader.ReadBigEndianUInt32();
                    var entrySize   = reader.ReadBigEndianUInt32();
                    var entryName   = reader.ReadNullTerminatedString();

                    var entry = new BigArchiveEntry(this, entryName, entryOffset, entrySize);

                    _entries.Add(entry);

                    // Overwrite any previous entries with the same name.
                    // Yes, at least one .big file has entries with duplicate names.
                    _entriesDictionary[entryName] = entry;
                }
            }
        }