REGDetector.cs 894 B

12345678910111213141516171819202122232425
  1. using System.Collections.Generic;
  2. using System.IO;
  3. using System.Linq;
  4. using System.Reflection;
  5. using System.Text.RegularExpressions;
  6. using Masuit.Tools.Mime;
  7. namespace Masuit.Tools.Files.FileDetector.Detectors;
  8. [FormatCategory(FormatCategory.Document)]
  9. [FormatCategory(FormatCategory.System)]
  10. internal sealed class REGDetector : AbstractRegexSignatureDetector
  11. {
  12. public override string Precondition => "txt";
  13. public override string Extension => "reg";
  14. protected override Regex Signature => new("^Windows Registry Editor Version [0-9]+.[0-9][0-9]\r?\n");
  15. public override string MimeType => new MimeMapper().GetMimeFromExtension("." + Extension);
  16. public override List<FormatCategory> FormatCategories => GetType().GetCustomAttributes<FormatCategoryAttribute>().Select(a => a.Category).ToList();
  17. public override string ToString() => "Windows Registry Detector";
  18. }