# HG changeset patch # User IBBoard # Date 1354134100 0 # Node ID 9131bc46903e3989fe4fcfdb3754d54c8f1f4c4f # Parent 780169621672c239e1c7c21d0421d443ea5389a1 * Add NamedStream wrapper class to support warfoundry:#419 diff -r 780169621672 -r 9131bc46903e IBBoard.csproj --- a/IBBoard.csproj Tue Nov 06 20:51:49 2012 +0000 +++ b/IBBoard.csproj Wed Nov 28 20:21:40 2012 +0000 @@ -158,6 +158,7 @@ + diff -r 780169621672 -r 9131bc46903e IO/NamedStream.cs --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/IO/NamedStream.cs Wed Nov 28 20:21:40 2012 +0000 @@ -0,0 +1,88 @@ +// This file (NamedStream.cs) is a part of the IBBoard project and is copyright 2012 IBBoard +// +// The file and the library/program it is in are licensed and distributed, without warranty, under the GNU LGPL, either version 3 of the License or (at your option) any later version. Please see COPYING for more information and the full license. +using System; +using System.IO; + +namespace IBBoard.IO +{ + /// + /// A wrapper class to allow naming of unnamed streams (e.g. memory streams). All Stream functions + /// are invoked on the provided stream. + /// + public class NamedStream : Stream + { + private Stream stream; + + public NamedStream(string name, Stream stream) + { + this.Name = name; + this.stream = stream; + } + + public string Name { get; set; } + + #region implemented abstract members of Stream + public override void Flush() + { + stream.Flush(); + } + public override int Read(byte[] buffer, int offset, int count) + { + return stream.Read(buffer, offset, count); + } + public override long Seek(long offset, SeekOrigin origin) + { + return stream.Seek(offset, origin); + } + public override void SetLength(long value) + { + stream.SetLength(value); + } + public override void Write(byte[] buffer, int offset, int count) + { + stream.Write(buffer, offset, count); + } + public override bool CanRead + { + get + { + return stream.CanRead; + } + } + public override bool CanSeek + { + get + { + return stream.CanSeek; + } + } + public override bool CanWrite + { + get + { + return stream.CanWrite; + } + } + public override long Length + { + get + { + return stream.Length; + } + } + public override long Position + { + get + { + return stream.Position; + } + set + { + stream.Position = value; + } + } + #endregion + } +} +