_7zDetector.cs 924 B

12345678910111213141516171819202122232425
  1. using System.Collections.Generic;
  2. using System.Linq;
  3. using System.Reflection;
  4. using Masuit.Tools.Mime;
  5. namespace Masuit.Tools.Files.FileDetector.Detectors;
  6. [FormatCategory(FormatCategory.Archive)]
  7. [FormatCategory(FormatCategory.Compression)]
  8. internal class _7zDetector : AbstractSignatureDetector
  9. {
  10. private static readonly SignatureInformation[] _7ZSignatureInfo = {
  11. new() { Position = 0, Signature = new byte [] { 0x37, 0x7A, 0xBC, 0xAF, 0x27, 0x1C } },
  12. };
  13. public override string Extension => "7z";
  14. protected override SignatureInformation[] SignatureInformations => _7ZSignatureInfo;
  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() => "7Z Detector";
  18. }