public Compressor(CompressionOptions options) { Options = options; cctx = ExternMethods.ZSTD_createCCtx().EnsureZstdSuccess(); options.ApplyCompressionParams(cctx); if (options.Cdict != IntPtr.Zero) { ExternMethods.ZSTD_CCtx_refCDict(cctx, options.Cdict).EnsureZstdSuccess(); } }
public CompressorStream(Stream stream, CompressionOptions options) { InnerStream = stream; Options = options; CStream = ZSTD_createCStream(); if (options.Cdict == IntPtr.Zero) { ZSTD_initCStream(CStream, options.CompressionLevel).EnsureZstdSuccess(); } else { ZSTD_initCStream_usingCDict(CStream, options.Cdict).EnsureZstdSuccess(); } OutputBuffer = CreateOutputBuffer(); InitializedOutputBufferState(); }
public CompressionStream(Stream stream, CompressionOptions options, int bufferSize = 0) { if (stream == null) { throw new ArgumentNullException(nameof(stream)); } if (!stream.CanWrite) { throw new ArgumentException("Stream is not writable", nameof(stream)); } if (bufferSize < 0) { throw new ArgumentOutOfRangeException(nameof(bufferSize)); } innerStream = stream; cStream = ZSTD_createCStream().EnsureZstdSuccess(); ZSTD_CCtx_reset(cStream, ZSTD_ResetDirective.ZSTD_reset_session_only).EnsureZstdSuccess(); if (options != null) { options.ApplyCompressionParams(cStream); if (options.Cdict != IntPtr.Zero) { ZSTD_CCtx_refCDict(cStream, options.Cdict).EnsureZstdSuccess(); } } this.bufferSize = bufferSize > 0 ? bufferSize : (int)ZSTD_CStreamOutSize().EnsureZstdSuccess(); outputBuffer = ArrayPool <byte> .Shared.Rent(this.bufferSize); #if !(NET45 || NETSTANDARD2_0) outputMemory = new ReadOnlyMemory <byte>(outputBuffer, 0, this.bufferSize); #endif }
public Compressor(CompressionOptions options) { Options = options; cctx = ExternMethods.ZSTD_createCCtx().EnsureZstdSuccess(); }
internal Compressor(ZstdNet.CompressionOptions options) => Delegator = new(options);
public StreamingCompressor(CompressionOptions options) { Options = options; zcs = ExternMethods.ZSTD_createCStream().EnsureZstdSuccess(); }