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

◆ ReadBufferAsync()

async ValueTask< int > System.IO.StreamReader.ReadBufferAsync ( CancellationToken cancellationToken)
inlineprivateinherited

Definition at line 994 of file StreamReader.cs.

995 {
996 _charLen = 0;
997 _charPos = 0;
998 byte[] tmpByteBuffer = _byteBuffer;
999 Stream tmpStream = _stream;
1000 if (!_checkPreamble)
1001 {
1002 _byteLen = 0;
1003 }
1004 do
1005 {
1006 if (_checkPreamble)
1007 {
1008 int bytePos = _bytePos;
1009 int num = await tmpStream.ReadAsync(new Memory<byte>(tmpByteBuffer, bytePos, tmpByteBuffer.Length - bytePos), cancellationToken).ConfigureAwait(continueOnCapturedContext: false);
1010 if (num == 0)
1011 {
1012 if (_byteLen > 0)
1013 {
1014 _charLen += _decoder.GetChars(tmpByteBuffer, 0, _byteLen, _charBuffer, _charLen);
1015 _bytePos = 0;
1016 _byteLen = 0;
1017 }
1018 return _charLen;
1019 }
1020 _byteLen += num;
1021 }
1022 else
1023 {
1024 _byteLen = await tmpStream.ReadAsync(new Memory<byte>(tmpByteBuffer), cancellationToken).ConfigureAwait(continueOnCapturedContext: false);
1025 if (_byteLen == 0)
1026 {
1027 return _charLen;
1028 }
1029 }
1030 _isBlocked = _byteLen < tmpByteBuffer.Length;
1031 if (!IsPreamble())
1032 {
1033 if (_detectEncoding && _byteLen >= 2)
1034 {
1036 }
1037 _charLen += _decoder.GetChars(tmpByteBuffer, 0, _byteLen, _charBuffer, _charLen);
1038 }
1039 }
1040 while (_charLen == 0);
1041 return _charLen;
1042 }
readonly Stream _stream
readonly byte[] _byteBuffer
int GetChars(byte[] bytes, int byteIndex, int byteCount, char[] chars, int charIndex)

References System.IO.StreamReader._byteBuffer, System.IO.StreamReader._byteLen, System.IO.StreamReader._bytePos, System.IO.StreamReader._charBuffer, System.IO.StreamReader._charLen, System.IO.StreamReader._charPos, System.IO.StreamReader._checkPreamble, System.IO.StreamReader._decoder, System.IO.StreamReader._detectEncoding, System.IO.StreamReader._isBlocked, System.IO.StreamReader._stream, System.cancellationToken, System.Threading.Tasks.Task< TResult >.ConfigureAwait(), System.IO.StreamReader.DetectEncoding(), System.Text.Decoder.GetChars(), System.IO.StreamReader.IsPreamble(), and System.IO.Stream.ReadAsync().

Referenced by System.IO.StreamReader.ReadAsyncInternal(), System.IO.StreamReader.ReadLineAsyncInternal(), and System.IO.StreamReader.ReadToEndAsyncInternal().