1 /* -*- Mode: csharp; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
6 // Christopher James Lahey <clahey@ximian.com>
8 // Copyright (C) 2004-2005 Novell, Inc (http://www.novell.com)
11 // Permission is hereby granted, free of charge, to any person obtaining
12 // a copy of this software and associated documentation files (the
13 // "Software"), to deal in the Software without restriction, including
14 // without limitation the rights to use, copy, modify, merge, publish,
15 // distribute, sublicense, and/or sell copies of the Software, and to
16 // permit persons to whom the Software is furnished to do so, subject to
17 // the following conditions:
19 // The above copyright notice and this permission notice shall be
20 // included in all copies or substantial portions of the Software.
22 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
23 // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
24 // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
25 // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
26 // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
27 // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
28 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
34 using System
.Runtime
.InteropServices
;
35 using System
.Runtime
.Remoting
.Messaging
;
37 namespace System
.IO
.Compression
{
39 public class GZipStream
: Stream
41 private DeflateStream deflateStream
;
43 public GZipStream (Stream compressedStream
, CompressionMode mode
) :
44 this (compressedStream
, mode
, false) {
47 public GZipStream (Stream compressedStream
, CompressionMode mode
, bool leaveOpen
) {
48 this.deflateStream
= new DeflateStream (compressedStream
, mode
, leaveOpen
, true);
51 protected override void Dispose (bool disposing
)
54 deflateStream
.Dispose ();
55 base.Dispose (disposing
);
58 public override int Read (byte[] dest
, int dest_offset
, int count
)
60 return deflateStream
.Read(dest
, dest_offset
, count
);
64 public override void Write (byte[] src
, int src_offset
, int count
)
66 deflateStream
.Write (src
, src_offset
, count
);
69 public override void Flush() {
70 deflateStream
.Flush();
73 public override long Seek (long offset
, SeekOrigin origin
) {
74 return deflateStream
.Seek (offset
, origin
);
77 public override void SetLength (long value) {
78 deflateStream
.SetLength (value);
81 public override IAsyncResult
BeginRead (byte [] buffer
, int offset
, int count
,
82 AsyncCallback cback
, object state
)
84 return deflateStream
.BeginRead (buffer
, offset
, count
, cback
, state
);
87 public override IAsyncResult
BeginWrite (byte [] buffer
, int offset
, int count
,
88 AsyncCallback cback
, object state
)
90 return deflateStream
.BeginWrite (buffer
, offset
, count
, cback
, state
);
93 public override int EndRead(IAsyncResult async_result
) {
94 return deflateStream
.EndRead (async_result
);
97 public override void EndWrite (IAsyncResult async_result
)
99 deflateStream
.EndWrite (async_result
);
102 public Stream BaseStream
{
104 return deflateStream
.BaseStream
;
107 public override bool CanRead
{
109 return deflateStream
.CanRead
;
112 public override bool CanSeek
{
114 return deflateStream
.CanSeek
;
117 public override bool CanWrite
{
119 return deflateStream
.CanWrite
;
122 public override long Length
{
124 return deflateStream
.Length
;
127 public override long Position
{
129 return deflateStream
.Position
;
132 deflateStream
.Position
= value;