forked from Mirror/Ryujinx
2989c163a8
* editorconfig: Add default charset * Change file encoding from UTF-8-BOM to UTF-8
29 lines
744 B
C#
29 lines
744 B
C#
using Ryujinx.Common.Memory;
|
|
using System.IO;
|
|
using System.Threading;
|
|
using System.Threading.Tasks;
|
|
|
|
namespace Ryujinx.Common.Utilities
|
|
{
|
|
public static class StreamUtils
|
|
{
|
|
public static byte[] StreamToBytes(Stream input)
|
|
{
|
|
using MemoryStream stream = MemoryStreamManager.Shared.GetStream();
|
|
|
|
|
|
input.CopyTo(stream);
|
|
|
|
return stream.ToArray();
|
|
}
|
|
|
|
public static async Task<byte[]> StreamToBytesAsync(Stream input, CancellationToken cancellationToken = default)
|
|
{
|
|
using MemoryStream stream = MemoryStreamManager.Shared.GetStream();
|
|
|
|
await input.CopyToAsync(stream, cancellationToken);
|
|
|
|
return stream.ToArray();
|
|
}
|
|
}
|
|
}
|