Esempio n. 1
0
        public static LZ4Stream CreateCompressor(Stream innerStream, LZ4StreamMode streamMode, LZ4FrameBlockMode blockMode = LZ4FrameBlockMode.Linked, LZ4FrameBlockSize blockSize = LZ4FrameBlockSize.Max64KB, LZ4FrameChecksumMode checksumMode = LZ4FrameChecksumMode.Content, long?maxFrameSize = null, bool leaveInnerStreamOpen = false)
        {
            var s = LZ4Loader.CreateCompressor()(innerStream, streamMode, blockMode, blockSize, checksumMode, maxFrameSize, leaveInnerStreamOpen);
            var r = new LZ4Stream();

            r._innerStream = s;
            return(r);
        }
Esempio n. 2
0
        public static byte[] Compress(byte[] input, int inputOffset, int inputLength, LZ4FrameBlockMode blockMode = LZ4FrameBlockMode.Linked, LZ4FrameBlockSize blockSize = LZ4FrameBlockSize.Max1MB, LZ4FrameChecksumMode checksumMode = LZ4FrameChecksumMode.Content, long?maxFrameSize = null, bool highCompression = false)
        {
            if (input == null)
            {
                throw new ArgumentNullException("input");
            }
            else if (inputOffset < 0)
            {
                throw new ArgumentOutOfRangeException("inputOffset");
            }
            else if (inputLength <= 0)
            {
                throw new ArgumentOutOfRangeException("inputLength");
            }
            else if (inputOffset + inputLength > input.Length)
            {
                throw new ArgumentOutOfRangeException("inputOffset+inputLength");
            }

            using (var ms = new MemoryStream()) {
                using (var lz4 = LZ4Stream.CreateCompressor(ms, LZ4StreamMode.Write, blockMode, blockSize, checksumMode, maxFrameSize, highCompression, true)) {
                    lz4.Write(input, inputOffset, inputLength);
                }
                return(ms.ToArray());
            }
        }
Esempio n. 3
0
 public static byte[] Compress(byte[] input, int inputOffset, int inputLength, LZ4FrameBlockMode blockMode = LZ4FrameBlockMode.Linked, LZ4FrameBlockSize blockSize = LZ4FrameBlockSize.Max64KB, LZ4FrameChecksumMode checksumMode = LZ4FrameChecksumMode.Content, long?maxFrameSize = null)
 {
     return(LZ4Loader.Compress4()(input, inputOffset, inputLength, blockMode, blockSize, checksumMode, maxFrameSize));
 }
Esempio n. 4
0
 public static byte[] Compress(byte[] input, LZ4FrameBlockMode blockMode = LZ4FrameBlockMode.Linked, LZ4FrameBlockSize blockSize = LZ4FrameBlockSize.Max1MB, LZ4FrameChecksumMode checksumMode = LZ4FrameChecksumMode.Content, long?maxFrameSize = null, bool highCompression = false)
 {
     if (input == null)
     {
         throw new ArgumentNullException("input");
     }
     return(Compress(input, 0, input.Length, blockMode, blockSize, checksumMode, maxFrameSize, highCompression));
 }
Esempio n. 5
0
        //public static class Custom {

        //	public static byte[] Compress(byte[] input) {
        //		return LZ4Loader.Compress1()(input);
        //	}

        //	public static byte[] Compress(byte[] input, int inputOffset, int inputLength, int passes) {
        //		return LZ4Loader.Compress2()(input, inputOffset, inputLength, passes);
        //	}

        //	public static byte[] Decompress(byte[] input) {
        //		return LZ4Loader.Decompress1()(input);
        //	}

        //	public static byte[] Decompress(byte[] input, int inputOffset, int inputLength) {
        //		return LZ4Loader.Decompress2()(input, inputOffset, inputLength);
        //	}
        //}

        //public static class Frame {

        public static byte[] Compress(byte[] input, LZ4FrameBlockMode blockMode = LZ4FrameBlockMode.Linked, LZ4FrameBlockSize blockSize = LZ4FrameBlockSize.Max1MB, LZ4FrameChecksumMode checksumMode = LZ4FrameChecksumMode.Content, long?maxFrameSize = null, bool highCompression = false)
        {
            return(LZ4Loader.Compress3()(input, blockMode, blockSize, checksumMode, maxFrameSize, highCompression));
        }