Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
58 changes: 58 additions & 0 deletions src/System.IO.Abstractions/FileStream.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
namespace System.IO.Abstractions
{
/// <summary>
/// A <see cref="Stream"/> that has properties similar to <see cref="System.IO.FileStream"/>
/// </summary>
public class FileStream : Stream
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we should use another name for this to prevent conflicts with System.IO.FileStream.

I don't have a good idea, maybe FileStreamBase to mirror other types here?

{
private readonly Stream _wrappedStream;

/// <summary>
/// Constructor for <see cref="FileStream"/>
/// </summary>
/// <param name="wrappedStream">The underlying wrapped <see cref="Stream"/></param>
/// <param name="name">The name of the underlying stream object</param>
public FileStream(Stream wrappedStream, string name)
{
_wrappedStream = wrappedStream;

Name = name;
}

/// <summary>
/// Name of the underlying stream object.
/// See <see cref="System.IO.FileStream.Name"/>
/// </summary>
public string Name { get; }

/// <inheritdoc />
public override bool CanRead => _wrappedStream.CanRead;

/// <inheritdoc />
public override bool CanSeek => _wrappedStream.CanSeek;

/// <inheritdoc />
public override bool CanWrite => _wrappedStream.CanWrite;

/// <inheritdoc />
public override long Length => _wrappedStream.Length;

/// <inheritdoc />
public override long Position { get => _wrappedStream.Position; set => _wrappedStream.Position = value; }

/// <inheritdoc />
public override void Flush() => _wrappedStream.Flush();

/// <inheritdoc />
public override int Read(byte[] buffer, int offset, int count) => _wrappedStream.Read(buffer, offset, count);

/// <inheritdoc />
public override long Seek(long offset, SeekOrigin origin) => _wrappedStream.Seek(offset, origin);

/// <inheritdoc />
public override void SetLength(long value) => _wrappedStream.SetLength(value);

/// <inheritdoc />
public override void Write(byte[] buffer, int offset, int count) => _wrappedStream.Write(buffer, offset, count);
}
}