コード例 #1
0
ファイル: DeflateStream.cs プロジェクト: zhufengGNSS/mono
        public static DeflateStreamNative Create(Stream compressedStream, CompressionMode mode, bool gzip)
        {
            var dsn = new DeflateStreamNative();

            dsn.data     = GCHandle.Alloc(dsn);
            dsn.feeder   = mode == CompressionMode.Compress ? new UnmanagedReadOrWrite(UnmanagedWrite) : new UnmanagedReadOrWrite(UnmanagedRead);
            dsn.z_stream = CreateZStream(mode, gzip, dsn.feeder, GCHandle.ToIntPtr(dsn.data));
            if (dsn.z_stream == IntPtr.Zero)
            {
                dsn.Dispose(true);
                return(null);
            }

            dsn.base_stream = compressedStream;
            return(dsn);
        }
コード例 #2
0
ファイル: DeflateStream.cs プロジェクト: BrzVlad/mono
		internal DeflateStream (Stream compressedStream, CompressionMode mode, bool leaveOpen, bool gzip)
		{
			if (compressedStream == null)
				throw new ArgumentNullException ("compressedStream");

			if (mode != CompressionMode.Compress && mode != CompressionMode.Decompress)
				throw new ArgumentException ("mode");

			this.base_stream = compressedStream;

			this.native = DeflateStreamNative.Create (compressedStream, mode, gzip);
			if (this.native == null) {
				throw new NotImplementedException ("Failed to initialize zlib. You probably have an old zlib installed. Version 1.2.0.4 or later is required.");
			}
			this.mode = mode;
			this.leaveOpen = leaveOpen;
		}
コード例 #3
0
ファイル: DeflateStream.cs プロジェクト: zhufengGNSS/mono
        internal DeflateStream(Stream compressedStream, CompressionMode mode, bool leaveOpen, bool gzip)
        {
            if (compressedStream == null)
            {
                throw new ArgumentNullException("compressedStream");
            }

            if (mode != CompressionMode.Compress && mode != CompressionMode.Decompress)
            {
                throw new ArgumentException("mode");
            }

            this.base_stream = compressedStream;

            this.native = DeflateStreamNative.Create(compressedStream, mode, gzip);
            if (this.native == null)
            {
                throw new NotImplementedException("Failed to initialize zlib. You probably have an old zlib installed. Version 1.2.0.4 or later is required.");
            }
            this.mode      = mode;
            this.leaveOpen = leaveOpen;
        }
コード例 #4
0
ファイル: DeflateStream.cs プロジェクト: BrzVlad/mono
		public static DeflateStreamNative Create (Stream compressedStream, CompressionMode mode, bool gzip)
		{
			var dsn = new DeflateStreamNative ();
			dsn.data = GCHandle.Alloc (dsn);
			dsn.feeder = mode == CompressionMode.Compress ? new UnmanagedReadOrWrite (UnmanagedWrite) : new UnmanagedReadOrWrite (UnmanagedRead);
			dsn.z_stream = CreateZStream (mode, gzip, dsn.feeder, GCHandle.ToIntPtr (dsn.data));
			if (dsn.z_stream == IntPtr.Zero) {
				dsn.Dispose (true);
				return null;
			}

			dsn.base_stream = compressedStream;
			return dsn;
		}