Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches
ConsoleStream.cs
Go to the documentation of this file.
2
3namespace System.IO;
4
5internal abstract class ConsoleStream : Stream
6{
7 private bool _canRead;
8
9 private bool _canWrite;
10
11 public sealed override bool CanRead => _canRead;
12
13 public sealed override bool CanWrite => _canWrite;
14
15 public sealed override bool CanSeek => false;
16
17 public sealed override long Length
18 {
19 get
20 {
22 }
23 }
24
25 public sealed override long Position
26 {
27 get
28 {
30 }
31 set
32 {
34 }
35 }
36
37 internal ConsoleStream(FileAccess access)
38 {
39 _canRead = (access & FileAccess.Read) == FileAccess.Read;
40 _canWrite = (access & FileAccess.Write) == FileAccess.Write;
41 }
42
43 public override void Write(byte[] buffer, int offset, int count)
44 {
47 }
48
49 public override void WriteByte(byte value)
50 {
51 Write(MemoryMarshal.CreateReadOnlySpan(ref value, 1));
52 }
53
54 public override int Read(byte[] buffer, int offset, int count)
55 {
57 return Read(new Span<byte>(buffer, offset, count));
58 }
59
60 public override int ReadByte()
61 {
62 byte reference = 0;
63 if (Read(MemoryMarshal.CreateSpan(ref reference, 1)) == 0)
64 {
65 return -1;
66 }
67 return reference;
68 }
69
70 protected override void Dispose(bool disposing)
71 {
72 _canRead = false;
73 _canWrite = false;
74 base.Dispose(disposing);
75 }
76
77 public override void Flush()
78 {
79 if (!CanWrite)
80 {
82 }
83 }
84
85 public sealed override void SetLength(long value)
86 {
88 }
89
90 public sealed override long Seek(long offset, SeekOrigin origin)
91 {
93 }
94
95 protected void ValidateRead(byte[] buffer, int offset, int count)
96 {
98 if (!_canRead)
99 {
101 }
102 }
103
104 protected void ValidateWrite(byte[] buffer, int offset, int count)
105 {
107 if (!_canWrite)
108 {
110 }
111 }
112}
void ValidateRead(byte[] buffer, int offset, int count)
override void SetLength(long value)
ConsoleStream(FileAccess access)
override long Seek(long offset, SeekOrigin origin)
override void Write(byte[] buffer, int offset, int count)
override int ReadByte()
override void WriteByte(byte value)
override int Read(byte[] buffer, int offset, int count)
override void Flush()
override void Dispose(bool disposing)
void ValidateWrite(byte[] buffer, int offset, int count)
static Exception GetReadNotSupported()
Definition Error.cs:10
static Exception GetWriteNotSupported()
Definition Error.cs:20
static Exception GetSeekNotSupported()
Definition Error.cs:15
static void ValidateBufferArguments(byte[] buffer, int offset, int count)
Definition Stream.cs:1044