Add support for byte addressable images to detection.

This commit is contained in:
2021-11-14 03:52:44 +00:00
parent 3f6fd587a1
commit 5e733abc8f
22 changed files with 2872 additions and 2842 deletions

View File

@@ -636,7 +636,7 @@ namespace Aaru.Core.Devices.Dumping
UpdateStatus?.Invoke("Creating sidecar."); UpdateStatus?.Invoke("Creating sidecar.");
var filters = new FiltersList(); var filters = new FiltersList();
IFilter filter = filters.GetFilter(_outputPath); IFilter filter = filters.GetFilter(_outputPath);
IMediaImage inputPlugin = ImageFormat.Detect(filter); IMediaImage inputPlugin = ImageFormat.Detect(filter) as IMediaImage;
ErrorNumber opened = inputPlugin.Open(filter); ErrorNumber opened = inputPlugin.Open(filter);
if(opened != ErrorNumber.NoError) if(opened != ErrorNumber.NoError)

View File

@@ -62,7 +62,7 @@ namespace Aaru.Core.Devices.Dumping
_dumpLog.WriteLine("Creating sidecar."); _dumpLog.WriteLine("Creating sidecar.");
var filters = new FiltersList(); var filters = new FiltersList();
IFilter filter = filters.GetFilter(_outputPath); IFilter filter = filters.GetFilter(_outputPath);
IMediaImage inputPlugin = ImageFormat.Detect(filter); IMediaImage inputPlugin = ImageFormat.Detect(filter) as IMediaImage;
totalChkDuration = 0; totalChkDuration = 0;
ErrorNumber opened = inputPlugin.Open(filter); ErrorNumber opened = inputPlugin.Open(filter);

View File

@@ -693,7 +693,7 @@ namespace Aaru.Core.Devices.Dumping
_dumpLog.WriteLine("Creating sidecar."); _dumpLog.WriteLine("Creating sidecar.");
var filters = new FiltersList(); var filters = new FiltersList();
IFilter filter = filters.GetFilter(_outputPath); IFilter filter = filters.GetFilter(_outputPath);
IMediaImage inputPlugin = ImageFormat.Detect(filter); IMediaImage inputPlugin = ImageFormat.Detect(filter) as IMediaImage;
ErrorNumber opened = inputPlugin.Open(filter); ErrorNumber opened = inputPlugin.Open(filter);
if(opened != ErrorNumber.NoError) if(opened != ErrorNumber.NoError)

View File

@@ -561,7 +561,7 @@ namespace Aaru.Core.Devices.Dumping
_dumpLog.WriteLine("Creating sidecar."); _dumpLog.WriteLine("Creating sidecar.");
var filters = new FiltersList(); var filters = new FiltersList();
IFilter filter = filters.GetFilter(_outputPath); IFilter filter = filters.GetFilter(_outputPath);
IMediaImage inputPlugin = ImageFormat.Detect(filter); IMediaImage inputPlugin = ImageFormat.Detect(filter) as IMediaImage;
ErrorNumber opened = inputPlugin.Open(filter); ErrorNumber opened = inputPlugin.Open(filter);
if(opened != ErrorNumber.NoError) if(opened != ErrorNumber.NoError)

View File

@@ -1314,7 +1314,7 @@ namespace Aaru.Core.Devices.Dumping
_dumpLog.WriteLine("Creating sidecar."); _dumpLog.WriteLine("Creating sidecar.");
var filters = new FiltersList(); var filters = new FiltersList();
IFilter filter = filters.GetFilter(_outputPath); IFilter filter = filters.GetFilter(_outputPath);
IMediaImage inputPlugin = ImageFormat.Detect(filter); IMediaImage inputPlugin = ImageFormat.Detect(filter) as IMediaImage;
ErrorNumber opened = inputPlugin.Open(filter); ErrorNumber opened = inputPlugin.Open(filter);
if(opened != ErrorNumber.NoError) if(opened != ErrorNumber.NoError)

View File

@@ -985,7 +985,7 @@ namespace Aaru.Core.Devices.Dumping
_dumpLog.WriteLine("Creating sidecar."); _dumpLog.WriteLine("Creating sidecar.");
var filters = new FiltersList(); var filters = new FiltersList();
IFilter filter = filters.GetFilter(_outputPath); IFilter filter = filters.GetFilter(_outputPath);
IMediaImage inputPlugin = ImageFormat.Detect(filter); IMediaImage inputPlugin = ImageFormat.Detect(filter) as IMediaImage;
ErrorNumber opened = inputPlugin.Open(filter); ErrorNumber opened = inputPlugin.Open(filter);
if(opened != ErrorNumber.NoError) if(opened != ErrorNumber.NoError)

View File

@@ -782,7 +782,7 @@ namespace Aaru.Core.Devices.Dumping
_dumpLog.WriteLine("Creating sidecar."); _dumpLog.WriteLine("Creating sidecar.");
var filters = new FiltersList(); var filters = new FiltersList();
IFilter filter = filters.GetFilter(_outputPath); IFilter filter = filters.GetFilter(_outputPath);
IMediaImage inputPlugin = ImageFormat.Detect(filter); IMediaImage inputPlugin = ImageFormat.Detect(filter) as IMediaImage;
ErrorNumber opened = inputPlugin.Open(filter); ErrorNumber opened = inputPlugin.Open(filter);
if(opened != ErrorNumber.NoError) if(opened != ErrorNumber.NoError)

View File

@@ -36,21 +36,21 @@ using Aaru.CommonTypes;
using Aaru.CommonTypes.Interfaces; using Aaru.CommonTypes.Interfaces;
using Aaru.Console; using Aaru.Console;
namespace Aaru.Core namespace Aaru.Core;
{
/// <summary>Core media image format operations</summary> /// <summary>Core media image format operations</summary>
public static class ImageFormat public static class ImageFormat
{ {
/// <summary>Detects the image plugin that recognizes the data inside a filter</summary> /// <summary>Detects the image plugin that recognizes the data inside a filter</summary>
/// <param name="imageFilter">Filter</param> /// <param name="imageFilter">Filter</param>
/// <returns>Detected image plugin</returns> /// <returns>Detected image plugin</returns>
public static IMediaImage Detect(IFilter imageFilter) public static IBaseImage Detect(IFilter imageFilter)
{ {
try try
{ {
PluginBase plugins = GetPluginBase.Instance; PluginBase plugins = GetPluginBase.Instance;
IMediaImage imageFormat = null; IBaseImage imageFormat = null;
// Check all but RAW plugin // Check all but RAW plugin
foreach(IMediaImage imagePlugin in plugins.ImagePluginsList.Values.Where(imagePlugin => foreach(IMediaImage imagePlugin in plugins.ImagePluginsList.Values.Where(imagePlugin =>
@@ -75,6 +75,29 @@ namespace Aaru.Core
if(imageFormat != null) if(imageFormat != null)
return imageFormat; return imageFormat;
// 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 // Check only RAW plugin
foreach(IMediaImage imagePlugin in plugins.ImagePluginsList.Values.Where(imagePlugin => foreach(IMediaImage imagePlugin in plugins.ImagePluginsList.Values.Where(imagePlugin =>
imagePlugin.Id == new Guid("12345678-AAAA-BBBB-CCCC-123456789000"))) imagePlugin.Id == new Guid("12345678-AAAA-BBBB-CCCC-123456789000")))
@@ -104,4 +127,3 @@ namespace Aaru.Core
} }
} }
} }
}

View File

@@ -523,7 +523,7 @@ namespace Aaru.Gui.ViewModels.Windows
try try
{ {
IMediaImage imageFormat = ImageFormat.Detect(inputFilter); IMediaImage imageFormat = ImageFormat.Detect(inputFilter) as IMediaImage;
if(imageFormat == null) if(imageFormat == null)
{ {

View File

@@ -47,7 +47,7 @@ namespace Aaru.Tests.Filesystems
Assert.IsNotNull(inputFilter, $"Filter: {testFile}"); Assert.IsNotNull(inputFilter, $"Filter: {testFile}");
IMediaImage image = ImageFormat.Detect(inputFilter); IMediaImage image = ImageFormat.Detect(inputFilter) as IMediaImage;
Assert.IsNotNull(image, $"Image format: {testFile}"); Assert.IsNotNull(image, $"Image format: {testFile}");
@@ -123,7 +123,7 @@ namespace Aaru.Tests.Filesystems
Assert.IsNotNull(inputFilter, $"Filter: {testFile}"); Assert.IsNotNull(inputFilter, $"Filter: {testFile}");
IMediaImage image = ImageFormat.Detect(inputFilter); IMediaImage image = ImageFormat.Detect(inputFilter) as IMediaImage;
Assert.IsNotNull(image, $"Image format: {testFile}"); Assert.IsNotNull(image, $"Image format: {testFile}");
@@ -162,7 +162,7 @@ namespace Aaru.Tests.Filesystems
Assert.IsNotNull(inputFilter, $"Filter: {testFile}"); Assert.IsNotNull(inputFilter, $"Filter: {testFile}");
IMediaImage image = ImageFormat.Detect(inputFilter); IMediaImage image = ImageFormat.Detect(inputFilter) as IMediaImage;
Assert.IsNotNull(image, $"Image format: {testFile}"); Assert.IsNotNull(image, $"Image format: {testFile}");

View File

@@ -48,7 +48,7 @@ namespace Aaru.Tests.Filesystems
Assert.IsNotNull(inputFilter, $"Filter: {testFile}"); Assert.IsNotNull(inputFilter, $"Filter: {testFile}");
IMediaImage image = ImageFormat.Detect(inputFilter); IMediaImage image = ImageFormat.Detect(inputFilter) as IMediaImage;
Assert.IsNotNull(image, $"Image format: {testFile}"); Assert.IsNotNull(image, $"Image format: {testFile}");
@@ -163,7 +163,7 @@ namespace Aaru.Tests.Filesystems
var filtersList = new FiltersList(); var filtersList = new FiltersList();
IFilter inputFilter = filtersList.GetFilter(testFile); IFilter inputFilter = filtersList.GetFilter(testFile);
IMediaImage image = ImageFormat.Detect(inputFilter); IMediaImage image = ImageFormat.Detect(inputFilter) as IMediaImage;
ErrorNumber opened = image.Open(inputFilter); ErrorNumber opened = image.Open(inputFilter);
if(opened != ErrorNumber.NoError) if(opened != ErrorNumber.NoError)

View File

@@ -48,7 +48,7 @@ namespace Aaru.Tests.Issues
PluginBase plugins = GetPluginBase.Instance; PluginBase plugins = GetPluginBase.Instance;
IMediaImage imageFormat = ImageFormat.Detect(inputFilter); IMediaImage imageFormat = ImageFormat.Detect(inputFilter) as IMediaImage;
Assert.NotNull(imageFormat, "Image format not identified, not proceeding with analysis."); Assert.NotNull(imageFormat, "Image format not identified, not proceeding with analysis.");

View File

@@ -42,7 +42,7 @@ namespace Aaru.Tests.Issues
PluginBase plugins = GetPluginBase.Instance; PluginBase plugins = GetPluginBase.Instance;
IMediaImage imageFormat = ImageFormat.Detect(inputFilter); IMediaImage imageFormat = ImageFormat.Detect(inputFilter) as IMediaImage;
Assert.NotNull(imageFormat, "Image format not identified, not proceeding with analysis."); Assert.NotNull(imageFormat, "Image format not identified, not proceeding with analysis.");

View File

@@ -29,7 +29,7 @@ namespace Aaru.Tests.Issues
Assert.IsNotNull(inputFilter, "Filter for test file is not detected"); Assert.IsNotNull(inputFilter, "Filter for test file is not detected");
IMediaImage image = ImageFormat.Detect(inputFilter); IMediaImage image = ImageFormat.Detect(inputFilter) as IMediaImage;
Assert.IsNotNull(image, "Image format for test file is not detected"); Assert.IsNotNull(image, "Image format for test file is not detected");

View File

@@ -55,7 +55,7 @@ namespace Aaru.Tests.Issues
Assert.IsFalse(File.Exists(outputPath), "Output file already exists, not continuing."); Assert.IsFalse(File.Exists(outputPath), "Output file already exists, not continuing.");
IMediaImage inputFormat = ImageFormat.Detect(inputFilter); IMediaImage inputFormat = ImageFormat.Detect(inputFilter) as IMediaImage;
Assert.IsNotNull(inputFormat, "Input image format not identified, not proceeding with conversion."); Assert.IsNotNull(inputFormat, "Input image format not identified, not proceeding with conversion.");

View File

@@ -31,7 +31,7 @@ namespace Aaru.Tests.Issues
Assert.IsNotNull(inputFilter, "Filter for test file is not detected"); Assert.IsNotNull(inputFilter, "Filter for test file is not detected");
IMediaImage image = ImageFormat.Detect(inputFilter); IMediaImage image = ImageFormat.Detect(inputFilter) as IMediaImage;
Assert.IsNotNull(image, "Image format for test file is not detected"); Assert.IsNotNull(image, "Image format for test file is not detected");

View File

@@ -36,7 +36,7 @@ namespace Aaru.Tests.Partitions
Assert.IsNotNull(inputFilter, $"Filter: {testFile}"); Assert.IsNotNull(inputFilter, $"Filter: {testFile}");
IMediaImage image = ImageFormat.Detect(inputFilter); IMediaImage image = ImageFormat.Detect(inputFilter) as IMediaImage;
Assert.IsNotNull(image, $"Image format: {testFile}"); Assert.IsNotNull(image, $"Image format: {testFile}");

View File

@@ -46,8 +46,8 @@ using JetBrains.Annotations;
using Spectre.Console; using Spectre.Console;
using FileAttributes = Aaru.CommonTypes.Structs.FileAttributes; using FileAttributes = Aaru.CommonTypes.Structs.FileAttributes;
namespace Aaru.Commands.Filesystem namespace Aaru.Commands.Filesystem;
{
internal sealed class ExtractFilesCommand : Command internal sealed class ExtractFilesCommand : Command
{ {
const long BUFFER_SIZE = 16777216; const long BUFFER_SIZE = 16777216;
@@ -193,23 +193,31 @@ namespace Aaru.Commands.Filesystem
try try
{ {
IMediaImage imageFormat = null; IMediaImage imageFormat = null;
IBaseImage baseImage = null;
Core.Spectre.ProgressSingleSpinner(ctx => Core.Spectre.ProgressSingleSpinner(ctx =>
{ {
ctx.AddTask("Identifying image format...").IsIndeterminate(); ctx.AddTask("Identifying image format...").IsIndeterminate();
imageFormat = ImageFormat.Detect(inputFilter); baseImage = ImageFormat.Detect(inputFilter);
imageFormat = baseImage as IMediaImage;
}); });
if(imageFormat == null) if(baseImage == null)
{ {
AaruConsole.WriteLine("Image format not identified, not proceeding with analysis."); AaruConsole.WriteLine("Image format not identified, not proceeding with analysis.");
return (int)ErrorNumber.UnrecognizedFormat; return (int)ErrorNumber.UnrecognizedFormat;
} }
if(imageFormat == null)
{
AaruConsole.WriteLine("Command not supported for this image type.");
return (int)ErrorNumber.InvalidArgument;
}
if(verbose) if(verbose)
AaruConsole.VerboseWriteLine("Image format identified by {0} ({1}).", imageFormat.Name, AaruConsole.VerboseWriteLine("Image format identified by {0} ({1}).", imageFormat.Name, imageFormat.Id);
imageFormat.Id);
else else
AaruConsole.WriteLine("Image format identified by {0}.", imageFormat.Name); AaruConsole.WriteLine("Image format identified by {0}.", imageFormat.Name);
@@ -253,8 +261,7 @@ namespace Aaru.Commands.Filesystem
AaruConsole.DebugWriteLine("Extract-Files command", "Image without headers is {0} bytes.", AaruConsole.DebugWriteLine("Extract-Files command", "Image without headers is {0} bytes.",
imageFormat.Info.ImageSize); imageFormat.Info.ImageSize);
AaruConsole.DebugWriteLine("Extract-Files command", "Image has {0} sectors.", AaruConsole.DebugWriteLine("Extract-Files command", "Image has {0} sectors.", imageFormat.Info.Sectors);
imageFormat.Info.Sectors);
AaruConsole.DebugWriteLine("Extract-Files command", "Image identifies disk type as {0}.", AaruConsole.DebugWriteLine("Extract-Files command", "Image identifies disk type as {0}.",
imageFormat.Info.MediaType); imageFormat.Info.MediaType);
@@ -349,8 +356,7 @@ namespace Aaru.Commands.Filesystem
Statistics.AddFilesystem(fs.XmlFsType.Type); Statistics.AddFilesystem(fs.XmlFsType.Type);
} }
else else
AaruConsole.ErrorWriteLine("Unable to mount device, error {0}", AaruConsole.ErrorWriteLine("Unable to mount device, error {0}", error.ToString());
error.ToString());
} }
} }
else else
@@ -398,8 +404,8 @@ namespace Aaru.Commands.Filesystem
return (int)ErrorNumber.NoError; return (int)ErrorNumber.NoError;
} }
static void ExtractFilesInDir(string path, [NotNull] IReadOnlyFilesystem fs, string volumeName, static void ExtractFilesInDir(string path, [NotNull] IReadOnlyFilesystem fs, string volumeName, string outputDir,
string outputDir, bool doXattrs) bool doXattrs)
{ {
if(path.StartsWith('/')) if(path.StartsWith('/'))
path = path.Substring(1); path = path.Substring(1);
@@ -500,8 +506,7 @@ namespace Aaru.Commands.Filesystem
if(error != ErrorNumber.NoError) if(error != ErrorNumber.NoError)
continue; continue;
outputPath = Path.Combine(outputDir, fs.XmlFsType.Type, volumeName, ".xattrs", path, outputPath = Path.Combine(outputDir, fs.XmlFsType.Type, volumeName, ".xattrs", path, xattr);
xattr);
Directory.CreateDirectory(outputPath); Directory.CreateDirectory(outputPath);
@@ -513,8 +518,8 @@ namespace Aaru.Commands.Filesystem
{ {
ctx.AddTask("Writing extended attribute...").IsIndeterminate(); ctx.AddTask("Writing extended attribute...").IsIndeterminate();
outputFile = new FileStream(outputPath, FileMode.CreateNew, outputFile = new FileStream(outputPath, FileMode.CreateNew, FileAccess.ReadWrite,
FileAccess.ReadWrite, FileShare.None); FileShare.None);
outputFile.Write(xattrBuf, 0, xattrBuf.Length); outputFile.Write(xattrBuf, 0, xattrBuf.Length);
outputFile.Close(); outputFile.Close();
@@ -571,12 +576,11 @@ namespace Aaru.Commands.Filesystem
{ {
long position = 0; long position = 0;
outputFile = new FileStream(outputPath, FileMode.CreateNew, FileAccess.ReadWrite, outputFile = new FileStream(outputPath, FileMode.CreateNew, FileAccess.ReadWrite, FileShare.None);
FileShare.None);
AnsiConsole.Progress().AutoClear(true).HideCompleted(true). AnsiConsole.Progress().AutoClear(true).HideCompleted(true).
Columns(new TaskDescriptionColumn(), new ProgressBarColumn(), Columns(new TaskDescriptionColumn(), new ProgressBarColumn(), new PercentageColumn()).
new PercentageColumn()).Start(ctx => Start(ctx =>
{ {
ProgressTask task = ctx.AddTask($"Reading file {Markup.Escape(entry)}..."); ProgressTask task = ctx.AddTask($"Reading file {Markup.Escape(entry)}...");
@@ -654,4 +658,3 @@ namespace Aaru.Commands.Filesystem
} }
} }
} }
}

View File

@@ -42,8 +42,8 @@ using Aaru.Console;
using Aaru.Core; using Aaru.Core;
using Spectre.Console; using Spectre.Console;
namespace Aaru.Commands.Filesystem namespace Aaru.Commands.Filesystem;
{
internal sealed class FilesystemInfoCommand : Command internal sealed class FilesystemInfoCommand : Command
{ {
public FilesystemInfoCommand() : base("info", public FilesystemInfoCommand() : base("info",
@@ -165,23 +165,31 @@ namespace Aaru.Commands.Filesystem
try try
{ {
IMediaImage imageFormat = null; IMediaImage imageFormat = null;
IBaseImage baseImage = null;
Core.Spectre.ProgressSingleSpinner(ctx => Core.Spectre.ProgressSingleSpinner(ctx =>
{ {
ctx.AddTask("Identifying image format...").IsIndeterminate(); ctx.AddTask("Identifying image format...").IsIndeterminate();
imageFormat = ImageFormat.Detect(inputFilter); baseImage = ImageFormat.Detect(inputFilter);
imageFormat = baseImage as IMediaImage;
}); });
if(imageFormat == null) if(baseImage == null)
{ {
AaruConsole.WriteLine("Image format not identified, not proceeding with analysis."); AaruConsole.WriteLine("Image format not identified, not proceeding with analysis.");
return (int)ErrorNumber.UnrecognizedFormat; return (int)ErrorNumber.UnrecognizedFormat;
} }
if(imageFormat == null)
{
AaruConsole.WriteLine("Command not supported for this image type.");
return (int)ErrorNumber.InvalidArgument;
}
if(verbose) if(verbose)
AaruConsole.VerboseWriteLine("Image format identified by {0} ({1}).", imageFormat.Name, AaruConsole.VerboseWriteLine("Image format identified by {0} ({1}).", imageFormat.Name, imageFormat.Id);
imageFormat.Id);
else else
AaruConsole.WriteLine("Image format identified by {0}.", imageFormat.Name); AaruConsole.WriteLine("Image format identified by {0}.", imageFormat.Name);
@@ -269,8 +277,7 @@ namespace Aaru.Commands.Filesystem
table.AddRow("Type", Markup.Escape(partitionsList[i].Type ?? "")); table.AddRow("Type", Markup.Escape(partitionsList[i].Type ?? ""));
table.AddRow("Start", $"sector {partitionsList[i].Start}, byte {partitionsList[i].Offset}"); table.AddRow("Start", $"sector {partitionsList[i].Start}, byte {partitionsList[i].Offset}");
table.AddRow("Length", table.AddRow("Length", $"{partitionsList[i].Length} sectors, {partitionsList[i].Size} bytes");
$"{partitionsList[i].Length} sectors, {partitionsList[i].Size} bytes");
table.AddRow("Scheme", Markup.Escape(partitionsList[i].Scheme ?? "")); table.AddRow("Scheme", Markup.Escape(partitionsList[i].Scheme ?? ""));
table.AddRow("Description", Markup.Escape(partitionsList[i].Description ?? "")); table.AddRow("Description", Markup.Escape(partitionsList[i].Description ?? ""));
@@ -377,4 +384,3 @@ namespace Aaru.Commands.Filesystem
return (int)ErrorNumber.NoError; return (int)ErrorNumber.NoError;
} }
} }
}

View File

@@ -45,8 +45,8 @@ using Aaru.Core;
using JetBrains.Annotations; using JetBrains.Annotations;
using Spectre.Console; using Spectre.Console;
namespace Aaru.Commands.Filesystem namespace Aaru.Commands.Filesystem;
{
internal sealed class LsCommand : Command internal sealed class LsCommand : Command
{ {
public LsCommand() : base("list", "Lists files in disc image.") public LsCommand() : base("list", "Lists files in disc image.")
@@ -182,23 +182,31 @@ namespace Aaru.Commands.Filesystem
try try
{ {
IMediaImage imageFormat = null; IMediaImage imageFormat = null;
IBaseImage baseImage = null;
Core.Spectre.ProgressSingleSpinner(ctx => Core.Spectre.ProgressSingleSpinner(ctx =>
{ {
ctx.AddTask("Identifying image format...").IsIndeterminate(); ctx.AddTask("Identifying image format...").IsIndeterminate();
imageFormat = ImageFormat.Detect(inputFilter); baseImage = ImageFormat.Detect(inputFilter);
imageFormat = baseImage as IMediaImage;
}); });
if(imageFormat == null) if(baseImage == null)
{ {
AaruConsole.WriteLine("Image format not identified, not proceeding with analysis."); AaruConsole.WriteLine("Image format not identified, not proceeding with analysis.");
return (int)ErrorNumber.UnrecognizedFormat; return (int)ErrorNumber.UnrecognizedFormat;
} }
if(imageFormat == null)
{
AaruConsole.WriteLine("Command not supported for this image type.");
return (int)ErrorNumber.InvalidArgument;
}
if(verbose) if(verbose)
AaruConsole.VerboseWriteLine("Image format identified by {0} ({1}).", imageFormat.Name, AaruConsole.VerboseWriteLine("Image format identified by {0} ({1}).", imageFormat.Name, imageFormat.Id);
imageFormat.Id);
else else
AaruConsole.WriteLine("Image format identified by {0}.", imageFormat.Name); AaruConsole.WriteLine("Image format identified by {0}.", imageFormat.Name);
@@ -320,8 +328,7 @@ namespace Aaru.Commands.Filesystem
Statistics.AddFilesystem(fs.XmlFsType.Type); Statistics.AddFilesystem(fs.XmlFsType.Type);
} }
else else
AaruConsole.ErrorWriteLine("Unable to mount device, error {0}", AaruConsole.ErrorWriteLine("Unable to mount device, error {0}", error.ToString());
error.ToString());
} }
} }
else else
@@ -395,8 +402,7 @@ namespace Aaru.Commands.Filesystem
Dictionary<string, FileEntryInfo> stats = new(); Dictionary<string, FileEntryInfo> stats = new();
AnsiConsole.Progress().AutoClear(true).HideCompleted(true). AnsiConsole.Progress().AutoClear(true).HideCompleted(true).
Columns(new TaskDescriptionColumn(), new ProgressBarColumn(), new PercentageColumn()). Columns(new TaskDescriptionColumn(), new ProgressBarColumn(), new PercentageColumn()).Start(ctx =>
Start(ctx =>
{ {
ProgressTask task = ctx.AddTask("Retrieving file information..."); ProgressTask task = ctx.AddTask("Retrieving file information...");
task.MaxValue = directory.Count; task.MaxValue = directory.Count;
@@ -420,9 +426,8 @@ namespace Aaru.Commands.Filesystem
AaruConsole.WriteLine("{0, 10:d} {0, 12:T} {1, -20} {2}", entry.Value.CreationTimeUtc, AaruConsole.WriteLine("{0, 10:d} {0, 12:T} {1, -20} {2}", entry.Value.CreationTimeUtc,
"<DIR>", Markup.Escape(entry.Key)); "<DIR>", Markup.Escape(entry.Key));
else else
AaruConsole.WriteLine("{0, 10:d} {0, 12:T} {1, 6}{2, 14:N0} {3}", AaruConsole.WriteLine("{0, 10:d} {0, 12:T} {1, 6}{2, 14:N0} {3}", entry.Value.CreationTimeUtc,
entry.Value.CreationTimeUtc, entry.Value.Inode, entry.Value.Length, entry.Value.Inode, entry.Value.Length, Markup.Escape(entry.Key));
Markup.Escape(entry.Key));
error = fs.ListXAttr(path + "/" + entry.Key, out List<string> xattrs); error = fs.ListXAttr(path + "/" + entry.Key, out List<string> xattrs);
@@ -455,4 +460,3 @@ namespace Aaru.Commands.Filesystem
ListFilesInDir(path + "/" + subdirectory.Key, fs, longFormat); ListFilesInDir(path + "/" + subdirectory.Key, fs, longFormat);
} }
} }
}

View File

@@ -53,8 +53,8 @@ using ImageInfo = Aaru.CommonTypes.Structs.ImageInfo;
using MediaType = Aaru.CommonTypes.MediaType; using MediaType = Aaru.CommonTypes.MediaType;
using Version = Aaru.CommonTypes.Interop.Version; using Version = Aaru.CommonTypes.Interop.Version;
namespace Aaru.Commands.Image namespace Aaru.Commands.Image;
{
internal sealed class ConvertImageCommand : Command internal sealed class ConvertImageCommand : Command
{ {
public ConvertImageCommand() : base("convert", "Converts one image to another format.") public ConvertImageCommand() : base("convert", "Converts one image to another format.")
@@ -109,8 +109,7 @@ namespace Aaru.Commands.Image
Required = false Required = false
}); });
Add(new Option("--drive-serial", Add(new Option("--drive-serial", "Serial number of the drive used to read the media represented by the image.")
"Serial number of the drive used to read the media represented by the image.")
{ {
Argument = new Argument<string>(() => null), Argument = new Argument<string>(() => null),
Required = false Required = false
@@ -267,9 +266,9 @@ namespace Aaru.Commands.Image
public static int Invoke(bool verbose, bool debug, string cicmXml, string comments, int count, string creator, public static int Invoke(bool verbose, bool debug, string cicmXml, string comments, int count, string creator,
string driveFirmwareRevision, string driveManufacturer, string driveModel, string driveFirmwareRevision, string driveManufacturer, string driveModel,
string driveSerialNumber, bool force, string inputPath, int lastMediaSequence, string driveSerialNumber, bool force, string inputPath, int lastMediaSequence,
string mediaBarcode, string mediaManufacturer, string mediaModel, string mediaBarcode, string mediaManufacturer, string mediaModel, string mediaPartNumber,
string mediaPartNumber, int mediaSequence, string mediaSerialNumber, string mediaTitle, int mediaSequence, string mediaSerialNumber, string mediaTitle, string outputPath,
string outputPath, string options, string resumeFile, string format, string geometry, string options, string resumeFile, string format, string geometry,
bool fixSubchannelPosition, bool fixSubchannel, bool fixSubchannelCrc, bool fixSubchannelPosition, bool fixSubchannel, bool fixSubchannelCrc,
bool generateSubchannels) bool generateSubchannels)
{ {
@@ -469,11 +468,13 @@ namespace Aaru.Commands.Image
PluginBase plugins = GetPluginBase.Instance; PluginBase plugins = GetPluginBase.Instance;
IMediaImage inputFormat = null; IMediaImage inputFormat = null;
IBaseImage baseImage = null;
Core.Spectre.ProgressSingleSpinner(ctx => Core.Spectre.ProgressSingleSpinner(ctx =>
{ {
ctx.AddTask("Identifying image format...").IsIndeterminate(); ctx.AddTask("Identifying image format...").IsIndeterminate();
inputFormat = ImageFormat.Detect(inputFilter); baseImage = ImageFormat.Detect(inputFilter);
inputFormat = baseImage as IMediaImage;
}); });
if(inputFormat == null) if(inputFormat == null)
@@ -483,6 +484,14 @@ namespace Aaru.Commands.Image
return (int)ErrorNumber.UnrecognizedFormat; return (int)ErrorNumber.UnrecognizedFormat;
} }
// TODO: Implement
if(inputFormat == null)
{
AaruConsole.WriteLine("Command not yet supported for this image type.");
return (int)ErrorNumber.InvalidArgument;
}
if(verbose) if(verbose)
AaruConsole.VerboseWriteLine("Input image format identified by {0} ({1}).", inputFormat.Name, AaruConsole.VerboseWriteLine("Input image format identified by {0} ({1}).", inputFormat.Name,
inputFormat.Id); inputFormat.Id);
@@ -744,8 +753,7 @@ namespace Aaru.Commands.Image
AaruConsole.ErrorWriteLine("Error {0} reading media tag, continuing...", errno); AaruConsole.ErrorWriteLine("Error {0} reading media tag, continuing...", errno);
else else
{ {
AaruConsole.ErrorWriteLine("Error {0} writing media tag, not continuing...", AaruConsole.ErrorWriteLine("Error {0} writing media tag, not continuing...", errno);
errno);
ErrorNumber = errno; ErrorNumber = errno;
} }
@@ -781,8 +789,7 @@ namespace Aaru.Commands.Image
{ {
if(!outputOptical.SetTracks(inputOptical.Tracks)) if(!outputOptical.SetTracks(inputOptical.Tracks))
{ {
AaruConsole.ErrorWriteLine("Error {0} sending tracks list to output image.", AaruConsole.ErrorWriteLine("Error {0} sending tracks list to output image.", outputFormat.ErrorMessage);
outputFormat.ErrorMessage);
return (int)ErrorNumber.WriteError; return (int)ErrorNumber.WriteError;
} }
@@ -844,8 +851,8 @@ namespace Aaru.Commands.Image
if(force) if(force)
AaruConsole. AaruConsole.
ErrorWriteLine("Error {0} reading sector {1}, continuing...", ErrorWriteLine("Error {0} reading sector {1}, continuing...", errno,
errno, doneSectors + track.StartSector); doneSectors + track.StartSector);
else else
{ {
AaruConsole. AaruConsole.
@@ -897,8 +904,8 @@ namespace Aaru.Commands.Image
if(force) if(force)
AaruConsole. AaruConsole.
ErrorWriteLine("Error {0} reading sector {1}, continuing...", ErrorWriteLine("Error {0} reading sector {1}, continuing...", errno,
errno, doneSectors + track.StartSector); doneSectors + track.StartSector);
else else
{ {
AaruConsole. AaruConsole.
@@ -914,8 +921,7 @@ namespace Aaru.Commands.Image
if(!result) if(!result)
if(force) if(force)
AaruConsole. AaruConsole.ErrorWriteLine("Error {0} writing sector {1}, continuing...",
ErrorWriteLine("Error {0} writing sector {1}, continuing...",
outputFormat.ErrorMessage, outputFormat.ErrorMessage,
doneSectors + track.StartSector); doneSectors + track.StartSector);
else else
@@ -970,8 +976,8 @@ namespace Aaru.Commands.Image
tracks[i].Indexes[idx.Key] = idx.Value; tracks[i].Indexes[idx.Key] = idx.Value;
} }
foreach(SectorTagType tag in inputFormat.Info.ReadableSectorTags. foreach(SectorTagType tag in inputFormat.Info.ReadableSectorTags.Where(t => t == SectorTagType.CdTrackIsrc).
Where(t => t == SectorTagType.CdTrackIsrc).OrderBy(t => t)) OrderBy(t => t))
{ {
foreach(Track track in tracks) foreach(Track track in tracks)
{ {
@@ -1006,8 +1012,7 @@ namespace Aaru.Commands.Image
subchannelExtents.Add((int)s); subchannelExtents.Add((int)s);
} }
foreach(SectorTagType tag in inputFormat.Info.ReadableSectorTags.OrderBy(t => t). foreach(SectorTagType tag in inputFormat.Info.ReadableSectorTags.OrderBy(t => t).TakeWhile(tag => useLong))
TakeWhile(tag => useLong))
{ {
switch(tag) switch(tag)
{ {
@@ -1054,6 +1059,7 @@ namespace Aaru.Commands.Image
if(errno == ErrorNumber.NoData) if(errno == ErrorNumber.NoData)
{ {
errno = ErrorNumber.NoError; errno = ErrorNumber.NoError;
continue; continue;
} }
@@ -1063,15 +1069,13 @@ namespace Aaru.Commands.Image
{ {
if(force) if(force)
{ {
AaruConsole. AaruConsole.ErrorWriteLine("Error {0} writing tag, continuing...",
ErrorWriteLine("Error {0} writing tag, continuing...",
outputFormat.ErrorMessage); outputFormat.ErrorMessage);
continue; continue;
} }
AaruConsole. AaruConsole.ErrorWriteLine("Error {0} writing tag, not continuing...",
ErrorWriteLine("Error {0} writing tag, not continuing...",
outputFormat.ErrorMessage); outputFormat.ErrorMessage);
errno = ErrorNumber.WriteError; errno = ErrorNumber.WriteError;
@@ -1081,8 +1085,7 @@ namespace Aaru.Commands.Image
if(!result) if(!result)
if(force) if(force)
AaruConsole. AaruConsole.ErrorWriteLine("Error {0} writing tag, continuing...",
ErrorWriteLine("Error {0} writing tag, continuing...",
outputFormat.ErrorMessage); outputFormat.ErrorMessage);
else else
{ {
@@ -1113,8 +1116,8 @@ namespace Aaru.Commands.Image
trackTask.Description = trackTask.Description =
string.Format("Converting tag {3} for sectors {0} to {1} in track {2}", string.Format("Converting tag {3} for sectors {0} to {1} in track {2}",
doneSectors + track.StartSector, doneSectors + track.StartSector,
doneSectors + sectorsToDo + track.StartSector, doneSectors + sectorsToDo + track.StartSector, track.Sequence,
track.Sequence, tag); tag);
if(sectorsToDo == 1) if(sectorsToDo == 1)
{ {
@@ -1130,9 +1133,9 @@ namespace Aaru.Commands.Image
MmcSubchannel.Raw, sector, MmcSubchannel.Raw, sector,
doneSectors + track.StartSector, 1, null, isrcs, doneSectors + track.StartSector, 1, null, isrcs,
(byte)track.Sequence, ref mcn, tracks, (byte)track.Sequence, ref mcn, tracks,
subchannelExtents, fixSubchannelPosition, subchannelExtents, fixSubchannelPosition, outputFormat,
outputFormat, fixSubchannel, fixSubchannelCrc, fixSubchannel, fixSubchannelCrc, null, null,
null, null, smallestPregapLbaPerTrack, false); smallestPregapLbaPerTrack, false);
if(indexesChanged) if(indexesChanged)
outputOptical.SetTracks(tracks.ToList()); outputOptical.SetTracks(tracks.ToList());
@@ -1176,9 +1179,9 @@ namespace Aaru.Commands.Image
MmcSubchannel.Raw, sector, MmcSubchannel.Raw, sector,
doneSectors + track.StartSector, sectorsToDo, null, doneSectors + track.StartSector, sectorsToDo, null,
isrcs, (byte)track.Sequence, ref mcn, tracks, isrcs, (byte)track.Sequence, ref mcn, tracks,
subchannelExtents, fixSubchannelPosition, subchannelExtents, fixSubchannelPosition, outputFormat,
outputFormat, fixSubchannel, fixSubchannelCrc, fixSubchannel, fixSubchannelCrc, null, null,
null, null, smallestPregapLbaPerTrack, false); smallestPregapLbaPerTrack, false);
if(indexesChanged) if(indexesChanged)
outputOptical.SetTracks(tracks.ToList()); outputOptical.SetTracks(tracks.ToList());
@@ -1236,7 +1239,8 @@ namespace Aaru.Commands.Image
} }
}); });
if(errno != ErrorNumber.NoError && !force) if(errno != ErrorNumber.NoError &&
!force)
return (int)errno; return (int)errno;
} }
@@ -1265,21 +1269,19 @@ namespace Aaru.Commands.Image
inputFormat.Info.MediaType == MediaType.VCD || inputFormat.Info.MediaType == MediaType.SVCD || inputFormat.Info.MediaType == MediaType.VCD || inputFormat.Info.MediaType == MediaType.SVCD ||
inputFormat.Info.MediaType == MediaType.PCD || inputFormat.Info.MediaType == MediaType.DTSCD || inputFormat.Info.MediaType == MediaType.PCD || inputFormat.Info.MediaType == MediaType.DTSCD ||
inputFormat.Info.MediaType == MediaType.CDMIDI || inputFormat.Info.MediaType == MediaType.CDV || inputFormat.Info.MediaType == MediaType.CDMIDI || inputFormat.Info.MediaType == MediaType.CDV ||
inputFormat.Info.MediaType == MediaType.CDIREADY || inputFormat.Info.MediaType == MediaType.CDIREADY || inputFormat.Info.MediaType == MediaType.FMTOWNS ||
inputFormat.Info.MediaType == MediaType.FMTOWNS || inputFormat.Info.MediaType == MediaType.PS1CD || inputFormat.Info.MediaType == MediaType.PS1CD || inputFormat.Info.MediaType == MediaType.PS2CD ||
inputFormat.Info.MediaType == MediaType.PS2CD || inputFormat.Info.MediaType == MediaType.MEGACD || inputFormat.Info.MediaType == MediaType.MEGACD || inputFormat.Info.MediaType == MediaType.SATURNCD ||
inputFormat.Info.MediaType == MediaType.SATURNCD || inputFormat.Info.MediaType == MediaType.GDROM || inputFormat.Info.MediaType == MediaType.GDROM || inputFormat.Info.MediaType == MediaType.GDR ||
inputFormat.Info.MediaType == MediaType.GDR || inputFormat.Info.MediaType == MediaType.MilCD || inputFormat.Info.MediaType == MediaType.MilCD || inputFormat.Info.MediaType == MediaType.SuperCDROM2 ||
inputFormat.Info.MediaType == MediaType.SuperCDROM2 || inputFormat.Info.MediaType == MediaType.JaguarCD || inputFormat.Info.MediaType == MediaType.ThreeDO ||
inputFormat.Info.MediaType == MediaType.JaguarCD || inputFormat.Info.MediaType == MediaType.PCFX || inputFormat.Info.MediaType == MediaType.NeoGeoCD ||
inputFormat.Info.MediaType == MediaType.ThreeDO || inputFormat.Info.MediaType == MediaType.PCFX || inputFormat.Info.MediaType == MediaType.CDTV || inputFormat.Info.MediaType == MediaType.CD32 ||
inputFormat.Info.MediaType == MediaType.NeoGeoCD || inputFormat.Info.MediaType == MediaType.CDTV || inputFormat.Info.MediaType == MediaType.Playdia || inputFormat.Info.MediaType == MediaType.Pippin ||
inputFormat.Info.MediaType == MediaType.CD32 || inputFormat.Info.MediaType == MediaType.Playdia ||
inputFormat.Info.MediaType == MediaType.Pippin ||
inputFormat.Info.MediaType == MediaType.VideoNow || inputFormat.Info.MediaType == MediaType.VideoNow ||
inputFormat.Info.MediaType == MediaType.VideoNowColor || inputFormat.Info.MediaType == MediaType.VideoNowColor ||
inputFormat.Info.MediaType == MediaType.VideoNowXp || inputFormat.Info.MediaType == MediaType.VideoNowXp || inputFormat.Info.MediaType == MediaType.CVD) &&
inputFormat.Info.MediaType == MediaType.CVD) && generateSubchannels) generateSubchannels)
{ {
Core.Spectre.ProgressSingleSpinner(ctx => Core.Spectre.ProgressSingleSpinner(ctx =>
{ {
@@ -1342,23 +1344,20 @@ namespace Aaru.Commands.Image
: inputFormat.ReadSectorsLong(doneSectors, sectorsToDo, out sector); : inputFormat.ReadSectorsLong(doneSectors, sectorsToDo, out sector);
if(errno == ErrorNumber.NoError) if(errno == ErrorNumber.NoError)
result = sectorsToDo == 1 result = sectorsToDo == 1 ? outputFormat.WriteSectorLong(sector, doneSectors)
? outputFormat.WriteSectorLong(sector, doneSectors) : outputFormat.WriteSectorsLong(sector, doneSectors, sectorsToDo);
: outputFormat.WriteSectorsLong(sector, doneSectors,
sectorsToDo);
else else
{ {
result = true; result = true;
if(force) if(force)
AaruConsole. AaruConsole.ErrorWriteLine("Error {0} reading sector {1}, continuing...",
ErrorWriteLine("Error {0} reading sector {1}, continuing...", errno, errno, doneSectors);
doneSectors);
else else
{ {
AaruConsole. AaruConsole.
ErrorWriteLine("Error {0} reading sector {1}, not continuing...", ErrorWriteLine("Error {0} reading sector {1}, not continuing...", errno,
errno, doneSectors); doneSectors);
return; return;
} }
@@ -1377,14 +1376,13 @@ namespace Aaru.Commands.Image
result = true; result = true;
if(force) if(force)
AaruConsole. AaruConsole.ErrorWriteLine("Error {0} reading sector {1}, continuing...",
ErrorWriteLine("Error {0} reading sector {1}, continuing...", errno, errno, doneSectors);
doneSectors);
else else
{ {
AaruConsole. AaruConsole.
ErrorWriteLine("Error {0} reading sector {1}, not continuing...", ErrorWriteLine("Error {0} reading sector {1}, not continuing...", errno,
errno, doneSectors); doneSectors);
return; return;
} }
@@ -1397,8 +1395,7 @@ namespace Aaru.Commands.Image
outputFormat.ErrorMessage, doneSectors); outputFormat.ErrorMessage, doneSectors);
else else
{ {
AaruConsole. AaruConsole.ErrorWriteLine("Error {0} writing sector {1}, not continuing...",
ErrorWriteLine("Error {0} writing sector {1}, not continuing...",
outputFormat.ErrorMessage, doneSectors); outputFormat.ErrorMessage, doneSectors);
errno = ErrorNumber.WriteError; errno = ErrorNumber.WriteError;
@@ -1412,8 +1409,7 @@ namespace Aaru.Commands.Image
mediaTask.StopTask(); mediaTask.StopTask();
foreach(SectorTagType tag in foreach(SectorTagType tag in inputFormat.Info.ReadableSectorTags.TakeWhile(tag => useLong))
inputFormat.Info.ReadableSectorTags.TakeWhile(tag => useLong))
{ {
switch(tag) switch(tag)
{ {
@@ -1454,29 +1450,26 @@ namespace Aaru.Commands.Image
bool result; bool result;
errno = sectorsToDo == 1 errno = sectorsToDo == 1 ? inputFormat.ReadSectorTag(doneSectors, tag, out sector)
? inputFormat.ReadSectorTag(doneSectors, tag, out sector) : inputFormat.ReadSectorsTag(doneSectors, sectorsToDo, tag, out sector);
: inputFormat.ReadSectorsTag(doneSectors, sectorsToDo, tag,
out sector);
if(errno == ErrorNumber.NoError) if(errno == ErrorNumber.NoError)
result = sectorsToDo == 1 result = sectorsToDo == 1
? outputFormat.WriteSectorTag(sector, doneSectors, tag) ? outputFormat.WriteSectorTag(sector, doneSectors, tag)
: outputFormat.WriteSectorsTag(sector, doneSectors, : outputFormat.WriteSectorsTag(sector, doneSectors, sectorsToDo,
sectorsToDo, tag); tag);
else else
{ {
result = true; result = true;
if(force) if(force)
AaruConsole. AaruConsole.ErrorWriteLine("Error {0} reading sector {1}, continuing...",
ErrorWriteLine("Error {0} reading sector {1}, continuing...", errno, errno, doneSectors);
doneSectors);
else else
{ {
AaruConsole. AaruConsole.
ErrorWriteLine("Error {0} reading sector {1}, not continuing...", ErrorWriteLine("Error {0} reading sector {1}, not continuing...", errno,
errno, doneSectors); doneSectors);
return; return;
} }
@@ -1484,8 +1477,7 @@ namespace Aaru.Commands.Image
if(!result) if(!result)
if(force) if(force)
AaruConsole. AaruConsole.ErrorWriteLine("Error {0} writing sector {1}, continuing...",
ErrorWriteLine("Error {0} writing sector {1}, continuing...",
outputFormat.ErrorMessage, doneSectors); outputFormat.ErrorMessage, doneSectors);
else else
{ {
@@ -1598,4 +1590,3 @@ namespace Aaru.Commands.Image
return (int)ErrorNumber.NoError; return (int)ErrorNumber.NoError;
} }
} }
}

View File

@@ -42,8 +42,8 @@ using Aaru.Decoders.CD;
using Aaru.Decoders.SCSI; using Aaru.Decoders.SCSI;
using Spectre.Console; using Spectre.Console;
namespace Aaru.Commands.Image namespace Aaru.Commands.Image;
{
internal sealed class DecodeCommand : Command internal sealed class DecodeCommand : Command
{ {
public DecodeCommand() : base("decode", "Decodes and pretty prints disk and/or sector tags.") public DecodeCommand() : base("decode", "Decodes and pretty prints disk and/or sector tags.")
@@ -94,8 +94,8 @@ namespace Aaru.Commands.Image
Handler = CommandHandler.Create(GetType().GetMethod(nameof(Invoke))); Handler = CommandHandler.Create(GetType().GetMethod(nameof(Invoke)));
} }
public static int Invoke(bool verbose, bool debug, bool diskTags, string imagePath, string length, public static int Invoke(bool verbose, bool debug, bool diskTags, string imagePath, string length, bool sectorTags,
bool sectorTags, ulong startSector) ulong startSector)
{ {
MainClass.PrintCopyright(); MainClass.PrintCopyright();
@@ -151,20 +151,29 @@ namespace Aaru.Commands.Image
} }
IMediaImage inputFormat = null; IMediaImage inputFormat = null;
IBaseImage baseImage = null;
Core.Spectre.ProgressSingleSpinner(ctx => Core.Spectre.ProgressSingleSpinner(ctx =>
{ {
ctx.AddTask("Identifying image format...").IsIndeterminate(); ctx.AddTask("Identifying image format...").IsIndeterminate();
inputFormat = ImageFormat.Detect(inputFilter); baseImage = ImageFormat.Detect(inputFilter);
inputFormat = baseImage as IMediaImage;
}); });
if(inputFormat == null) if(baseImage == null)
{ {
AaruConsole.ErrorWriteLine("Unable to recognize image format, not decoding"); AaruConsole.ErrorWriteLine("Unable to recognize image format, not decoding");
return (int)ErrorNumber.UnrecognizedFormat; return (int)ErrorNumber.UnrecognizedFormat;
} }
if(inputFormat == null)
{
AaruConsole.WriteLine("Command not supported for this image type.");
return (int)ErrorNumber.InvalidArgument;
}
ErrorNumber opened = ErrorNumber.NoData; ErrorNumber opened = ErrorNumber.NoData;
Core.Spectre.ProgressSingleSpinner(ctx => Core.Spectre.ProgressSingleSpinner(ctx =>
@@ -197,8 +206,7 @@ namespace Aaru.Commands.Image
errno = inputFormat.ReadMediaTag(MediaTagType.SCSI_INQUIRY, out byte[] inquiry); errno = inputFormat.ReadMediaTag(MediaTagType.SCSI_INQUIRY, out byte[] inquiry);
if(inquiry == null) if(inquiry == null)
AaruConsole.WriteLine("Error {0} reading SCSI INQUIRY response from disc image", AaruConsole.WriteLine("Error {0} reading SCSI INQUIRY response from disc image", errno);
errno);
else else
{ {
AaruConsole.WriteLine("[bold]SCSI INQUIRY command response:[/]"); AaruConsole.WriteLine("[bold]SCSI INQUIRY command response:[/]");
@@ -219,8 +227,7 @@ namespace Aaru.Commands.Image
errno = inputFormat.ReadMediaTag(MediaTagType.ATA_IDENTIFY, out byte[] identify); errno = inputFormat.ReadMediaTag(MediaTagType.ATA_IDENTIFY, out byte[] identify);
if(errno != ErrorNumber.NoError) if(errno != ErrorNumber.NoError)
AaruConsole. AaruConsole.WriteLine("Error {0} reading ATA IDENTIFY DEVICE response from disc image",
WriteLine("Error {0} reading ATA IDENTIFY DEVICE response from disc image",
errno); errno);
else else
{ {
@@ -388,8 +395,7 @@ namespace Aaru.Commands.Image
break; break;
} }
default: default:
AaruConsole.WriteLine("Decoder for disk tag type \"{0}\" not yet implemented, sorry.", AaruConsole.WriteLine("Decoder for disk tag type \"{0}\" not yet implemented, sorry.", tag);
tag);
break; break;
} }
@@ -415,8 +421,7 @@ namespace Aaru.Commands.Image
switch(tag) switch(tag)
{ {
default: default:
AaruConsole.WriteLine("Decoder for disk tag type \"{0}\" not yet implemented, sorry.", AaruConsole.WriteLine("Decoder for disk tag type \"{0}\" not yet implemented, sorry.", tag);
tag);
break; break;
} }
@@ -427,4 +432,3 @@ namespace Aaru.Commands.Image
return (int)ErrorNumber.NoError; return (int)ErrorNumber.NoError;
} }
} }
}