System.IO.Compression.ZLibNative.ZLibStreamHandle.Inflate C# (CSharp) Method

Inflate() private method

private Inflate ( FlushCode flush ) : ErrorCode
flush FlushCode
return ErrorCode
            public ErrorCode Inflate(FlushCode flush)
            {
                EnsureNotDisposed();
                EnsureState(State.InitializedForInflate);
                return Interop.zlib.Inflate(ref _zStream, flush);
            }

Usage Example

Esempio n. 1
0
        private ZLibNative.ErrorCode Inflate(ZLibNative.FlushCode flushCode)
        {
            ZLibNative.ErrorCode errC;
            try
            {
                errC = _zlibStream.Inflate(flushCode);
            }
            catch (Exception cause) // could not load the Zlib DLL correctly
            {
                throw new ZLibException("SR.ZLibErrorDLLLoadError", cause);
            }
            switch (errC)
            {
            case ZLibNative.ErrorCode.Ok:               // progress has been made inflating
            case ZLibNative.ErrorCode.StreamEnd:        // The end of the input stream has been reached
                return(errC);

            case ZLibNative.ErrorCode.BufError:         // No room in the output buffer - inflate() can be called again with more space to continue
                return(errC);

            case ZLibNative.ErrorCode.MemError:         // Not enough memory to complete the operation
                throw new ZLibException("SR.ZLibErrorNotEnoughMemory", "inflate_", (int)errC, _zlibStream.GetErrorMessage());

            case ZLibNative.ErrorCode.DataError:        // The input data was corrupted (input stream not conforming to the zlib format or incorrect check value)
                throw new InvalidDataException("SR.UnsupportedCompression");

            case ZLibNative.ErrorCode.StreamError:      //the stream structure was inconsistent (for example if next_in or next_out was NULL),
                throw new ZLibException("SR.ZLibErrorInconsistentStream", "inflate_", (int)errC, _zlibStream.GetErrorMessage());

            default:
                throw new ZLibException("SR.ZLibErrorUnexpected", "inflate_", (int)errC, _zlibStream.GetErrorMessage());
            }
        }