internal static int Process(zlib.ZStream /*!*/ zst, MutableString str, zlib.FlushStrategy flush, bool compress,
out MutableString /*!*/ result, ref MutableString trailingUncompressedData)
{
result = MutableString.CreateBinary();
// add previously compressed data to the output:
if (zst.next_out != null)
{
result.Append(zst.next_out, 0, zst.next_out_index);
}
int err;
int bufferStart = zst.next_out_index;
err = Process(zst, str, flush, compress, ref trailingUncompressedData);
result.Append(zst.next_out, bufferStart, zst.next_out_index - bufferStart);
if (err == Z_STREAM_END && (flush == zlib.FlushStrategy.Z_FINISH || str == null))
{
err = compress ? zst.deflateEnd() : zst.inflateEnd();
}
zst.next_out = null;
zst.next_out_index = 0;
zst.avail_out = 0;
return(err);
}