Use content matching helper, part 1

This commit is contained in:
Matt Nadareski
2021-03-21 14:30:37 -07:00
parent 7c53eaab13
commit ab07eb96ce
35 changed files with 270 additions and 216 deletions

View File

@@ -10,12 +10,12 @@ namespace BurnOutSharp.ProtectionType
/// <inheritdoc/>
public string CheckContents(string file, byte[] fileContent, bool includePosition = false)
{
// "CD-Cops, ver. "
// CD-Cops, ver.
byte?[] check = new byte?[] { 0x43, 0x44, 0x2D, 0x43, 0x6F, 0x70, 0x73, 0x2C, 0x20, 0x20, 0x76, 0x65, 0x72, 0x2E, 0x20 };
if (fileContent.FirstPosition(check, out int position))
return $"CD-Cops {GetVersion(fileContent, position)}" + (includePosition ? $" (Index {position})" : string.Empty);
// ".grand" + (char)0x00
// .grand + (char)0x00
check = new byte?[] { 0x2E, 0x67, 0x72, 0x61, 0x6E, 0x64, 0x00};
if (fileContent.FirstPosition(check, out position))
return "CD-Cops" + (includePosition ? $" (Index {position})" : string.Empty);