mirror of
https://github.com/SabreTools/BinaryObjectScanner.git
synced 2026-02-08 13:49:47 +00:00
50 lines
1.3 KiB
C#
50 lines
1.3 KiB
C#
using System;
|
|
using System.IO;
|
|
using BinaryObjectScanner.Interfaces;
|
|
|
|
namespace BinaryObjectScanner.FileType
|
|
{
|
|
/// <summary>
|
|
/// BD+ SVM
|
|
/// </summary>
|
|
public class BDPlusSVM : IDetectable
|
|
{
|
|
/// <inheritdoc/>
|
|
public string Detect(string file, bool includeDebug)
|
|
{
|
|
if (!File.Exists(file))
|
|
return null;
|
|
|
|
using (var fs = File.Open(file, FileMode.Open, FileAccess.Read, FileShare.Read))
|
|
{
|
|
return Detect(fs, file, includeDebug);
|
|
}
|
|
}
|
|
|
|
/// <inheritdoc/>
|
|
public string Detect(Stream stream, string file, bool includeDebug)
|
|
{
|
|
// If the BD+ file itself fails
|
|
try
|
|
{
|
|
// Create the wrapper
|
|
Wrappers.BDPlusSVM svm = Wrappers.BDPlusSVM.Create(stream);
|
|
if (svm == null)
|
|
return null;
|
|
|
|
// Format the date
|
|
string date = $"{svm.Year:0000}/{svm.Month:00}/{svm.Day:00}";
|
|
|
|
// Return the formatted value
|
|
return $"BD+ {date}";
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
if (includeDebug) Console.WriteLine(ex);
|
|
}
|
|
|
|
return null;
|
|
}
|
|
}
|
|
}
|