Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches

◆ Decompress()

unsafe OperationStatus System.IO.Compression.BrotliDecoder.Decompress ( ReadOnlySpan< byte > source,
Span< byte > destination,
out int bytesConsumed,
out int bytesWritten )
inline

Definition at line 45 of file BrotliDecoder.cs.

46 {
48 bytesConsumed = 0;
49 bytesWritten = 0;
50 if (global::Interop.Brotli.BrotliDecoderIsFinished(_state) != 0)
51 {
52 return OperationStatus.Done;
53 }
54 nuint availableOut = (nuint)destination.Length;
55 nuint availableIn = (nuint)source.Length;
56 while ((int)availableOut > 0)
57 {
58 fixed (byte* ptr = &MemoryMarshal.GetReference(source))
59 {
60 byte* ptr2 = ptr;
61 fixed (byte* ptr3 = &MemoryMarshal.GetReference(destination))
62 {
63 byte* ptr4 = ptr3;
64 UIntPtr totalOut;
65 int num = global::Interop.Brotli.BrotliDecoderDecompressStream(_state, ref availableIn, &ptr2, ref availableOut, &ptr4, out totalOut);
66 if (num == 0)
67 {
68 return OperationStatus.InvalidData;
69 }
70 bytesConsumed += source.Length - (int)availableIn;
71 bytesWritten += destination.Length - (int)availableOut;
72 switch (num)
73 {
74 case 1:
75 return OperationStatus.Done;
76 case 3:
77 return OperationStatus.DestinationTooSmall;
78 }
79 source = source.Slice(source.Length - (int)availableIn);
80 destination = destination.Slice(destination.Length - (int)availableOut);
81 if (num == 2 && source.Length == 0)
82 {
83 return OperationStatus.NeedMoreData;
84 }
85 }
86 }
87 }
88 return OperationStatus.DestinationTooSmall;
89 }
SafeBrotliDecoderHandle _state

References System.IO.Compression.BrotliDecoder._state, System.destination, System.IO.Compression.BrotliDecoder.EnsureInitialized(), and System.source.

Referenced by System.IO.Compression.BrotliStream.TryDecompress().