Files
BinaryObjectScanner/BurnOutSharp/ProtectionType/SmartE.cs
Matt Nadareski 921292e077 Static list of content matchers
This also includes some more path matcher conversions that I couldn't reasonably split out
2021-03-23 09:52:09 -07:00

52 lines
1.6 KiB
C#

using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using BurnOutSharp.Matching;
namespace BurnOutSharp.ProtectionType
{
public class SmartE : IContentCheck, IPathCheck
{
/// <summary>
/// Set of all ContentMatchSets for this protection
/// </summary>
private static List<ContentMatchSet> contentMatchers = new List<ContentMatchSet>
{
// BITARTS
new ContentMatchSet(new byte?[] { 0x42, 0x49, 0x54, 0x41, 0x52, 0x54, 0x53 }, "SmartE"),
};
/// <inheritdoc/>
public string CheckContents(string file, byte[] fileContent, bool includePosition = false)
{
return MatchUtil.GetFirstMatch(file, fileContent, contentMatchers, includePosition);
}
/// <inheritdoc/>
public string CheckDirectoryPath(string path, IEnumerable<string> files)
{
// TODO: Verify if these are OR or AND
if (files.Any(f => Path.GetFileName(f).Equals("00001.TMP", StringComparison.OrdinalIgnoreCase))
|| files.Any(f => Path.GetFileName(f).Equals("00002.TMP", StringComparison.OrdinalIgnoreCase)))
{
return "SmartE";
}
return null;
}
/// <inheritdoc/>
public string CheckFilePath(string path)
{
if (Path.GetFileName(path).Equals("00001.TMP", StringComparison.OrdinalIgnoreCase)
|| Path.GetFileName(path).Equals("00002.TMP", StringComparison.OrdinalIgnoreCase))
{
return "SmartE";
}
return null;
}
}
}