-
Notifications
You must be signed in to change notification settings - Fork 256
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added draft implementation of a
FileStream
-like class. It is not pl…
…umbed in at all because I want to discuss the approach first.
- Loading branch information
Brian McBrayer
committed
Jan 8, 2022
1 parent
f46d7c4
commit e7c380e
Showing
1 changed file
with
58 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
{ | ||
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); | ||
} | ||
} |