Esempio n. 1
0
        public override void WriteTo(Stream source, Stream destination)
        {
            LZ4StreamFlags flags = LZ4StreamFlags.IsolateInnerStream |
                                   (CompressionLevel > 1 ? LZ4StreamFlags.HighCompression : LZ4StreamFlags.None);

            using (var lz4 = new LZ4Stream(destination, CompressionMode.Compress, flags, 4194304))
            {
                source.CopyTo(lz4);
            }
        }
        /// <summary>Initializes a new instance of the <see cref="LZ4Stream" /> class.</summary>
        /// <param name="innerStream">The inner stream.</param>
        /// <param name="compressionMode">The compression mode.</param>
        /// <param name="compressionFlags">The compression flags.</param>
        /// <param name="blockSize">Size of the block.</param>
        public LZ4Stream(
			Stream innerStream,
			CompressionMode compressionMode,
			LZ4StreamFlags compressionFlags = LZ4StreamFlags.Default,
			int blockSize = 1024*1024)
            : this(innerStream,
				ToLZ4StreamMode(compressionMode),
				compressionFlags,
				blockSize)
        {
        }
Esempio n. 3
0
 /// <summary>Initializes a new instance of the <see cref="LZ4Stream" /> class.</summary>
 /// <param name="innerStream">The inner stream.</param>
 /// <param name="compressionMode">The compression mode.</param>
 /// <param name="compressionFlags">The compression flags.</param>
 /// <param name="blockSize">Size of the block.</param>
 public LZ4Stream(
     Stream innerStream,
     CompressionMode compressionMode,
     LZ4StreamFlags compressionFlags = LZ4StreamFlags.Default,
     int blockSize = 1024 *1024)
     : this(
         innerStream,
         ToLZ4StreamMode(compressionMode),
         compressionFlags,
         blockSize)
 {
 }
Esempio n. 4
0
 /// <summary>Initializes a new instance of the <see cref="LZ4Stream" /> class.</summary>
 /// <param name="innerStream">The inner stream.</param>
 /// <param name="compressionMode">The compression mode.</param>
 /// <param name="compressionFlags">The compression flags.</param>
 /// <param name="blockSize">Size of the block.</param>
 public LZ4Stream(
     Stream innerStream,
     LZ4StreamMode compressionMode,
     LZ4StreamFlags compressionFlags = LZ4StreamFlags.Default,
     int blockSize = 1024 *1024)
 {
     _innerStream        = innerStream;
     _compressionMode    = compressionMode;
     _highCompression    = (compressionFlags & LZ4StreamFlags.HighCompression) != 0;
     _interactiveRead    = (compressionFlags & LZ4StreamFlags.InteractiveRead) != 0;
     _isolateInnerStream = (compressionFlags & LZ4StreamFlags.IsolateInnerStream) != 0;
     _blockSize          = Math.Max(16, blockSize);
 }
Esempio n. 5
0
        public override Stream GetStream(Stream source)
        {
            MemoryStream mem = new MemoryStream();

            LZ4StreamFlags flags = LZ4StreamFlags.IsolateInnerStream |
                                   (CompressionLevel > 1 ? LZ4StreamFlags.HighCompression : LZ4StreamFlags.None);

            using (var lz4 = new LZ4Stream(mem, CompressionMode.Compress, flags, 4194304))
            {
                source.CopyTo(lz4);
            }

            mem.SetLength(mem.Length);             //trims excess off buffer
            mem.Position = 0;

            return(mem);
        }
Esempio n. 6
0
        /// <summary>Initializes a new instance of the <see cref="LZ4Stream" /> class.</summary>
        /// <param name="innerStream">The inner stream.</param>
        /// <param name="compressionMode">The compression mode.</param>
        /// <param name="compressionFlags">The compression flags.</param>
        /// <param name="blockSize">Size of the block.</param>
        public LZ4Stream(
			Stream innerStream,
			LZ4StreamMode compressionMode,
			LZ4StreamFlags compressionFlags = LZ4StreamFlags.Default,
			int blockSize = 1024*1024)
        {
            _innerStream = innerStream;
            _compressionMode = compressionMode;
            _highCompression = (compressionFlags & LZ4StreamFlags.HighCompression) != 0;
            _interactiveRead = (compressionFlags & LZ4StreamFlags.InteractiveRead) != 0;
            _isolateInnerStream = (compressionFlags & LZ4StreamFlags.IsolateInnerStream) != 0;
            _blockSize = Math.Max(16, blockSize);
        }