Beispiel #1
0
        public byte[] ReadFile(PackedFileInfo packedFileInfo)
        {
            _gameFileData.Seek(packedFileInfo.location + 8, SeekOrigin.Begin);
            var buffer = new byte[packedFileInfo.size];

            _gameFileData.Read(buffer, 0, buffer.Length);
            return(buffer);
        }
Beispiel #2
0
        private string GetFileType(PackedFileInfo packedFileInfo)
        {
            var returnTo = _gameFileData.Position;

            var buffer = new byte[8];

            _gameFileData.Position = packedFileInfo.location + 8;
            _gameFileData.Read(buffer, 0, buffer.Length);

            if (buffer.Take(4).SequenceEqual(FileHeaders.Wave))
            {
                return("wav");
            }

            if (buffer.Take(4).SequenceEqual(FileHeaders.Texture))
            {
                return("dds");
            }

            _gameFileData.Position = returnTo;
            return(default);
Beispiel #3
0
        public PackedFileInfo[] GetPackedFiles()
        {
            var fileReader = new BinaryReader(_gameFileData);

            // File names start 64 bits from the header.
            fileReader.BaseStream.Seek(8, SeekOrigin.Begin);

            var fileCount   = GetFileCount();
            var dataAddress = GetDataAddress();

            var packedFiles = new PackedFileInfo[fileCount];

            for (var x = 0u; x < fileCount; x++)
            {
                var fileName = Encoding.UTF8.GetString(fileReader.ReadBytes(16)).Split('\0')[0]
                               ?? throw new Exception("Invalid String");

                var fileOffset = fileReader.ReadUInt32();
                var fileSize   = fileReader.ReadUInt32();
                fileReader.BaseStream.Position += 8;

                packedFiles[x] = new PackedFileInfo()
                {
                    name            = fileName,
                    size            = fileSize,
                    dataStartOffset = fileOffset,
                    location        = fileOffset + dataAddress
                };
            }

            for (var x = 0; x < fileCount; x++)
            {
                packedFiles[x].extension = GetFileType(packedFiles[x]);
            }

            return(packedFiles);
        }