-
Notifications
You must be signed in to change notification settings - Fork 474
/
ForwardOnlyStream.cs
51 lines (37 loc) · 1.32 KB
/
ForwardOnlyStream.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
using System;
using System.IO;
namespace SharpCompress.Test.Mocks;
public class ForwardOnlyStream : Stream
{
private readonly Stream stream;
public bool IsDisposed { get; private set; }
public ForwardOnlyStream(Stream stream) => this.stream = stream;
protected override void Dispose(bool disposing)
{
if (!IsDisposed)
{
if (disposing)
{
stream.Dispose();
IsDisposed = true;
base.Dispose(disposing);
}
}
}
public override bool CanRead => true;
public override bool CanSeek => false;
public override bool CanWrite => false;
public override void Flush() { }
public override long Length => throw new NotSupportedException();
public override long Position
{
get => throw new NotSupportedException();
set => throw new NotSupportedException();
}
public override int Read(byte[] buffer, int offset, int count) =>
stream.Read(buffer, offset, count);
public override long Seek(long offset, SeekOrigin origin) => throw new NotSupportedException();
public override void SetLength(long value) => throw new NotSupportedException();
public override void Write(byte[] buffer, int offset, int count) =>
throw new NotSupportedException();
}