Esempio n. 1
0
        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}.");
            }
        }
Esempio n. 2
0
        private void InflateInit(Int32 windowBits)
        {
            var error = ZLibNative.CreateZLibStreamForInflate(out m_handle, windowBits);

            switch (error)
            {
            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:     //zlib library is incompatible with the version assumed
                throw new IOException("The version of the underlying compression routine does not match expected version.");

            case ZLibNative.ErrorCode.StreamError:      // Parameters are invalid
                throw new IOException("The underlying compression routine received incorrect initialization parameters.");

            default:
                throw new IOException($"The underlying compression routine returned an unexpected error code {error}.");
            }
        }