2019-01-05 22:26:16 +01:00
|
|
|
|
using System;
|
|
|
|
|
using System.IO;
|
2022-11-24 15:26:29 +01:00
|
|
|
|
using System.Runtime.CompilerServices;
|
2019-01-05 22:26:16 +01:00
|
|
|
|
using System.Runtime.InteropServices;
|
|
|
|
|
|
|
|
|
|
namespace Ryujinx.Common
|
|
|
|
|
{
|
2019-02-11 13:00:32 +01:00
|
|
|
|
public static class BinaryReaderExtensions
|
2019-01-05 22:26:16 +01:00
|
|
|
|
{
|
2019-02-11 13:00:32 +01:00
|
|
|
|
public unsafe static T ReadStruct<T>(this BinaryReader reader)
|
2022-11-24 15:26:29 +01:00
|
|
|
|
where T : unmanaged
|
2019-01-05 22:26:16 +01:00
|
|
|
|
{
|
2022-11-24 15:26:29 +01:00
|
|
|
|
return MemoryMarshal.Cast<byte, T>(reader.ReadBytes(Unsafe.SizeOf<T>()))[0];
|
2019-06-27 13:11:51 +02:00
|
|
|
|
}
|
2019-01-05 22:26:16 +01:00
|
|
|
|
}
|
|
|
|
|
}
|