ShockwaveFlashDetector.cs 1.0 KB

123456789101112131415161718192021222324252627
  1. using System.Collections.Generic;
  2. using System.IO;
  3. using System.Linq;
  4. using System.Reflection;
  5. using Masuit.Tools.Mime;
  6. namespace Masuit.Tools.Files.FileDetector.Detectors;
  7. [FormatCategory(FormatCategory.Video)]
  8. [FormatCategory(FormatCategory.Executable)]
  9. internal class ShockwaveFlashDetector : AbstractSignatureDetector
  10. {
  11. private static readonly SignatureInformation[] SwfSignatureInfo = {
  12. new() { Position = 0, Signature = new byte [] { 0x43, 0x57, 0x53 } },
  13. new() { Position = 0, Signature = new byte [] { 0x46, 0x57, 0x53 } },
  14. };
  15. public override string Extension => "swf";
  16. public override string MimeType => new MimeMapper().GetMimeFromExtension("." + Extension);
  17. public override List<FormatCategory> FormatCategories => GetType().GetCustomAttributes<FormatCategoryAttribute>().Select(a => a.Category).ToList();
  18. protected override SignatureInformation[] SignatureInformations => SwfSignatureInfo;
  19. public override string ToString() => "Shockwave Flash(SWF) Detector";
  20. }