* Filters/FilterPackage.cs, Filters/FilterRPM.cs,
[beagle.git] / Util / UnclosableStream.cs
blob0026d49571771fdeb5affd1a95898cdba65bcc24
1 //
2 // UnclosableStream.cs
3 //
4 // Copyright (C) 2005 Novell, Inc.
5 //
7 //
8 // Permission is hereby granted, free of charge, to any person obtaining a copy
9 // of this software and associated documentation files (the "Software"), to deal
10 // in the Software without restriction, including without limitation the rights
11 // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
12 // copies of the Software, and to permit persons to whom the Software is
13 // furnished to do so, subject to the following conditions:
15 // The above copyright notice and this permission notice shall be included in all
16 // copies or substantial portions of the Software.
18 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19 // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20 // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
21 // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22 // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
23 // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
24 // SOFTWARE.
27 using System;
28 using System.IO;
30 namespace Beagle.Util {
32 public class UnclosableStream : Stream {
34 Stream base_stream;
35 bool close_was_called = false;
37 public UnclosableStream (Stream base_stream) : base ()
39 this.base_stream = base_stream;
42 public Stream BaseStream {
43 get { return base_stream; }
46 public bool CloseWasCalled {
47 get { return close_was_called; }
50 public override bool CanRead {
51 get { return base_stream.CanRead; }
54 public override bool CanWrite {
55 get { return base_stream.CanWrite; }
58 public override bool CanSeek {
59 get { return base_stream.CanSeek; }
62 public override long Length {
63 get { return base_stream.Length; }
66 public override long Position {
67 get { return base_stream.Position; }
68 set { base_stream.Position = value; }
71 public override void Close ()
73 base_stream.Flush ();
74 close_was_called = true;
77 public override void Flush ()
79 base_stream.Flush ();
82 public override int Read (byte [] buffer, int offset, int count)
84 return base_stream.Read (buffer, offset, count);
87 public override int ReadByte ()
89 return base_stream.ReadByte ();
92 public override long Seek (long offset, SeekOrigin origin)
94 return base_stream.Seek (offset, origin);
97 public override void SetLength (long value)
99 base_stream.SetLength (value);
102 public override void Write (byte [] buffer, int offset, int count)
104 base_stream.Write (buffer, offset, count);
107 public override void WriteByte (byte value)
109 base_stream.WriteByte (value);
112 public override IAsyncResult
113 BeginRead (byte [] buffer, int offset, int count, AsyncCallback cback, object state)
115 return base_stream.BeginRead (buffer, offset, count, cback, state);
118 public override IAsyncResult
119 BeginWrite (byte [] buffer, int offset, int count, AsyncCallback cback, object state)
121 return base_stream.BeginWrite (buffer, offset, count, cback, state);
124 public override int EndRead (IAsyncResult async_result)
126 return base_stream.EndRead (async_result);
129 public override void EndWrite (IAsyncResult async_result)
131 base_stream.EndWrite (async_result);