skyscraper8/skyscraper8/Skyscraper/ByteArrayExtensions.cs
2025-06-21 20:57:07 +02:00

32 lines
740 B
C#

using skyscraper5.Skyscraper.Plugins;
namespace skyscraper5.Skyscraper
{
internal static class ByteArrayExtensions
{
private static ByteArrayComparer _comparer;
public static bool IsEqual(this byte[] a, byte[] b)
{
if (_comparer == null)
_comparer = new ByteArrayComparer();
return _comparer.Compare(a, b) == 0;
}
//geklaut aus yo3explorers CD-I Treiber
public static void FlipEndian(this byte[] data)
{
if (data.Length % 2 == 1)
throw new InvalidDataException(); //Überprüfe: Ist das überhaupt eine Zahl ?
byte temp;
for (int i = 0; i < (data.Length / 2); i++)
{
temp = data[i];
data[i] = data[data.Length - i - 1];
data[data.Length - i - 1] = temp;
}
}
}
}