mirror of
https://git.naxdy.org/Mirror/Ryujinx.git
synced 2024-11-15 09:35:27 +00:00
29 lines
775 B
C#
29 lines
775 B
C#
|
using System;
|
|||
|
using System.IO;
|
|||
|
using System.Runtime.InteropServices;
|
|||
|
|
|||
|
namespace Ryujinx.Common
|
|||
|
{
|
|||
|
public static class BinaryWriterExtensions
|
|||
|
{
|
|||
|
public unsafe static void WriteStruct<T>(this BinaryWriter writer, T value)
|
|||
|
where T : unmanaged
|
|||
|
{
|
|||
|
ReadOnlySpan<byte> data = MemoryMarshal.Cast<T, byte>(MemoryMarshal.CreateReadOnlySpan(ref value, 1));
|
|||
|
|
|||
|
writer.Write(data);
|
|||
|
}
|
|||
|
|
|||
|
public static void Write(this BinaryWriter writer, UInt128 value)
|
|||
|
{
|
|||
|
writer.Write((ulong)value);
|
|||
|
writer.Write((ulong)(value >> 64));
|
|||
|
}
|
|||
|
|
|||
|
public static void Write(this BinaryWriter writer, MemoryStream stream)
|
|||
|
{
|
|||
|
stream.CopyTo(writer.BaseStream);
|
|||
|
}
|
|||
|
}
|
|||
|
}
|