/// <summary>Initializes a new instance of the GZipStream class using the specified stream and BZip2CompressionMode value.</summary> /// <param name="stream">The stream to compress or decompress.</param> /// <param name="mode">One of the BZip2CompressionMode values that indicates the action to take.</param> /// <param name="opts">The encodgin/decoding options</param> public unsafe LZMAStream(Stream stream, CompressionMode mode, ref LZMAOptionLZMA opts) { fixed(LZMAOptionLZMA *o = &opts) { Init(stream, mode, o); } }
public static unsafe LZMAStatus CompressBuffer(void *inBuff, IntPtr inLength, void *outBuff, IntPtr outLength, out IntPtr outPosition, int preset) { var options = new LZMAOptionLZMA((uint) preset); var filters = stackalloc LZMAFilter[2]; filters[0].id = LZMANative.LZMA_FILTER_LZMA2; filters[0].options = &options; filters[1].id = LZMANative.LZMA_VLI_UNKNOWN; return CompressBuffer(inBuff, inLength, outBuff, outLength, out outPosition, filters); }
public static unsafe LZMAStatus CompressBuffer(void *inBuff, IntPtr inLength, void *outBuff, IntPtr outLength, out IntPtr outPosition, int preset) { var options = new LZMAOptionLZMA((uint)preset); var filters = stackalloc LZMAFilter[2]; filters[0].id = LZMANative.LZMA_FILTER_LZMA2; filters[0].options = &options; filters[1].id = LZMANative.LZMA_VLI_UNKNOWN; return(CompressBuffer(inBuff, inLength, outBuff, outLength, out outPosition, filters)); }
public unsafe void Init(Stream stream, CompressionMode mode, LZMAOptionLZMA *opts) { _compressedStream = stream; _mode = mode; _isClosed = false; _zstreamBuff = new byte[sizeof(LZMAStreamNative)]; _zstreamHandle = GCHandle.Alloc(_zstreamBuff, GCHandleType.Pinned); _zstream = (LZMAStreamNative*)_zstreamHandle.AddrOfPinnedObject().ToPointer(); _tmpBuffer = new byte[BufferSize]; _tmpBufferHandle = GCHandle.Alloc(_tmpBuffer, GCHandleType.Pinned); _tmpBufferPtr = _tmpBufferHandle.AddrOfPinnedObject().ToPointer(); LZMAStatus ret; switch (mode) { case CompressionMode.Compress: // We will always use one filter, + 1 to mark the end of the filter array var filters = stackalloc LZMAFilter[2]; filters[0].id = LZMANative.LZMA_FILTER_LZMA2; filters[0].options = opts; filters[1].id = LZMANative.LZMA_VLI_UNKNOWN; ret = LZMANative.lzma_stream_encoder(_zstream, filters, LZMACheck.LZMA_CHECK_CRC64); if (ret != LZMAStatus.LZMA_OK) throw new ArgumentException(string.Format("Unable to init LZMA decoder. Return code: {0}", ret)); _zstream->next_out = _tmpBufferPtr; _zstream->avail_out = (IntPtr)_tmpBuffer.Length; break; case CompressionMode.Decompress: ret = LZMANative.lzma_auto_decoder(_zstream, 1024 * 1024 * 1024, 0); if (ret != LZMAStatus.LZMA_OK) throw new ArgumentException(string.Format("Unable to init LZMA decoder. Return code: {0}", ret)); break; } }
public static extern unsafe LZMAStatus lzma_alone_encoder(LZMAStreamNative* strm, ref LZMAOptionLZMA options);
public unsafe LZMAStream(Stream stream, CompressionMode mode, LZMAOptionLZMA *opts) { Init(stream, mode, opts); }
/// <summary>Initializes a new instance of the GZipStream class using the specified stream and BZip2CompressionMode value.</summary> /// <param name="stream">The stream to compress or decompress.</param> /// <param name="mode">One of the BZip2CompressionMode values that indicates the action to take.</param> /// <param name="opts">The encodgin/decoding options</param> public unsafe LZMAStream(Stream stream, CompressionMode mode, ref LZMAOptionLZMA opts) { fixed (LZMAOptionLZMA* o = &opts) { Init(stream, mode, o); } }
public static extern unsafe LZMAStatus lzma_alone_encoder(LZMAStreamNative *strm, ref LZMAOptionLZMA options);