mirror of
https://github.com/ldqk/Masuit.Tools.git
synced 2026-10-19 06:58:32 +08:00
24 lines
808 B
C#
24 lines
808 B
C#
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Reflection;
|
|
using System.Text.RegularExpressions;
|
|
using Masuit.Tools.Mime;
|
|
|
|
namespace Masuit.Tools.Files.FileDetector.Detectors;
|
|
|
|
[FormatCategory(FormatCategory.Executable)]
|
|
internal sealed class BashShellScriptDetector : AbstractRegexSignatureDetector
|
|
{
|
|
public override string Precondition => "txt";
|
|
|
|
public override string Extension => "sh";
|
|
|
|
protected override Regex Signature => new("^#!\\/(.+)\n");
|
|
|
|
public override string MimeType => new MimeMapper().GetMimeFromExtension("." + Extension);
|
|
|
|
public override List<FormatCategory> FormatCategories => GetType().GetCustomAttributes<FormatCategoryAttribute>().Select(a => a.Category).ToList();
|
|
|
|
public override string ToString() => "Bash Shell Script Detector";
|
|
}
|