2020-07-15 04:20:56 +00:00
|
|
|
<#@ template language="C#" #>
|
|
|
|
<#@ assembly name="System.Core" #>
|
|
|
|
|
|
|
|
<#
|
2020-09-02 22:14:56 +00:00
|
|
|
byte[] StringToByteArray(string hex)
|
|
|
|
{
|
|
|
|
return Enumerable.Range(0, hex.Length)
|
|
|
|
.Where(x => x % 2 == 0)
|
|
|
|
.Select(x => Convert.ToByte(hex.Substring(x, 2), 16))
|
|
|
|
.ToArray();
|
2020-07-15 04:20:56 +00:00
|
|
|
}
|
|
|
|
|
2021-10-23 16:51:17 +00:00
|
|
|
var files = new[] {"bsasigs.txt", "file_sigs_RAW.txt"};
|
2020-07-15 04:20:56 +00:00
|
|
|
var digits = new HashSet<char>("0123456789".ToArray());
|
|
|
|
var rows = files
|
|
|
|
.SelectMany(file => File.ReadAllLines(Path.Combine("./Definitions/", file)))
|
|
|
|
.Select(row => row.Split(','))
|
|
|
|
.SelectMany(row => row[2].Split('|').Select(e => new
|
|
|
|
{
|
|
|
|
EnumName = (digits.Contains(e.First()) ? "_" + e : e).Replace(".", ""),
|
2021-09-27 12:42:46 +00:00
|
|
|
Sig = row[1].Trim().Split(' ').Select(b => "0x" + b),
|
2020-07-15 04:20:56 +00:00
|
|
|
Description = row[0]
|
|
|
|
}));
|
2021-09-27 12:42:46 +00:00
|
|
|
#>
|
2020-07-15 04:20:56 +00:00
|
|
|
namespace Wabbajack.Common.FileSignatures {
|
|
|
|
|
2021-09-27 12:42:46 +00:00
|
|
|
public enum FileType { <#
|
|
|
|
foreach (var nrow in rows.Select(r => r.EnumName).Distinct().OrderBy(r => r))
|
|
|
|
{
|
|
|
|
#>
|
2020-07-15 04:20:56 +00:00
|
|
|
<#= nrow #>,
|
2021-09-27 12:42:46 +00:00
|
|
|
<#
|
2020-07-15 04:20:56 +00:00
|
|
|
}
|
2021-09-27 12:42:46 +00:00
|
|
|
#>
|
|
|
|
}
|
|
|
|
|
|
|
|
public static class Definitions {
|
|
|
|
|
2020-07-15 04:20:56 +00:00
|
|
|
|
|
|
|
public static (FileType, byte[])[] Signatures = {
|
|
|
|
<#
|
2021-09-27 12:42:46 +00:00
|
|
|
foreach (var row in rows)
|
2020-07-15 04:20:56 +00:00
|
|
|
{
|
2021-09-27 12:42:46 +00:00
|
|
|
#>
|
2020-07-15 04:20:56 +00:00
|
|
|
// <#= row.Description #>
|
2021-09-27 12:42:46 +00:00
|
|
|
(FileType.<#= row.EnumName #>, new byte[] {<#= string.Join(", ", row.Sig) #>}),
|
2020-07-15 04:20:56 +00:00
|
|
|
|
|
|
|
<#
|
|
|
|
}
|
|
|
|
#>
|
|
|
|
|
|
|
|
};}}
|