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

◆ Compress() [3/3]

unsafe OperationStatus System.IO.Compression.BrotliEncoder.Compress ( ReadOnlySpan< byte > source,
Span< byte > destination,
out int bytesConsumed,
out int bytesWritten,
BrotliEncoderOperation operation )
inlinepackage

Definition at line 130 of file BrotliEncoder.cs.

131 {
133 bytesWritten = 0;
134 bytesConsumed = 0;
135 nuint availableOut = (nuint)destination.Length;
136 nuint availableIn = (nuint)source.Length;
137 while ((int)availableOut > 0)
138 {
139 fixed (byte* ptr = &MemoryMarshal.GetReference(source))
140 {
141 byte* ptr2 = ptr;
142 fixed (byte* ptr3 = &MemoryMarshal.GetReference(destination))
143 {
144 byte* ptr4 = ptr3;
145 if (global::Interop.Brotli.BrotliEncoderCompressStream(_state, operation, ref availableIn, &ptr2, ref availableOut, &ptr4, out UIntPtr _) == global::Interop.BOOL.FALSE)
146 {
147 return OperationStatus.InvalidData;
148 }
149 bytesConsumed += source.Length - (int)availableIn;
150 bytesWritten += destination.Length - (int)availableOut;
151 if ((int)availableOut == destination.Length && global::Interop.Brotli.BrotliEncoderHasMoreOutput(_state) == global::Interop.BOOL.FALSE && availableIn == 0)
152 {
153 return OperationStatus.Done;
154 }
155 source = source.Slice(source.Length - (int)availableIn);
156 destination = destination.Slice(destination.Length - (int)availableOut);
157 }
158 }
159 }
160 return OperationStatus.DestinationTooSmall;
161 }
SafeBrotliEncoderHandle _state

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