using System; using System.IO; using BinaryObjectScanner.Interfaces; namespace BinaryObjectScanner.FileType { /// /// Executable or library /// /// /// Due to the complexity of executables, all actual handling is offloaded to /// another class that is used by the scanner /// public class Executable : IDetectable, IExtractable { /// 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); } } /// /// This implementation should never be invoked public string Detect(Stream stream, string file, bool includeDebug) { throw new InvalidOperationException(); } /// public string Extract(string file, bool includeDebug) { if (!File.Exists(file)) return null; using (var fs = File.Open(file, FileMode.Open, FileAccess.Read, FileShare.Read)) { return Extract(fs, file, includeDebug); } } /// /// This implementation should never be invoked public string Extract(Stream stream, string file, bool includeDebug) { throw new InvalidOperationException(); } } }