internal static extern ZLibNative.ErrorCode DeflateInit2_( ref ZLibNative.ZStream stream, ZLibNative.CompressionLevel level, ZLibNative.CompressionMethod method, int windowBits, int memLevel, ZLibNative.CompressionStrategy strategy);
private void DeflateInit(ZLibNative.CompressionLevel compressionLevel, int windowBits, int memLevel, ZLibNative.CompressionStrategy strategy) { ZErrorCode errC; try { errC = ZLibNative.CreateZLibStreamForDeflate(out _zlibStream, compressionLevel, windowBits, memLevel, strategy); } catch (Exception cause) { throw new ZLibException(SR.GetString(SR.ZLibErrorDLLLoadError), cause); } switch (errC) { case ZErrorCode.Ok: return; case ZErrorCode.MemError: throw new ZLibException(SR.GetString(SR.ZLibErrorNotEnoughMemory), "deflateInit2_", (int)errC, _zlibStream.GetErrorMessage()); case ZErrorCode.VersionError: throw new ZLibException(SR.GetString(SR.ZLibErrorVersionMismatch), "deflateInit2_", (int)errC, _zlibStream.GetErrorMessage()); case ZErrorCode.StreamError: throw new ZLibException(SR.GetString(SR.ZLibErrorIncorrectInitParameters), "deflateInit2_", (int)errC, _zlibStream.GetErrorMessage()); default: throw new ZLibException(SR.GetString(SR.ZLibErrorUnexpected), "deflateInit2_", (int)errC, _zlibStream.GetErrorMessage()); } }
internal static unsafe partial ZLibNative.ErrorCode DeflateInit2_( ZLibNative.ZStream *stream, ZLibNative.CompressionLevel level, ZLibNative.CompressionMethod method, int windowBits, int memLevel, ZLibNative.CompressionStrategy strategy);
internal static unsafe ZLibNative.ErrorCode DeflateInit2_( ref ZLibNative.ZStream stream, ZLibNative.CompressionLevel level, ZLibNative.CompressionMethod method, int windowBits, int memLevel, ZLibNative.CompressionStrategy strategy) { fixed(byte *versionString = &ZLibVersion[0]) fixed(ZLibNative.ZStream * streamBytes = &stream) { byte *pBytes = (byte *)streamBytes; return((ZLibNative.ErrorCode)deflateInit2_(pBytes, (int)level, (int)method, (int)windowBits, (int)memLevel, (int)strategy, versionString, sizeof(ZLibNative.ZStream))); } }
public ZLibNative.ErrorCode DeflateInit2_(ZLibNative.CompressionLevel level, int windowBits, int memLevel, ZLibNative.CompressionStrategy strategy) { this.EnsureNotDisposed(); this.EnsureState(ZLibNative.ZLibStreamHandle.State.NotInitialized); bool success = false; RuntimeHelpers.PrepareConstrainedRegions(); ZLibNative.ErrorCode errorCode; try { } finally { errorCode = ZLibNative.ZLibStreamHandle.NativeZLibDLLStub.deflateInit2_Delegate(ref this.zStream, level, ZLibNative.CompressionMethod.Deflated, windowBits, memLevel, strategy, "1.2.3", Marshal.SizeOf((object)this.zStream)); this.initializationState = ZLibNative.ZLibStreamHandle.State.InitializedForDeflate; ZLibNative.ZLibStreamHandle.zlibLibraryHandle.DangerousAddRef(ref success); } return(errorCode); }
private void DeflateInit(ZLibNative.CompressionLevel compressionLevel, Int32 windowBits, Int32 memLevel, ZLibNative.CompressionStrategy strategy) { var errorCode = ZLibNative.CreateZLibStreamForDeflate(out m_handle, compressionLevel, windowBits, memLevel, strategy); switch (errorCode) { case ZLibNative.ErrorCode.Ok: return; case ZLibNative.ErrorCode.MemError: throw new IOException("The underlying compression routine could not reserve sufficient memory."); case ZLibNative.ErrorCode.VersionError: throw new IOException("The version of the underlying compression routine does not match expected version."); case ZLibNative.ErrorCode.StreamError: throw new IOException("The underlying compression routine received incorrect initialization parameters."); default: throw new IOException($"The underlying compression routine returned an unexpected error code {errorCode}."); } }
public static ZLibNative.ErrorCode CreateZLibStreamForDeflate(out ZLibNative.ZLibStreamHandle zLibStreamHandle, ZLibNative.CompressionLevel level, int windowBits, int memLevel, ZLibNative.CompressionStrategy strategy) { zLibStreamHandle = new ZLibNative.ZLibStreamHandle(); return(zLibStreamHandle.DeflateInit2_(level, windowBits, memLevel, strategy)); }