BashShellScriptDetector.cs 808 B

1234567891011121314151617181920212223
  1. using System.Collections.Generic;
  2. using System.Linq;
  3. using System.Reflection;
  4. using System.Text.RegularExpressions;
  5. using Masuit.Tools.Mime;
  6. namespace Masuit.Tools.Files.FileDetector.Detectors;
  7. [FormatCategory(FormatCategory.Executable)]
  8. internal sealed class BashShellScriptDetector : AbstractRegexSignatureDetector
  9. {
  10. public override string Precondition => "txt";
  11. public override string Extension => "sh";
  12. protected override Regex Signature => new("^#!\\/(.+)\n");
  13. public override string MimeType => new MimeMapper().GetMimeFromExtension("." + Extension);
  14. public override List<FormatCategory> FormatCategories => GetType().GetCustomAttributes<FormatCategoryAttribute>().Select(a => a.Category).ToList();
  15. public override string ToString() => "Bash Shell Script Detector";
  16. }