1
0
mirror of synced 2025-01-19 01:14:08 +01:00

Some more fixes to magic checks

This commit is contained in:
KillzXGaming 2019-06-01 10:23:06 -04:00
parent 72ea6d0eb7
commit 7845840209
3 changed files with 12 additions and 2 deletions

Binary file not shown.

View File

@ -12,8 +12,18 @@ namespace Switch_Toolbox.Library.IO
//https://github.com/exelix11/EditorCore/blob/872d210f85ec0409f8a6ac3a12fc162aaf4cd90c/EditorCoreCommon/CustomClasses.cs#L367
public static bool Matches(this byte[] arr, string magic) =>
arr.Matches(0, magic.ToCharArray());
public static bool Matches(this byte[] arr, uint startIndex, string magic) =>
arr.Matches(startIndex, magic.ToCharArray());
public static bool Matches(this byte[] arr, uint magic) =>
arr.Matches(0, BitConverter.GetBytes(magic));
public static bool Matches(this byte[] arr, uint startIndex, params byte[] magic)
{
if (arr.Length < magic.Length + startIndex) return false;
for (uint i = 0; i < magic.Length; i++)
{
if (arr[i + startIndex] != magic[i]) return false;
}
return true;
}
public static bool Matches(this byte[] arr, uint startIndex, params char[] magic)
{