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

◆ ReadAllBytesUnknownLength()

static byte[] System.IO.File.ReadAllBytesUnknownLength ( FileStream fs)
inlinestaticprivate

Definition at line 1015 of file File.cs.

1016 {
1017 byte[] array = null;
1018 Span<byte> span = stackalloc byte[512];
1019 try
1020 {
1021 int num = 0;
1022 while (true)
1023 {
1024 if (num == span.Length)
1025 {
1026 uint num2 = (uint)(span.Length * 2);
1027 if (num2 > Array.MaxLength)
1028 {
1029 num2 = (uint)Math.Max(Array.MaxLength, span.Length + 1);
1030 }
1031 byte[] array2 = ArrayPool<byte>.Shared.Rent((int)num2);
1033 byte[] array3 = array;
1034 span = (array = array2);
1035 if (array3 != null)
1036 {
1037 ArrayPool<byte>.Shared.Return(array3);
1038 }
1039 }
1040 int num3 = fs.Read(span.Slice(num));
1041 if (num3 == 0)
1042 {
1043 break;
1044 }
1045 num += num3;
1046 }
1047 return span.Slice(0, num).ToArray();
1048 }
1049 finally
1050 {
1051 if (array != null)
1052 {
1053 ArrayPool<byte>.Shared.Return(array);
1054 }
1055 }
1056 }
void CopyTo(KeyValuePair< TKey, TValue >[] array, int index)

References System.array, System.Collections.Generic.Dictionary< TKey, TValue >.CopyTo(), System.Math.Max(), and System.Array.MaxLength.

Referenced by System.IO.File.ReadAllBytes().