diff options
Diffstat (limited to 'UVtools.Core/Extensions/FileStreamExtensions.cs')
-rw-r--r-- | UVtools.Core/Extensions/FileStreamExtensions.cs | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/UVtools.Core/Extensions/FileStreamExtensions.cs b/UVtools.Core/Extensions/FileStreamExtensions.cs index 02fba02..c9b530c 100644 --- a/UVtools.Core/Extensions/FileStreamExtensions.cs +++ b/UVtools.Core/Extensions/FileStreamExtensions.cs @@ -24,6 +24,9 @@ namespace UVtools.Core.Extensions return buffer; } + public static byte[] ReadBytes(this FileStream fs, uint length, int offset = 0) + => fs.ReadBytes((int)length, offset); + public static uint ReadUShortLittleEndian(this FileStream fs, int offset = 0) { return BitExtensions.ToUShortLittleEndian(fs.ReadBytes(2, offset)); @@ -44,6 +47,26 @@ namespace UVtools.Core.Extensions return BitExtensions.ToUIntBigEndian(fs.ReadBytes(4, offset)); } + public static void WriteUShortLittleEndian(this FileStream fs, ushort value, int offset = 0) + { + fs.WriteBytes(BitExtensions.ToBytesLittleEndian(value), offset); + } + + public static void WriteUShortBigEndian(this FileStream fs, ushort value, int offset = 0) + { + fs.WriteBytes(BitExtensions.ToBytesBigEndian(value), offset); + } + + public static void WriteUIntLittleEndian(this FileStream fs, uint value, int offset = 0) + { + fs.WriteBytes(BitExtensions.ToBytesLittleEndian(value), offset); + } + + public static void WriteUIntBigEndian(this FileStream fs, uint value, int offset = 0) + { + fs.WriteBytes(BitExtensions.ToBytesBigEndian(value), offset); + } + public static uint WriteStream(this FileStream fs, MemoryStream stream, int offset = 0) { return fs.WriteBytes(stream.ToArray(), offset); |