Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches
DerivedFileStreamStrategy.cs
Go to the documentation of this file.
4
6
8{
9 private readonly FileStreamStrategy _strategy;
10
11 private readonly FileStream _fileStream;
12
13 public override bool CanRead => _strategy.CanRead;
14
15 public override bool CanWrite => _strategy.CanWrite;
16
17 public override bool CanSeek => _strategy.CanSeek;
18
19 public override long Length => _strategy.Length;
20
21 public override long Position
22 {
23 get
24 {
25 return _strategy.Position;
26 }
27 set
28 {
29 _strategy.Position = value;
30 }
31 }
32
33 internal override bool IsAsync => _strategy.IsAsync;
34
35 internal override string Name => _strategy.Name;
36
38 {
39 get
40 {
41 _fileStream.Flush(flushToDisk: false);
43 }
44 }
45
46 internal override bool IsClosed => _strategy.IsClosed;
47
49 {
50 _fileStream = fileStream;
51 _strategy = strategy;
52 }
53
55 {
56 _fileStream.DisposeInternal(disposing: false);
57 }
58
59 internal override void Lock(long position, long length)
60 {
61 _strategy.Lock(position, length);
62 }
63
64 internal override void Unlock(long position, long length)
65 {
66 _strategy.Unlock(position, length);
67 }
68
69 public override long Seek(long offset, SeekOrigin origin)
70 {
71 return _strategy.Seek(offset, origin);
72 }
73
74 public override void SetLength(long value)
75 {
77 }
78
79 public override int ReadByte()
80 {
81 return _strategy.ReadByte();
82 }
83
84 public override IAsyncResult BeginRead(byte[] buffer, int offset, int count, AsyncCallback callback, object state)
85 {
86 if (!_strategy.IsAsync)
87 {
88 return _fileStream.BaseBeginRead(buffer, offset, count, callback, state);
89 }
90 return _strategy.BeginRead(buffer, offset, count, callback, state);
91 }
92
93 public override int EndRead(IAsyncResult asyncResult)
94 {
95 if (!_strategy.IsAsync)
96 {
98 }
100 }
101
102 public override int Read(byte[] buffer, int offset, int count)
103 {
104 return _strategy.Read(buffer, offset, count);
105 }
106
107 public override int Read(Span<byte> buffer)
108 {
110 }
111
116
121
122 public override IAsyncResult BeginWrite(byte[] buffer, int offset, int count, AsyncCallback callback, object state)
123 {
124 if (!_strategy.IsAsync)
125 {
126 return _fileStream.BaseBeginWrite(buffer, offset, count, callback, state);
127 }
128 return _strategy.BeginWrite(buffer, offset, count, callback, state);
129 }
130
131 public override void EndWrite(IAsyncResult asyncResult)
132 {
133 if (_strategy.IsAsync)
134 {
136 }
137 else
138 {
140 }
141 }
142
143 public override void WriteByte(byte value)
144 {
146 }
147
148 public override void Write(byte[] buffer, int offset, int count)
149 {
151 }
152
153 public override void Write(ReadOnlySpan<byte> buffer)
154 {
156 }
157
162
167
168 public override void Flush()
169 {
170 throw new InvalidOperationException("FileStream should never call this method.");
171 }
172
173 internal override void Flush(bool flushToDisk)
174 {
175 _strategy.Flush(flushToDisk);
176 }
177
182
184 {
186 }
187
188 public override ValueTask DisposeAsync()
189 {
191 }
192
193 internal override void DisposeInternal(bool disposing)
194 {
195 _strategy.DisposeInternal(disposing);
196 if (disposing)
197 {
198 GC.SuppressFinalize(this);
199 }
200 }
201}
static void SuppressFinalize(object obj)
Definition GC.cs:202
Definition GC.cs:8
int BaseEndRead(IAsyncResult asyncResult)
Task BaseCopyToAsync(Stream destination, int bufferSize, CancellationToken cancellationToken)
int BaseRead(Span< byte > buffer)
void DisposeInternal(bool disposing)
override void Flush()
void BaseWrite(ReadOnlySpan< byte > buffer)
ValueTask BaseDisposeAsync()
Task< int > BaseReadAsync(byte[] buffer, int offset, int count, CancellationToken cancellationToken)
Task BaseFlushAsync(CancellationToken cancellationToken)
Task BaseWriteAsync(byte[] buffer, int offset, int count, CancellationToken cancellationToken)
IAsyncResult BaseBeginRead(byte[] buffer, int offset, int count, AsyncCallback callback, object state)
void BaseEndWrite(IAsyncResult asyncResult)
IAsyncResult BaseBeginWrite(byte[] buffer, int offset, int count, AsyncCallback callback, object state)
override void Write(byte[] buffer, int offset, int count)
override ValueTask WriteAsync(ReadOnlyMemory< byte > buffer, CancellationToken cancellationToken=default(CancellationToken))
override void EndWrite(IAsyncResult asyncResult)
override int EndRead(IAsyncResult asyncResult)
override Task< int > ReadAsync(byte[] buffer, int offset, int count, CancellationToken cancellationToken)
override Task CopyToAsync(Stream destination, int bufferSize, CancellationToken cancellationToken)
override int Read(byte[] buffer, int offset, int count)
override IAsyncResult BeginRead(byte[] buffer, int offset, int count, AsyncCallback callback, object state)
DerivedFileStreamStrategy(FileStream fileStream, FileStreamStrategy strategy)
override void Lock(long position, long length)
override void Unlock(long position, long length)
override long Seek(long offset, SeekOrigin origin)
override IAsyncResult BeginWrite(byte[] buffer, int offset, int count, AsyncCallback callback, object state)
override ValueTask< int > ReadAsync(Memory< byte > buffer, CancellationToken cancellationToken=default(CancellationToken))
override Task FlushAsync(CancellationToken cancellationToken)
override void Write(ReadOnlySpan< byte > buffer)
override Task WriteAsync(byte[] buffer, int offset, int count, CancellationToken cancellationToken)
void Unlock(long position, long length)
void Lock(long position, long length)
virtual int ReadByte()
Definition Stream.cs:994
void SetLength(long value)
long Seek(long offset, SeekOrigin origin)
virtual void EndWrite(IAsyncResult asyncResult)
Definition Stream.cs:889
int Read(byte[] buffer, int offset, int count)
void Write(byte[] buffer, int offset, int count)
virtual IAsyncResult BeginRead(byte[] buffer, int offset, int count, AsyncCallback? callback, object? state)
Definition Stream.cs:688
virtual void WriteByte(byte value)
Definition Stream.cs:1020
virtual IAsyncResult BeginWrite(byte[] buffer, int offset, int count, AsyncCallback? callback, object? state)
Definition Stream.cs:813
virtual int EndRead(IAsyncResult asyncResult)
Definition Stream.cs:737