wabbajack/Wabbajack.IO.Async/Extensions.cs
2022-02-05 08:47:15 -07:00

16 lines
441 B
C#

namespace Wabbajack.IO.Async;
public static class Extensions
{
public static async ValueTask ReadAllAsync(this Stream frm, Memory<byte> output)
{
var read = 0;
while (read < output.Length)
{
var thisRead = await frm.ReadAsync(output[read..]);
if (thisRead == 0)
throw new Exception("End of stream reached before limit");
read += thisRead;
}
}
}