Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches

◆ Flush() [2/2]

void System.IO.StreamWriter.Flush ( bool flushStream,
bool flushEncoder )
inlineprivate

Definition at line 273 of file StreamWriter.cs.

274 {
276 if (_charPos == 0 && !flushStream && !flushEncoder)
277 {
278 return;
279 }
281 {
283 ReadOnlySpan<byte> preamble = _encoding.Preamble;
284 if (preamble.Length > 0)
285 {
286 _stream.Write(preamble);
287 }
288 }
289 Span<byte> span = default(Span<byte>);
290 if (_byteBuffer != null)
291 {
292 span = _byteBuffer;
293 }
294 else
295 {
296 int maxByteCount = _encoding.GetMaxByteCount(_charPos);
297 Span<byte> span2 = ((maxByteCount > 1024) ? ((Span<byte>)(_byteBuffer = new byte[_encoding.GetMaxByteCount(_charBuffer.Length)])) : stackalloc byte[1024]);
298 span = span2;
299 }
300 int bytes = _encoder.GetBytes(new ReadOnlySpan<char>(_charBuffer, 0, _charPos), span, flushEncoder);
301 _charPos = 0;
302 if (bytes > 0)
303 {
304 _stream.Write(span.Slice(0, bytes));
305 }
306 if (flushStream)
307 {
308 _stream.Flush();
309 }
310 }
readonly Stream _stream
readonly Encoder _encoder
readonly char[] _charBuffer
readonly Encoding _encoding
void Write(byte[] buffer, int offset, int count)
int GetBytes(char[] chars, int charIndex, int charCount, byte[] bytes, int byteIndex, bool flush)
virtual ReadOnlySpan< byte > Preamble
Definition Encoding.cs:347
int GetMaxByteCount(int charCount)

References System.IO.StreamWriter._byteBuffer, System.IO.StreamWriter._charBuffer, System.IO.StreamWriter._charPos, System.IO.StreamWriter._encoder, System.IO.StreamWriter._encoding, System.IO.StreamWriter._haveWrittenPreamble, System.IO.StreamWriter._stream, System.bytes, System.IO.Stream.Flush(), System.Text.Encoder.GetBytes(), System.Text.Encoding.GetMaxByteCount(), System.ReadOnlySpan< T >.Length, System.Text.Encoding.Preamble, System.Span< T >.Slice(), System.IO.StreamWriter.ThrowIfDisposed(), and System.IO.Stream.Write().