Rename MinecraftUSkinEditor -> PCK-Studio, PckStudio.Installer

-> `PCK-Studio.Installer` and rename solution
This commit is contained in:
miku-666
2022-08-11 21:08:18 +02:00
parent a78b2a1b8a
commit 768bdc4dc7
268 changed files with 1090 additions and 130 deletions

View File

@@ -0,0 +1,59 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace PckStudio.Classes.IO
{
public class StreamDataReader
{
private static bool useLittleEndian;
protected static bool IsUsingLittleEndian => useLittleEndian;
protected StreamDataReader(bool littleEndian)
{
useLittleEndian = littleEndian;
}
protected static string ReadString(Stream stream, int length, Encoding encoding)
{
byte[] buffer = ReadBytes(stream, length << Convert.ToInt32(encoding is UnicodeEncoding));
return encoding.GetString(buffer);
}
protected static byte[] ReadBytes(Stream stream, int count)
{
byte[] buffer = new byte[count];
stream.Read(buffer, 0, count);
return buffer;
}
protected static ushort ReadUShort(Stream stream) => (ushort)ReadShort(stream);
protected static short ReadShort(Stream stream)
{
byte[] bytes = ReadBytes(stream, 2);
if (BitConverter.IsLittleEndian && !useLittleEndian)
Array.Reverse(bytes);
return BitConverter.ToInt16(bytes, 0);
}
protected static uint ReadUInt(Stream stream) => (uint)ReadInt(stream);
protected static int ReadInt(Stream stream)
{
byte[] buffer = ReadBytes(stream, 4);
if (BitConverter.IsLittleEndian && !useLittleEndian)
Array.Reverse(buffer);
return BitConverter.ToInt32(buffer, 0);
}
protected static ulong ReadULong(Stream stream) => (ulong)ReadLong(stream);
protected static long ReadLong(Stream stream)
{
byte[] buffer = ReadBytes(stream, 8);
if (BitConverter.IsLittleEndian && !useLittleEndian)
Array.Reverse(buffer);
return BitConverter.ToInt64(buffer, 0);
}
}
}