private ZErrorCode Deflate(ZFlushCode flushCode) { ZErrorCode errC; try { errC = _zlibStream.Deflate(flushCode); } catch (Exception cause) { throw new ZLibException("SR.ZLibErrorDLLLoadError", cause); } switch (errC) { case ZErrorCode.Ok: case ZErrorCode.StreamEnd: return(errC); case ZErrorCode.BufError: return(errC); // This is a recoverable error case ZErrorCode.StreamError: throw new ZLibException("SR.ZLibErrorInconsistentStream", "deflate", (int)errC, _zlibStream.GetErrorMessage()); default: throw new ZLibException("SR.ZLibErrorUnexpected", "deflate", (int)errC, _zlibStream.GetErrorMessage()); } }
private unsafe ZErrorCode ReadDeflateOutput(IntPtr buffer, int count, ZFlushCode flushCode, out int bytesRead) { lock (_syncLock) { _zlibStream.NextOut = buffer; _zlibStream.AvailOut = (uint)count; ZErrorCode errC = Deflate(flushCode); bytesRead = count - (int)_zlibStream.AvailOut; return(errC); } }