Facilitate the merge
[mono.git] / mcs / class / System / System.IO.Compression / GZipStream.cs
1 /* -*- Mode: csharp; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
2 // 
3 // GZipStream.cs
4 //
5 // Authors:
6 //      Christopher James Lahey <clahey@ximian.com>
7 //
8 // Copyright (C) 2004-2005 Novell, Inc (http://www.novell.com)
9 //
10 //
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:
18 // 
19 // The above copyright notice and this permission notice shall be
20 // included in all copies or substantial portions of the Software.
21 // 
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.
29 //
30
31 #if NET_2_0
32 using System;
33 using System.IO;
34 using System.Runtime.InteropServices;
35 using System.Runtime.Remoting.Messaging;
36
37 namespace System.IO.Compression {
38
39         public class GZipStream : Stream
40         {
41                 private DeflateStream deflateStream;
42
43                 public GZipStream (Stream compressedStream, CompressionMode mode) :
44                         this (compressedStream, mode, false) {
45                 }
46
47                 public GZipStream (Stream compressedStream, CompressionMode mode, bool leaveOpen) {
48                         this.deflateStream = new DeflateStream (compressedStream, mode, leaveOpen, true);
49                 }
50
51                 protected override void Dispose (bool disposing)
52                 {
53                         if (disposing)
54                                 deflateStream.Dispose ();
55                         base.Dispose (disposing);
56                 }
57
58                 public override int Read (byte[] dest, int dest_offset, int count)
59                 {
60                         return deflateStream.Read(dest, dest_offset, count);
61                 }
62
63
64                 public override void Write (byte[] src, int src_offset, int count)
65                 {
66                         deflateStream.Write (src, src_offset, count);
67                 }
68
69                 public override void Flush() {
70                         deflateStream.Flush();
71                 }
72
73                 public override long Seek (long offset, SeekOrigin origin) {
74                         return deflateStream.Seek (offset, origin);
75                 }
76
77                 public override void SetLength (long value) {
78                         deflateStream.SetLength (value);
79                 }
80
81                 public override IAsyncResult BeginRead (byte [] buffer, int offset, int count,
82                                                         AsyncCallback cback, object state)
83                 {
84                         return deflateStream.BeginRead (buffer, offset, count, cback, state);
85                 }
86
87                 public override IAsyncResult BeginWrite (byte [] buffer, int offset, int count,
88                                                         AsyncCallback cback, object state)
89                 {
90                         return deflateStream.BeginWrite (buffer, offset, count, cback, state);
91                 }
92
93                 public override int EndRead(IAsyncResult async_result) {
94                         return deflateStream.EndRead (async_result);
95                 }
96
97                 public override void EndWrite (IAsyncResult async_result)
98                 {
99                         deflateStream.EndWrite (async_result);
100                 }
101
102                 public Stream BaseStream {
103                         get {
104                                 return deflateStream.BaseStream;
105                         }
106                 }
107                 public override bool CanRead {
108                         get {
109                                 return deflateStream.CanRead;
110                         }
111                 }
112                 public override bool CanSeek {
113                         get {
114                                 return deflateStream.CanSeek;
115                         }
116                 }
117                 public override bool CanWrite {
118                         get {
119                                 return deflateStream.CanWrite;
120                         }
121                 }
122                 public override long Length {
123                         get {
124                                 return deflateStream.Length;
125                         }
126                 }
127                 public override long Position {
128                         get {
129                                 return deflateStream.Position;
130                         }
131                         set {
132                                 deflateStream.Position = value;
133                         }
134                 }
135         }
136 }
137
138 #endif