mirror of
https://github.com/TalAloni/SMBLibrary.git
synced 2025-05-28 16:29:51 +02:00
Added stream related methods to LittleEndianWriter.cs
This commit is contained in:
parent
ecce6f9311
commit
4c3d3b542f
1 changed files with 38 additions and 20 deletions
|
@ -11,18 +11,6 @@ namespace Utilities
|
|||
{
|
||||
public class LittleEndianWriter
|
||||
{
|
||||
public static void WriteUInt16(byte[] buffer, int offset, ushort value)
|
||||
{
|
||||
byte[] bytes = LittleEndianConverter.GetBytes(value);
|
||||
Array.Copy(bytes, 0, buffer, offset, bytes.Length);
|
||||
}
|
||||
|
||||
public static void WriteUInt16(byte[] buffer, ref int offset, ushort value)
|
||||
{
|
||||
WriteUInt16(buffer, offset, value);
|
||||
offset += 2;
|
||||
}
|
||||
|
||||
public static void WriteInt16(byte[] buffer, int offset, short value)
|
||||
{
|
||||
byte[] bytes = LittleEndianConverter.GetBytes(value);
|
||||
|
@ -35,16 +23,16 @@ namespace Utilities
|
|||
offset += 2;
|
||||
}
|
||||
|
||||
public static void WriteUInt32(byte[] buffer, int offset, uint value)
|
||||
public static void WriteUInt16(byte[] buffer, int offset, ushort value)
|
||||
{
|
||||
byte[] bytes = LittleEndianConverter.GetBytes(value);
|
||||
Array.Copy(bytes, 0, buffer, offset, bytes.Length);
|
||||
}
|
||||
|
||||
public static void WriteUInt32(byte[] buffer, ref int offset, uint value)
|
||||
public static void WriteUInt16(byte[] buffer, ref int offset, ushort value)
|
||||
{
|
||||
WriteUInt32(buffer, offset, value);
|
||||
offset += 4;
|
||||
WriteUInt16(buffer, offset, value);
|
||||
offset += 2;
|
||||
}
|
||||
|
||||
public static void WriteInt32(byte[] buffer, int offset, int value)
|
||||
|
@ -59,16 +47,16 @@ namespace Utilities
|
|||
offset += 4;
|
||||
}
|
||||
|
||||
public static void WriteUInt64(byte[] buffer, int offset, ulong value)
|
||||
public static void WriteUInt32(byte[] buffer, int offset, uint value)
|
||||
{
|
||||
byte[] bytes = LittleEndianConverter.GetBytes(value);
|
||||
Array.Copy(bytes, 0, buffer, offset, bytes.Length);
|
||||
}
|
||||
|
||||
public static void WriteUInt64(byte[] buffer, ref int offset, ulong value)
|
||||
public static void WriteUInt32(byte[] buffer, ref int offset, uint value)
|
||||
{
|
||||
WriteUInt64(buffer, offset, value);
|
||||
offset += 8;
|
||||
WriteUInt32(buffer, offset, value);
|
||||
offset += 4;
|
||||
}
|
||||
|
||||
public static void WriteInt64(byte[] buffer, int offset, long value)
|
||||
|
@ -83,6 +71,18 @@ namespace Utilities
|
|||
offset += 8;
|
||||
}
|
||||
|
||||
public static void WriteUInt64(byte[] buffer, int offset, ulong value)
|
||||
{
|
||||
byte[] bytes = LittleEndianConverter.GetBytes(value);
|
||||
Array.Copy(bytes, 0, buffer, offset, bytes.Length);
|
||||
}
|
||||
|
||||
public static void WriteUInt64(byte[] buffer, ref int offset, ulong value)
|
||||
{
|
||||
WriteUInt64(buffer, offset, value);
|
||||
offset += 8;
|
||||
}
|
||||
|
||||
public static void WriteGuid(byte[] buffer, int offset, Guid value)
|
||||
{
|
||||
byte[] bytes = LittleEndianConverter.GetBytes(value);
|
||||
|
@ -95,6 +95,12 @@ namespace Utilities
|
|||
offset += 16;
|
||||
}
|
||||
|
||||
public static void WriteInt16(Stream stream, short value)
|
||||
{
|
||||
byte[] bytes = LittleEndianConverter.GetBytes(value);
|
||||
stream.Write(bytes, 0, bytes.Length);
|
||||
}
|
||||
|
||||
public static void WriteUInt16(Stream stream, ushort value)
|
||||
{
|
||||
byte[] bytes = LittleEndianConverter.GetBytes(value);
|
||||
|
@ -112,5 +118,17 @@ namespace Utilities
|
|||
byte[] bytes = LittleEndianConverter.GetBytes(value);
|
||||
stream.Write(bytes, 0, bytes.Length);
|
||||
}
|
||||
|
||||
public static void WriteInt64(Stream stream, long value)
|
||||
{
|
||||
byte[] bytes = LittleEndianConverter.GetBytes(value);
|
||||
stream.Write(bytes, 0, bytes.Length);
|
||||
}
|
||||
|
||||
public static void WriteUInt64(Stream stream, ulong value)
|
||||
{
|
||||
byte[] bytes = LittleEndianConverter.GetBytes(value);
|
||||
stream.Write(bytes, 0, bytes.Length);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue