|
| 1 | +namespace System.IO.Abstractions |
| 2 | +{ |
| 3 | + /// <summary> |
| 4 | + /// A <see cref="Stream"/> that has properties similar to <see cref="System.IO.FileStream"/> |
| 5 | + /// </summary> |
| 6 | + public class FileStream : Stream |
| 7 | + { |
| 8 | + private readonly Stream _wrappedStream; |
| 9 | + |
| 10 | + /// <summary> |
| 11 | + /// Constructor for <see cref="FileStream"/> |
| 12 | + /// </summary> |
| 13 | + /// <param name="wrappedStream">The underlying wrapped <see cref="Stream"/></param> |
| 14 | + /// <param name="name">The name of the underlying stream object</param> |
| 15 | + public FileStream(Stream wrappedStream, string name) |
| 16 | + { |
| 17 | + _wrappedStream = wrappedStream; |
| 18 | + |
| 19 | + Name = name; |
| 20 | + } |
| 21 | + |
| 22 | + /// <summary> |
| 23 | + /// Name of the underlying stream object. |
| 24 | + /// See <see cref="System.IO.FileStream.Name"/> |
| 25 | + /// </summary> |
| 26 | + public string Name { get; } |
| 27 | + |
| 28 | + /// <inheritdoc /> |
| 29 | + public override bool CanRead => _wrappedStream.CanRead; |
| 30 | + |
| 31 | + /// <inheritdoc /> |
| 32 | + public override bool CanSeek => _wrappedStream.CanSeek; |
| 33 | + |
| 34 | + /// <inheritdoc /> |
| 35 | + public override bool CanWrite => _wrappedStream.CanWrite; |
| 36 | + |
| 37 | + /// <inheritdoc /> |
| 38 | + public override long Length => _wrappedStream.Length; |
| 39 | + |
| 40 | + /// <inheritdoc /> |
| 41 | + public override long Position { get => _wrappedStream.Position; set => _wrappedStream.Position = value; } |
| 42 | + |
| 43 | + /// <inheritdoc /> |
| 44 | + public override void Flush() => _wrappedStream.Flush(); |
| 45 | + |
| 46 | + /// <inheritdoc /> |
| 47 | + public override int Read(byte[] buffer, int offset, int count) => _wrappedStream.Read(buffer, offset, count); |
| 48 | + |
| 49 | + /// <inheritdoc /> |
| 50 | + public override long Seek(long offset, SeekOrigin origin) => _wrappedStream.Seek(offset, origin); |
| 51 | + |
| 52 | + /// <inheritdoc /> |
| 53 | + public override void SetLength(long value) => _wrappedStream.SetLength(value); |
| 54 | + |
| 55 | + /// <inheritdoc /> |
| 56 | + public override void Write(byte[] buffer, int offset, int count) => _wrappedStream.Write(buffer, offset, count); |
| 57 | + } |
| 58 | +} |
0 commit comments