private static bool ReadPakInfo(Stream stream, long size, AesPakCryptoProvider?_aesProvider, [NotNullWhen(true)] out PakInfo?info) { var values = Enum.GetValues(typeof(PakInfoSize)).Cast <int>().Where(x => size > x); // check only versions that can actually be pak files if (values.Any()) { var maxSize = values.Max(); using var data = PakMemoryPool.Shared.Rent(maxSize); stream.ReadWholeBuf(-maxSize, SeekOrigin.End, data.Memory); foreach (var value in values) { if (value > size) { continue; } var z = data.Memory.Slice(data.Memory.Length - value); var pak = new PakInfo(z, _aesProvider); if (pak.IsUnrealPak) { info = pak; return(true); } } } info = null; return(false); }
private async ValueTask InitializeAsync(PakInfo info, CancellationToken cancellationToken = default) => ProcessIndex(await info.ReadIndexAsync(SourceStream, cancellationToken: cancellationToken).ConfigureAwait(false));
private void Initialize(PakInfo info) => ProcessIndex(info.ReadIndex(SourceStream));