2020-07-15 04:20:56 +00:00
|
|
|
<#@ template language="C#" #>
|
|
|
|
<#@ assembly name="System.Core" #>
|
|
|
|
<#@ import namespace="System.Text" #>
|
|
|
|
<#@ import namespace="System.Collections.Generic" #>
|
|
|
|
<#@ import namespace="System.IO" #>
|
|
|
|
<#@ import namespace="System.Linq" #>
|
|
|
|
|
|
|
|
<#
|
|
|
|
|
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
|
|
|
}
|
|
|
|
|
|
|
|
var files = new string[] {"bsasigs.txt", "file_sigs_RAW.txt"};
|
|
|
|
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(".", ""),
|
|
|
|
Sig = row[1].Trim().Split(' ').Select(b => "0x"+b),
|
|
|
|
Description = row[0]
|
|
|
|
}));
|
|
|
|
#>
|
|
|
|
namespace Wabbajack.Common.FileSignatures {
|
|
|
|
public static class Definitions {
|
|
|
|
public enum FileType { <#
|
|
|
|
|
|
|
|
foreach (var nrow in rows.Select(r => r.EnumName).Distinct().OrderBy(r => r)) {
|
|
|
|
#>
|
|
|
|
<#= nrow #>,
|
|
|
|
<#} #>
|
|
|
|
}
|
|
|
|
|
|
|
|
public static (FileType, byte[])[] Signatures = {
|
|
|
|
<#
|
|
|
|
foreach (var row in rows)
|
|
|
|
{
|
|
|
|
#>
|
|
|
|
// <#= row.Description #>
|
|
|
|
(FileType.<#=row.EnumName #>, new byte[] {<#= string.Join(", ", row.Sig)#>}),
|
|
|
|
|
|
|
|
<#
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
#>
|
|
|
|
|
|
|
|
};}}
|