Example #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);
        }