mirror of
https://github.com/wabbajack-tools/wabbajack.git
synced 2024-08-30 18:42:17 +00:00
16 lines
441 B
C#
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;
|
||
|
}
|
||
|
}
|
||
|
}
|