mirror of
https://github.com/claunia/SabreTools.git
synced 2025-12-16 19:14:27 +00:00
Move one more method to better class
This commit is contained in:
@@ -11,5 +11,29 @@ namespace SabreTools.Core
|
|||||||
{
|
{
|
||||||
return array == null || array.Length == 0;
|
return array == null || array.Length == 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//// <summary>
|
||||||
|
/// Returns if the first byte array starts with the second array
|
||||||
|
/// </summary>
|
||||||
|
public static bool StartsWith(this byte[] arr1, byte[] arr2, bool exact = false)
|
||||||
|
{
|
||||||
|
// If we have any invalid inputs, we return false
|
||||||
|
if (arr1 == null || arr2 == null
|
||||||
|
|| arr1.Length == 0 || arr2.Length == 0
|
||||||
|
|| arr2.Length > arr1.Length
|
||||||
|
|| (exact && arr1.Length != arr2.Length))
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Otherwise, loop through and see
|
||||||
|
for (int i = 0; i < arr2.Length; i++)
|
||||||
|
{
|
||||||
|
if (arr1[i] != arr2[i])
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -111,33 +111,5 @@ namespace SabreTools.Core.Tools
|
|||||||
_ => false,
|
_ => false,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
//// <summary>
|
|
||||||
/// Returns if the first byte array starts with the second array
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="arr1">First byte array to compare</param>
|
|
||||||
/// <param name="arr2">Second byte array to compare</param>
|
|
||||||
/// <param name="exact">True if the input arrays should match exactly, false otherwise (default)</param>
|
|
||||||
/// <returns>True if the first byte array starts with the second, false otherwise</returns>
|
|
||||||
public static bool StartsWith(this byte[] arr1, byte[] arr2, bool exact = false)
|
|
||||||
{
|
|
||||||
// If we have any invalid inputs, we return false
|
|
||||||
if (arr1 == null || arr2 == null
|
|
||||||
|| arr1.Length == 0 || arr2.Length == 0
|
|
||||||
|| arr2.Length > arr1.Length
|
|
||||||
|| (exact && arr1.Length != arr2.Length))
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Otherwise, loop through and see
|
|
||||||
for (int i = 0; i < arr2.Length; i++)
|
|
||||||
{
|
|
||||||
if (arr1[i] != arr2[i])
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
|
using SabreTools.Core;
|
||||||
using SabreTools.Core.Tools;
|
|
||||||
using SabreTools.IO;
|
using SabreTools.IO;
|
||||||
|
|
||||||
namespace SabreTools.FileTypes.Aaru
|
namespace SabreTools.FileTypes.Aaru
|
||||||
|
|||||||
@@ -2,7 +2,6 @@
|
|||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
using SabreTools.Core;
|
using SabreTools.Core;
|
||||||
using SabreTools.Core.Tools;
|
using SabreTools.Core.Tools;
|
||||||
using SabreTools.FileTypes.Aaru;
|
using SabreTools.FileTypes.Aaru;
|
||||||
|
|||||||
Reference in New Issue
Block a user