Exemplo n.º 1
0
        private async ValueTask <IMemoryOwner <byte> > ProcessEntryAsync(PakEntry entry, CancellationToken cancellationToken = default)
        {
            var data = await entry.ReadAsync(SourceStream, cancellationToken);

            if (entry.IsEncrypted)
            {
                if (_aesProvider is null)
                {
                    throw new PakEncryptedException("Pak file contains encrypted entries. AES encryption key is necessary for reading this asset.");
                }

                _aesProvider.Decrypt(data.Memory);
            }
            return(entry.IsCompressed ? await UnrealCompression.DecompressAsync(data, entry) : data);
        }
Exemplo n.º 2
0
        private IMemoryOwner <byte> ProcessEntry(PakEntry entry)
        {
            var data = entry.Read(SourceStream);

            if (entry.IsEncrypted)
            {
                if (_aesProvider is null)
                {
                    throw new PakEncryptedException("Pak file contains encrypted entries. AES encryption key is necessary for reading this asset.");
                }

                // decrypts data inplace
                _aesProvider.Decrypt(data.Memory);
            }
            return(entry.IsCompressed ? UnrealCompression.Decompress(data, entry) : data);
        }