mirror of
https://github.com/aaru-dps/Aaru.git
synced 2025-12-16 19:24:25 +00:00
Add support for byte addressable images to detection.
This commit is contained in:
@@ -636,7 +636,7 @@ namespace Aaru.Core.Devices.Dumping
|
||||
UpdateStatus?.Invoke("Creating sidecar.");
|
||||
var filters = new FiltersList();
|
||||
IFilter filter = filters.GetFilter(_outputPath);
|
||||
IMediaImage inputPlugin = ImageFormat.Detect(filter);
|
||||
IMediaImage inputPlugin = ImageFormat.Detect(filter) as IMediaImage;
|
||||
ErrorNumber opened = inputPlugin.Open(filter);
|
||||
|
||||
if(opened != ErrorNumber.NoError)
|
||||
|
||||
@@ -62,7 +62,7 @@ namespace Aaru.Core.Devices.Dumping
|
||||
_dumpLog.WriteLine("Creating sidecar.");
|
||||
var filters = new FiltersList();
|
||||
IFilter filter = filters.GetFilter(_outputPath);
|
||||
IMediaImage inputPlugin = ImageFormat.Detect(filter);
|
||||
IMediaImage inputPlugin = ImageFormat.Detect(filter) as IMediaImage;
|
||||
totalChkDuration = 0;
|
||||
ErrorNumber opened = inputPlugin.Open(filter);
|
||||
|
||||
|
||||
@@ -693,7 +693,7 @@ namespace Aaru.Core.Devices.Dumping
|
||||
_dumpLog.WriteLine("Creating sidecar.");
|
||||
var filters = new FiltersList();
|
||||
IFilter filter = filters.GetFilter(_outputPath);
|
||||
IMediaImage inputPlugin = ImageFormat.Detect(filter);
|
||||
IMediaImage inputPlugin = ImageFormat.Detect(filter) as IMediaImage;
|
||||
ErrorNumber opened = inputPlugin.Open(filter);
|
||||
|
||||
if(opened != ErrorNumber.NoError)
|
||||
|
||||
@@ -561,7 +561,7 @@ namespace Aaru.Core.Devices.Dumping
|
||||
_dumpLog.WriteLine("Creating sidecar.");
|
||||
var filters = new FiltersList();
|
||||
IFilter filter = filters.GetFilter(_outputPath);
|
||||
IMediaImage inputPlugin = ImageFormat.Detect(filter);
|
||||
IMediaImage inputPlugin = ImageFormat.Detect(filter) as IMediaImage;
|
||||
ErrorNumber opened = inputPlugin.Open(filter);
|
||||
|
||||
if(opened != ErrorNumber.NoError)
|
||||
|
||||
@@ -1314,7 +1314,7 @@ namespace Aaru.Core.Devices.Dumping
|
||||
_dumpLog.WriteLine("Creating sidecar.");
|
||||
var filters = new FiltersList();
|
||||
IFilter filter = filters.GetFilter(_outputPath);
|
||||
IMediaImage inputPlugin = ImageFormat.Detect(filter);
|
||||
IMediaImage inputPlugin = ImageFormat.Detect(filter) as IMediaImage;
|
||||
ErrorNumber opened = inputPlugin.Open(filter);
|
||||
|
||||
if(opened != ErrorNumber.NoError)
|
||||
|
||||
@@ -985,7 +985,7 @@ namespace Aaru.Core.Devices.Dumping
|
||||
_dumpLog.WriteLine("Creating sidecar.");
|
||||
var filters = new FiltersList();
|
||||
IFilter filter = filters.GetFilter(_outputPath);
|
||||
IMediaImage inputPlugin = ImageFormat.Detect(filter);
|
||||
IMediaImage inputPlugin = ImageFormat.Detect(filter) as IMediaImage;
|
||||
ErrorNumber opened = inputPlugin.Open(filter);
|
||||
|
||||
if(opened != ErrorNumber.NoError)
|
||||
|
||||
@@ -782,7 +782,7 @@ namespace Aaru.Core.Devices.Dumping
|
||||
_dumpLog.WriteLine("Creating sidecar.");
|
||||
var filters = new FiltersList();
|
||||
IFilter filter = filters.GetFilter(_outputPath);
|
||||
IMediaImage inputPlugin = ImageFormat.Detect(filter);
|
||||
IMediaImage inputPlugin = ImageFormat.Detect(filter) as IMediaImage;
|
||||
ErrorNumber opened = inputPlugin.Open(filter);
|
||||
|
||||
if(opened != ErrorNumber.NoError)
|
||||
|
||||
@@ -36,72 +36,94 @@ using Aaru.CommonTypes;
|
||||
using Aaru.CommonTypes.Interfaces;
|
||||
using Aaru.Console;
|
||||
|
||||
namespace Aaru.Core
|
||||
namespace Aaru.Core;
|
||||
|
||||
/// <summary>Core media image format operations</summary>
|
||||
public static class ImageFormat
|
||||
{
|
||||
/// <summary>Core media image format operations</summary>
|
||||
public static class ImageFormat
|
||||
/// <summary>Detects the image plugin that recognizes the data inside a filter</summary>
|
||||
/// <param name="imageFilter">Filter</param>
|
||||
/// <returns>Detected image plugin</returns>
|
||||
public static IBaseImage Detect(IFilter imageFilter)
|
||||
{
|
||||
/// <summary>Detects the image plugin that recognizes the data inside a filter</summary>
|
||||
/// <param name="imageFilter">Filter</param>
|
||||
/// <returns>Detected image plugin</returns>
|
||||
public static IMediaImage Detect(IFilter imageFilter)
|
||||
try
|
||||
{
|
||||
try
|
||||
{
|
||||
PluginBase plugins = GetPluginBase.Instance;
|
||||
PluginBase plugins = GetPluginBase.Instance;
|
||||
|
||||
IMediaImage imageFormat = null;
|
||||
IBaseImage imageFormat = null;
|
||||
|
||||
// Check all but RAW plugin
|
||||
foreach(IMediaImage imagePlugin in plugins.ImagePluginsList.Values.Where(imagePlugin =>
|
||||
imagePlugin.Id != new Guid("12345678-AAAA-BBBB-CCCC-123456789000")))
|
||||
try
|
||||
{
|
||||
AaruConsole.DebugWriteLine("Format detection", "Trying plugin {0}", imagePlugin.Name);
|
||||
// Check all but RAW plugin
|
||||
foreach(IMediaImage imagePlugin in plugins.ImagePluginsList.Values.Where(imagePlugin =>
|
||||
imagePlugin.Id != new Guid("12345678-AAAA-BBBB-CCCC-123456789000")))
|
||||
try
|
||||
{
|
||||
AaruConsole.DebugWriteLine("Format detection", "Trying plugin {0}", imagePlugin.Name);
|
||||
|
||||
if(!imagePlugin.Identify(imageFilter))
|
||||
continue;
|
||||
if(!imagePlugin.Identify(imageFilter))
|
||||
continue;
|
||||
|
||||
imageFormat = imagePlugin;
|
||||
imageFormat = imagePlugin;
|
||||
|
||||
break;
|
||||
}
|
||||
#pragma warning disable RECS0022 // A catch clause that catches System.Exception and has an empty body
|
||||
catch
|
||||
{
|
||||
// ignored
|
||||
}
|
||||
break;
|
||||
}
|
||||
#pragma warning disable RECS0022 // A catch clause that catches System.Exception and has an empty body
|
||||
catch
|
||||
{
|
||||
// ignored
|
||||
}
|
||||
|
||||
if(imageFormat != null)
|
||||
return imageFormat;
|
||||
|
||||
// Check only RAW plugin
|
||||
foreach(IMediaImage imagePlugin in plugins.ImagePluginsList.Values.Where(imagePlugin =>
|
||||
imagePlugin.Id == new Guid("12345678-AAAA-BBBB-CCCC-123456789000")))
|
||||
try
|
||||
{
|
||||
AaruConsole.DebugWriteLine("Format detection", "Trying plugin {0}", imagePlugin.Name);
|
||||
|
||||
if(!imagePlugin.Identify(imageFilter))
|
||||
continue;
|
||||
|
||||
imageFormat = imagePlugin;
|
||||
|
||||
break;
|
||||
}
|
||||
#pragma warning disable RECS0022 // A catch clause that catches System.Exception and has an empty body
|
||||
catch
|
||||
{
|
||||
// ignored
|
||||
}
|
||||
|
||||
// Still not recognized
|
||||
if(imageFormat != null)
|
||||
return imageFormat;
|
||||
}
|
||||
catch
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
// Check all but RAW plugin
|
||||
foreach(IByteAddressableImage imagePlugin in plugins.ByteAddressableImages.Values.Where(imagePlugin =>
|
||||
imagePlugin.Id != new Guid("12345678-AAAA-BBBB-CCCC-123456789000")))
|
||||
try
|
||||
{
|
||||
AaruConsole.DebugWriteLine("Format detection", "Trying plugin {0}", imagePlugin.Name);
|
||||
|
||||
if(!imagePlugin.Identify(imageFilter))
|
||||
continue;
|
||||
|
||||
imageFormat = imagePlugin;
|
||||
|
||||
break;
|
||||
}
|
||||
#pragma warning disable RECS0022 // A catch clause that catches System.Exception and has an empty body
|
||||
catch
|
||||
{
|
||||
// ignored
|
||||
}
|
||||
|
||||
if(imageFormat != null)
|
||||
return imageFormat;
|
||||
|
||||
// Check only RAW plugin
|
||||
foreach(IMediaImage imagePlugin in plugins.ImagePluginsList.Values.Where(imagePlugin =>
|
||||
imagePlugin.Id == new Guid("12345678-AAAA-BBBB-CCCC-123456789000")))
|
||||
try
|
||||
{
|
||||
AaruConsole.DebugWriteLine("Format detection", "Trying plugin {0}", imagePlugin.Name);
|
||||
|
||||
if(!imagePlugin.Identify(imageFilter))
|
||||
continue;
|
||||
|
||||
imageFormat = imagePlugin;
|
||||
|
||||
break;
|
||||
}
|
||||
#pragma warning disable RECS0022 // A catch clause that catches System.Exception and has an empty body
|
||||
catch
|
||||
{
|
||||
// ignored
|
||||
}
|
||||
|
||||
// Still not recognized
|
||||
return imageFormat;
|
||||
}
|
||||
catch
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user