mirror of
https://github.com/aaru-dps/Aaru.git
synced 2025-12-16 19:24:25 +00:00
Moved image format detection out of "analyze" verb.
This commit is contained in:
@@ -36,44 +36,18 @@ namespace DiscImageChef.Commands
|
|||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
_imageFormat = null;
|
_imageFormat = ImageFormat.Detect(options.InputFile);
|
||||||
|
|
||||||
// Check all but RAW plugin
|
|
||||||
foreach (ImagePlugin _imageplugin in plugins.ImagePluginsList.Values)
|
|
||||||
{
|
|
||||||
if(_imageplugin.PluginUUID != new Guid("12345678-AAAA-BBBB-CCCC-123456789000"))
|
|
||||||
{
|
|
||||||
if (_imageplugin.IdentifyImage(options.InputFile))
|
|
||||||
{
|
|
||||||
_imageFormat = _imageplugin;
|
|
||||||
Console.WriteLine("Image format identified by {0}.", _imageplugin.Name);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Check only RAW plugin
|
|
||||||
if(_imageFormat == null)
|
if(_imageFormat == null)
|
||||||
{
|
{
|
||||||
foreach (ImagePlugin _imageplugin in plugins.ImagePluginsList.Values)
|
Console.WriteLine("Image format not identified, not proceeding with analysis.");
|
||||||
{
|
|
||||||
if(_imageplugin.PluginUUID == new Guid("12345678-AAAA-BBBB-CCCC-123456789000"))
|
|
||||||
{
|
|
||||||
if (_imageplugin.IdentifyImage(options.InputFile))
|
|
||||||
{
|
|
||||||
_imageFormat = _imageplugin;
|
|
||||||
Console.WriteLine("Image format identified by {0}.", _imageplugin.Name);
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
}
|
else
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Still not recognized
|
|
||||||
if (_imageFormat == null)
|
|
||||||
{
|
{
|
||||||
Console.WriteLine("Image format not identified, not proceeding.");
|
if(MainClass.isVerbose)
|
||||||
return;
|
Console.WriteLine("Image format identified by {0} ({1}).", _imageFormat.Name, _imageFormat.PluginUUID);
|
||||||
|
else
|
||||||
|
Console.WriteLine("Image format identified by {0}.", _imageFormat.Name);
|
||||||
}
|
}
|
||||||
|
|
||||||
try
|
try
|
||||||
@@ -100,8 +74,6 @@ namespace DiscImageChef.Commands
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
Console.WriteLine("Image identified as {0}.", _imageFormat.GetImageFormat());
|
|
||||||
|
|
||||||
if (options.SearchForPartitions)
|
if (options.SearchForPartitions)
|
||||||
{
|
{
|
||||||
List<Partition> partitions = new List<Partition>();
|
List<Partition> partitions = new List<Partition>();
|
||||||
|
|||||||
@@ -84,6 +84,7 @@
|
|||||||
<Compile Include="Commands\Checksum.cs" />
|
<Compile Include="Commands\Checksum.cs" />
|
||||||
<Compile Include="Commands\Verify.cs" />
|
<Compile Include="Commands\Verify.cs" />
|
||||||
<Compile Include="Commands\Commands.cs" />
|
<Compile Include="Commands\Commands.cs" />
|
||||||
|
<Compile Include="ImagePlugins\DetectImageFormat.cs" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
|
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
|||||||
61
DiscImageChef/ImagePlugins/DetectImageFormat.cs
Normal file
61
DiscImageChef/ImagePlugins/DetectImageFormat.cs
Normal file
@@ -0,0 +1,61 @@
|
|||||||
|
using System;
|
||||||
|
|
||||||
|
namespace DiscImageChef.ImagePlugins
|
||||||
|
{
|
||||||
|
public static class ImageFormat
|
||||||
|
{
|
||||||
|
public static ImagePlugin Detect(string imagePath)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
ImagePlugin _imageFormat;
|
||||||
|
PluginBase plugins = new PluginBase();
|
||||||
|
plugins.RegisterAllPlugins();
|
||||||
|
|
||||||
|
_imageFormat = null;
|
||||||
|
|
||||||
|
// Check all but RAW plugin
|
||||||
|
foreach (ImagePlugin _imageplugin in plugins.ImagePluginsList.Values)
|
||||||
|
{
|
||||||
|
if(_imageplugin.PluginUUID != new Guid("12345678-AAAA-BBBB-CCCC-123456789000"))
|
||||||
|
{
|
||||||
|
if (_imageplugin.IdentifyImage(imagePath))
|
||||||
|
{
|
||||||
|
_imageFormat = _imageplugin;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Check only RAW plugin
|
||||||
|
if (_imageFormat == null)
|
||||||
|
{
|
||||||
|
foreach (ImagePlugin _imageplugin in plugins.ImagePluginsList.Values)
|
||||||
|
{
|
||||||
|
if(_imageplugin.PluginUUID == new Guid("12345678-AAAA-BBBB-CCCC-123456789000"))
|
||||||
|
{
|
||||||
|
if (_imageplugin.IdentifyImage(imagePath))
|
||||||
|
{
|
||||||
|
_imageFormat = _imageplugin;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Still not recognized
|
||||||
|
if (_imageFormat == null)
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
return _imageFormat;
|
||||||
|
}
|
||||||
|
catch
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
Reference in New Issue
Block a user