using System;
using System.IO;
using GameLauncher.Engines.Common;
namespace GameLauncher.Engines.Evb
{
///
/// Backwards-compatible facade over .
///
/// The plan names the detection primitive , but
/// several callers (the engine module, the unpack service and the game scanner)
/// were written against the shorter EvbDetector API. This facade keeps those
/// call sites stable while the authoritative PE-signature logic lives in
/// .
///
/// This class is engine-local and has no side effects.
///
public static class EvbDetector
{
///
/// Returns true when the game directory holds an EVB packed executable.
/// A packed project file (*.evb) in the folder is also accepted as a
/// decisive signal, in addition to the PE-signature check.
///
public static bool IsEvbGame(string gameDirectory)
{
if (string.IsNullOrWhiteSpace(gameDirectory) || !Directory.Exists(gameDirectory))
{
return false;
}
try
{
// A packed project file in the folder is the strongest single signal.
if (Directory.GetFiles(gameDirectory, "*.evb", SearchOption.TopDirectoryOnly).Length > 0)
{
return true;
}
}
catch
{
// Fall through to the executable signature check.
}
return EvbDetectionHelper.FindEvbPackedExecutable(gameDirectory) != null;
}
///
/// Resolves the executable that should be passed to the unpacker: the first
/// .exe in the folder that carries a decisive EVB signature, or null.
///
public static string? FindPackedExecutable(string gameDirectory)
=> EvbDetectionHelper.FindEvbPackedExecutable(gameDirectory);
/// Returns true when the given executable is packed with EVB.
public static bool ContainsEvbSignature(string exePath)
=> EvbDetectionHelper.IsEvbPacked(exePath);
/// Re-exposes the engine name constant for callers that only reference this helper.
public static string EngineName => EngineDetectionHelper.EngineEvb;
}
}