mirror of
https://github.com/SabreTools/BinaryObjectScanner.git
synced 2026-02-11 05:35:15 +00:00
58 lines
1.6 KiB
C#
58 lines
1.6 KiB
C#
|
|
using System;
|
|||
|
|
using System.Collections.Concurrent;
|
|||
|
|
using System.IO;
|
|||
|
|
using System.Linq;
|
|||
|
|
using BurnOutSharp.Interfaces;
|
|||
|
|
using BurnOutSharp.Tools;
|
|||
|
|
|
|||
|
|
namespace BurnOutSharp.FileType
|
|||
|
|
{
|
|||
|
|
public class PLJ : IScannable
|
|||
|
|
{
|
|||
|
|
/// <inheritdoc/>
|
|||
|
|
public bool ShouldScan(byte[] magic)
|
|||
|
|
{
|
|||
|
|
// https://www.iana.org/assignments/media-types/audio/vnd.everad.plj
|
|||
|
|
if (magic.StartsWith(new byte?[] { 0xFF, 0x9D, 0x53, 0x4B }))
|
|||
|
|
return true;
|
|||
|
|
|
|||
|
|
return false;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
/// <inheritdoc/>
|
|||
|
|
public ConcurrentDictionary<string, ConcurrentQueue<string>> Scan(Scanner scanner, string file)
|
|||
|
|
{
|
|||
|
|
if (!File.Exists(file))
|
|||
|
|
return null;
|
|||
|
|
|
|||
|
|
using (var fs = File.OpenRead(file))
|
|||
|
|
{
|
|||
|
|
return Scan(scanner, fs, file);
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
/// <inheritdoc/>
|
|||
|
|
public ConcurrentDictionary<string, ConcurrentQueue<string>> Scan(Scanner scanner, Stream stream, string file)
|
|||
|
|
{
|
|||
|
|
var protections = new ConcurrentDictionary<string, ConcurrentQueue<string>>();
|
|||
|
|
try
|
|||
|
|
{
|
|||
|
|
byte[] magic = new byte[16];
|
|||
|
|
stream.Read(magic, 0, 16);
|
|||
|
|
|
|||
|
|
if (ShouldScan(magic))
|
|||
|
|
{
|
|||
|
|
Utilities.AppendToDictionary(protections, file, "PlayJ Audio File");
|
|||
|
|
return protections;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
catch (Exception ex)
|
|||
|
|
{
|
|||
|
|
if (scanner.IncludeDebug) Console.WriteLine(ex);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
return null;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|