mirror of
https://github.com/riegera2412/UVtools.git
synced 2026-07-12 11:32:33 +02:00
45 lines
1.4 KiB
C#
45 lines
1.4 KiB
C#
/*
|
|
* GNU AFFERO GENERAL PUBLIC LICENSE
|
|
* Version 3, 19 November 2007
|
|
* Copyright (C) 2007 Free Software Foundation, Inc. <https://fsf.org/>
|
|
* Everyone is permitted to copy and distribute verbatim copies
|
|
* of this license document, but changing it is not allowed.
|
|
*/
|
|
|
|
using System.IO;
|
|
|
|
namespace UVtools.Core.Extensions
|
|
{
|
|
public static class FileStreamExtensions
|
|
{
|
|
public static uint ReadBytes(this FileStream fs, byte[] bytes, int offset = 0)
|
|
{
|
|
return (uint)fs.Read(bytes, offset, bytes.Length);
|
|
}
|
|
|
|
public static byte[] ReadBytes(this Stream stream)
|
|
{
|
|
byte[] buff = new byte[stream.Length];
|
|
stream.Read(buff, 0, buff.Length);
|
|
return buff;
|
|
}
|
|
|
|
public static uint WriteStream(this FileStream fs, MemoryStream stream, int offset = 0)
|
|
{
|
|
return fs.WriteBytes(stream.ToArray(), offset);
|
|
}
|
|
|
|
public static uint WriteBytes(this FileStream fs, byte[] bytes, int offset = 0)
|
|
{
|
|
fs.Write(bytes, offset, bytes.Length);
|
|
return (uint)bytes.Length;
|
|
}
|
|
|
|
public static uint WriteBytes(this Stream stream, byte[] bytes, int offset = 0)
|
|
{
|
|
stream.Write(bytes, offset, bytes.Length);
|
|
return (uint)bytes.Length;
|
|
}
|
|
}
|
|
}
|