mirror of
https://github.com/SabreTools/BinaryObjectScanner.git
synced 2026-08-02 05:59:24 +00:00
Migrate wrapper methods to proper factory
This commit is contained in:
@@ -2,11 +2,10 @@
|
||||
using System.IO;
|
||||
using BinaryObjectScanner.Matching;
|
||||
using BinaryObjectScanner.Utilities;
|
||||
using BinaryObjectScanner.Wrappers;
|
||||
|
||||
namespace BurnOutSharp.Tools
|
||||
namespace BinaryObjectScanner.Wrappers
|
||||
{
|
||||
public static class FileTypeTools
|
||||
public static class WrapperFactory
|
||||
{
|
||||
/// <summary>
|
||||
/// Create an instance of a wrapper based on file type
|
||||
@@ -22,7 +21,7 @@ namespace BurnOutSharp.Tools
|
||||
//case SupportedFileType.BZip2: return BZip2.Create(data);
|
||||
case SupportedFileType.CFB: return CFB.Create(data);
|
||||
case SupportedFileType.CIA: return CIA.Create(data);
|
||||
case SupportedFileType.Executable: return DetermineExecutableType(data);
|
||||
case SupportedFileType.Executable: return CreateExecutableWrapper(data);
|
||||
case SupportedFileType.GCF: return GCF.Create(data);
|
||||
//case SupportedFileType.GZIP: return GZIP.Create(data);
|
||||
//case SupportedFileType.IniFile: return IniFile.Create(data);
|
||||
@@ -56,11 +55,11 @@ namespace BurnOutSharp.Tools
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Determine the executable type from the stream
|
||||
/// Create an instance of a wrapper based on the executable type
|
||||
/// </summary>
|
||||
/// <param name="stream">Stream data to parse</param>
|
||||
/// <returns>WrapperBase representing the executable, null on error</returns>
|
||||
public static WrapperBase DetermineExecutableType(Stream stream)
|
||||
public static WrapperBase CreateExecutableWrapper(Stream stream)
|
||||
{
|
||||
// Try to get an MS-DOS wrapper first
|
||||
WrapperBase wrapper = MSDOS.Create(stream);
|
||||
@@ -112,7 +112,7 @@ namespace BurnOutSharp.FileType
|
||||
}
|
||||
|
||||
// Get the wrapper for the appropriate executable type
|
||||
WrapperBase wrapper = Tools.FileTypeTools.DetermineExecutableType(stream);
|
||||
WrapperBase wrapper = WrapperFactory.CreateExecutableWrapper(stream);
|
||||
if (wrapper == null)
|
||||
return protections;
|
||||
|
||||
|
||||
@@ -2,6 +2,7 @@ using System;
|
||||
using System.IO;
|
||||
using System.Text;
|
||||
using BinaryObjectScanner.Utilities;
|
||||
using BinaryObjectScanner.Wrappers;
|
||||
|
||||
namespace Test
|
||||
{
|
||||
@@ -60,7 +61,7 @@ namespace Test
|
||||
Console.WriteLine($"File format found: {ft}");
|
||||
|
||||
// Setup the wrapper to print
|
||||
var wrapper = BurnOutSharp.Tools.FileTypeTools.CreateWrapper(ft, stream);
|
||||
var wrapper = WrapperFactory.CreateWrapper(ft, stream);
|
||||
|
||||
// If we don't have a wrapper
|
||||
if (wrapper == null)
|
||||
|
||||
Reference in New Issue
Block a user