diff --git a/Aaru/Aaru.csproj b/Aaru/Aaru.csproj
index b52f8109d..a83e8c9c7 100644
--- a/Aaru/Aaru.csproj
+++ b/Aaru/Aaru.csproj
@@ -1,211 +1,211 @@
-
- 2.0
- {7A4B05BE-73C9-4F34-87FE-E80CCF1F732D}
- Exe
- Aaru
- aaru
- $(Version)
- net8.0
- true
- 6.0.0~alpha9
- Claunia.com
- Copyright © 2011-2023 Natalia Portillo
- Aaru Data Preservation Suite
- Aaru
- $(Version)
-
- linux-musl-arm;linux-musl-arm64;linux-musl-x64;linux-arm64;linux-arm;linux-x64;osx-x64;osx-arm64;win-arm64;win-x64;win-x86
- true
- 12
- true
- true
- false
-
-
- $(Version)+{chash:8}
- true
- false
-
-
- -dbg
- CS1591;CS1574
-
-
-
-
-
-
-
-
-
-
- README.md
- PreserveNewest
-
-
- .travis.yml
-
-
- CONTRIBUTING.md
- PreserveNewest
-
-
- NEEDED.md
-
-
- Changelog.md
- PreserveNewest
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- LICENSE.MIT
- PreserveNewest
-
-
- LICENSE.LGPL
- PreserveNewest
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- all
- runtime; build; native; contentfiles; analyzers; buildtransitive
-
-
-
-
-
-
-
- all
- runtime; build; native; contentfiles; analyzers; buildtransitive
-
-
-
-
-
-
-
-
-
-
-
-
+
+ 2.0
+ {7A4B05BE-73C9-4F34-87FE-E80CCF1F732D}
+ Exe
+ Aaru
+ aaru
+ $(Version)
+ net8.0
+ true
+ 6.0.0~alpha9
+ Claunia.com
+ Copyright © 2011-2023 Natalia Portillo
+ Aaru Data Preservation Suite
+ Aaru
+ $(Version)
+
+ linux-musl-arm;linux-musl-arm64;linux-musl-x64;linux-arm64;linux-arm;linux-x64;osx-x64;osx-arm64;win-arm64;win-x64;win-x86
+ true
+ 12
+ true
+ true
+ false
+
+
+ $(Version)+{chash:8}
+ true
+ false
+
+
+ -dbg
+ CS1591;CS1574
+
+
+
+
+
+
+
+
+
+
+ README.md
+ PreserveNewest
+
+
+ .travis.yml
+
+
+ CONTRIBUTING.md
+ PreserveNewest
+
+
+ NEEDED.md
+
+
+ Changelog.md
+ PreserveNewest
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ LICENSE.MIT
+ PreserveNewest
+
+
+ LICENSE.LGPL
+ PreserveNewest
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ all
+ runtime; build; native; contentfiles; analyzers; buildtransitive
+
+
+
+
+
+
+
+ all
+ runtime; build; native; contentfiles; analyzers; buildtransitive
+
+
+
+
+
+
+
+
+
+
+
+
-
- 6.0.0-alpha9
- aaru
- Natalia Portillo <claunia@claunia.com>
-
- Disc image management and creation tool for disks, tapes, optical and solid state media
-
+
+ 6.0.0-alpha9
+ aaru
+ Natalia Portillo <claunia@claunia.com>
+
+ Disc image management and creation tool for disks, tapes, optical and solid state media
+
-
-
- /usr/share/mime/packages/aaruformat.xml
-
-
-
-
- $(PackagePrefix)-$(PackageVersion)_alpine_aarch64$(DebugPackage)
-
+
+
+ /usr/share/mime/packages/aaruformat.xml
+
+
-
- $(PackagePrefix)-$(PackageVersion)_alpine_armhf$(DebugPackage)
-
+
+ $(PackagePrefix)-$(PackageVersion)_alpine_aarch64$(DebugPackage)
+
-
- $(PackagePrefix)-$(PackageVersion)_alpine_x86_64$(DebugPackage)
-
+
+ $(PackagePrefix)-$(PackageVersion)_alpine_armhf$(DebugPackage)
+
-
- $(PackagePrefix)-$(PackageVersion)_linux_arm64$(DebugPackage)
-
+
+ $(PackagePrefix)-$(PackageVersion)_alpine_x86_64$(DebugPackage)
+
-
- $(PackagePrefix)-$(PackageVersion)_linux_armhf$(DebugPackage)
-
-
- $(PackagePrefix)-$(PackageVersion)_linux_amd64$(DebugPackage)
-
+
+ $(PackagePrefix)-$(PackageVersion)_linux_arm64$(DebugPackage)
+
-
- $(PackagePrefix)-$(PackageVersion)_macos$(DebugPackage)
-
+
+ $(PackagePrefix)-$(PackageVersion)_linux_armhf$(DebugPackage)
+
+
+ $(PackagePrefix)-$(PackageVersion)_linux_amd64$(DebugPackage)
+
-
- $(PackagePrefix)-$(PackageVersion)_macos_applesilicon$(DebugPackage)
-
+
+ $(PackagePrefix)-$(PackageVersion)_macos$(DebugPackage)
+
-
- $(PackagePrefix)-$(PackageVersion)_windows_aarch64$(DebugPackage)
-
+
+ $(PackagePrefix)-$(PackageVersion)_macos_applesilicon$(DebugPackage)
+
-
- $(PackagePrefix)-$(PackageVersion)_windows_arm$(DebugPackage)
-
+
+ $(PackagePrefix)-$(PackageVersion)_windows_aarch64$(DebugPackage)
+
-
- $(PackagePrefix)-$(PackageVersion)_windows_x64$(DebugPackage)
-
+
+ $(PackagePrefix)-$(PackageVersion)_windows_arm$(DebugPackage)
+
-
- $(PackagePrefix)-$(PackageVersion)_windows_x86$(DebugPackage)
-
+
+ $(PackagePrefix)-$(PackageVersion)_windows_x64$(DebugPackage)
+
-
+
diff --git a/Aaru/Commands/Archive/Info.cs b/Aaru/Commands/Archive/Info.cs
index 94160a69c..fb4544fc6 100644
--- a/Aaru/Commands/Archive/Info.cs
+++ b/Aaru/Commands/Archive/Info.cs
@@ -69,27 +69,29 @@ sealed class ArchiveInfoCommand : Command
});
AaruConsole.DebugWriteLineEvent += (format, objects) =>
- {
- if(objects is null)
- stderrConsole.MarkupLine(format);
- else
- stderrConsole.MarkupLine(format, objects);
- };
+ {
+ if(objects is null)
+ stderrConsole.MarkupLine(format);
+ else
+ stderrConsole.MarkupLine(format, objects);
+ };
}
if(verbose)
+ {
AaruConsole.WriteEvent += (format, objects) =>
- {
- if(objects is null)
- AnsiConsole.Markup(format);
- else
- AnsiConsole.Markup(format, objects);
- };
+ {
+ if(objects is null)
+ AnsiConsole.Markup(format);
+ else
+ AnsiConsole.Markup(format, objects);
+ };
+ }
Statistics.AddCommand("archive-info");
- AaruConsole.DebugWriteLine(MODULE_NAME, "--debug={0}", debug);
- AaruConsole.DebugWriteLine(MODULE_NAME, "--input={0}", imagePath);
+ AaruConsole.DebugWriteLine(MODULE_NAME, "--debug={0}", debug);
+ AaruConsole.DebugWriteLine(MODULE_NAME, "--input={0}", imagePath);
AaruConsole.DebugWriteLine(MODULE_NAME, "--verbose={0}", verbose);
/* TODO: This is just a stub for now */
diff --git a/Aaru/Commands/Configure.cs b/Aaru/Commands/Configure.cs
index f0ae70f81..1ab16b82d 100644
--- a/Aaru/Commands/Configure.cs
+++ b/Aaru/Commands/Configure.cs
@@ -58,22 +58,24 @@ sealed class ConfigureCommand : Command
});
AaruConsole.DebugWriteLineEvent += (format, objects) =>
- {
- if(objects is null)
- stderrConsole.MarkupLine(format);
- else
- stderrConsole.MarkupLine(format, objects);
- };
+ {
+ if(objects is null)
+ stderrConsole.MarkupLine(format);
+ else
+ stderrConsole.MarkupLine(format, objects);
+ };
}
if(verbose)
+ {
AaruConsole.WriteEvent += (format, objects) =>
- {
- if(objects is null)
- AnsiConsole.Markup(format);
- else
- AnsiConsole.Markup(format, objects);
- };
+ {
+ if(objects is null)
+ AnsiConsole.Markup(format);
+ else
+ AnsiConsole.Markup(format, objects);
+ };
+ }
return DoConfigure(false);
}
@@ -100,7 +102,8 @@ sealed class ConfigureCommand : Command
Settings.Settings.Current.EnableDecryption =
AnsiConsole.Confirm($"[italic]{UI.Do_you_want_to_enable_decryption_of_copy_protected_media_Q}[/]");
- #region Device reports
+ #region Device reports
+
AaruConsole.WriteLine();
AaruConsole.WriteLine(UI.Configure_Device_Report_information_disclaimer);
@@ -114,9 +117,11 @@ sealed class ConfigureCommand : Command
Settings.Settings.Current.ShareReports =
AnsiConsole.Confirm($"[italic]{UI.Do_you_want_to_share_your_device_reports_with_us_Q}[/]");
- #endregion Device reports
- #region Statistics
+ #endregion Device reports
+
+ #region Statistics
+
AaruConsole.WriteLine();
AaruConsole.WriteLine(UI.Statistics_disclaimer);
@@ -151,7 +156,8 @@ sealed class ConfigureCommand : Command
}
else
Settings.Settings.Current.Stats = null;
- #endregion Statistics
+
+ #endregion Statistics
Settings.Settings.Current.GdprCompliance = DicSettings.GDPR_LEVEL;
Settings.Settings.SaveSettings();
diff --git a/Aaru/Commands/Database/Statistics.cs b/Aaru/Commands/Database/Statistics.cs
index 80e5a4260..caf49f4fe 100644
--- a/Aaru/Commands/Database/Statistics.cs
+++ b/Aaru/Commands/Database/Statistics.cs
@@ -59,22 +59,24 @@ sealed class StatisticsCommand : Command
});
AaruConsole.DebugWriteLineEvent += (format, objects) =>
- {
- if(objects is null)
- stderrConsole.MarkupLine(format);
- else
- stderrConsole.MarkupLine(format, objects);
- };
+ {
+ if(objects is null)
+ stderrConsole.MarkupLine(format);
+ else
+ stderrConsole.MarkupLine(format, objects);
+ };
}
if(verbose)
+ {
AaruConsole.WriteEvent += (format, objects) =>
- {
- if(objects is null)
- AnsiConsole.Markup(format);
- else
- AnsiConsole.Markup(format, objects);
- };
+ {
+ if(objects is null)
+ AnsiConsole.Markup(format);
+ else
+ AnsiConsole.Markup(format, objects);
+ };
+ }
var ctx = AaruContext.Create(Settings.Settings.LocalDbPath);
@@ -91,7 +93,7 @@ sealed class StatisticsCommand : Command
return (int)ErrorNumber.NothingFound;
}
- bool thereAreStats = false;
+ var thereAreStats = false;
Table table;
if(ctx.Commands.Any())
@@ -116,19 +118,21 @@ sealed class StatisticsCommand : Command
ulong count = 0;
foreach(Aaru.Database.Models.Command fsInfo in ctx.Commands.Where(c => c.Name == "fs-info" &&
- c.Synchronized))
+ c.Synchronized))
{
count += fsInfo.Count;
ctx.Remove(fsInfo);
}
if(count > 0)
+ {
ctx.Commands.Add(new Aaru.Database.Models.Command
{
Count = count,
Name = "fs-info",
Synchronized = true
});
+ }
ctx.SaveChanges();
}
@@ -281,8 +285,10 @@ sealed class StatisticsCommand : Command
foreach(DeviceStat ds in ctx.SeenDevices.OrderBy(ds => ds.Manufacturer).ThenBy(ds => ds.Model).
ThenBy(ds => ds.Revision).ThenBy(ds => ds.Bus))
+ {
table.AddRow(Markup.Escape(ds.Manufacturer ?? ""), Markup.Escape(ds.Model ?? ""),
Markup.Escape(ds.Revision ?? ""), Markup.Escape(ds.Bus ?? ""));
+ }
AnsiConsole.Write(table);
AaruConsole.WriteLine();
diff --git a/Aaru/Commands/Database/Update.cs b/Aaru/Commands/Database/Update.cs
index e0a9ef299..9faf52df9 100644
--- a/Aaru/Commands/Database/Update.cs
+++ b/Aaru/Commands/Database/Update.cs
@@ -54,7 +54,7 @@ sealed class UpdateCommand : Command
{
_mainDbUpdate = mainDbUpdate;
- Add(new Option("--clear", () => false, UI.Clear_existing_main_database));
+ Add(new Option("--clear", () => false, UI.Clear_existing_main_database));
Add(new Option("--clear-all", () => false, UI.Clear_existing_main_and_local_database));
Handler = CommandHandler.Create((Func)Invoke);
@@ -75,27 +75,30 @@ sealed class UpdateCommand : Command
});
AaruConsole.DebugWriteLineEvent += (format, objects) =>
- {
- if(objects is null)
- stderrConsole.MarkupLine(format);
- else
- stderrConsole.MarkupLine(format, objects);
- };
+ {
+ if(objects is null)
+ stderrConsole.MarkupLine(format);
+ else
+ stderrConsole.MarkupLine(format, objects);
+ };
}
if(verbose)
+ {
AaruConsole.WriteEvent += (format, objects) =>
- {
- if(objects is null)
- AnsiConsole.Markup(format);
- else
- AnsiConsole.Markup(format, objects);
- };
+ {
+ if(objects is null)
+ AnsiConsole.Markup(format);
+ else
+ AnsiConsole.Markup(format, objects);
+ };
+ }
- AaruConsole.DebugWriteLine(MODULE_NAME, "--debug={0}", debug);
+ AaruConsole.DebugWriteLine(MODULE_NAME, "--debug={0}", debug);
AaruConsole.DebugWriteLine(MODULE_NAME, "--verbose={0}", verbose);
if(clearAll)
+ {
try
{
File.Delete(Settings.Settings.LocalDbPath);
@@ -113,8 +116,10 @@ sealed class UpdateCommand : Command
return (int)ErrorNumber.CannotRemoveDatabase;
}
+ }
if(clear || clearAll)
+ {
try
{
File.Delete(Settings.Settings.MainDbPath);
@@ -128,6 +133,7 @@ sealed class UpdateCommand : Command
return (int)ErrorNumber.CannotRemoveDatabase;
}
+ }
DoUpdate(clear || clearAll);
diff --git a/Aaru/Commands/Device/DeviceReport.cs b/Aaru/Commands/Device/DeviceReport.cs
index 362f31b16..1700dd05a 100644
--- a/Aaru/Commands/Device/DeviceReport.cs
+++ b/Aaru/Commands/Device/DeviceReport.cs
@@ -70,10 +70,7 @@ sealed class DeviceReportCommand : Command
Name = "device-path"
});
- Add(new Option(new[]
- {
- "--trap-disc", "-t"
- }, () => false, UI.Device_report_using_trap_disc));
+ Add(new Option(new[] { "--trap-disc", "-t" }, () => false, UI.Device_report_using_trap_disc));
Handler = CommandHandler.Create(GetType().GetMethod(nameof(Invoke)));
}
@@ -90,27 +87,29 @@ sealed class DeviceReportCommand : Command
});
AaruConsole.DebugWriteLineEvent += (format, objects) =>
- {
- if(objects is null)
- stderrConsole.MarkupLine(format);
- else
- stderrConsole.MarkupLine(format, objects);
- };
+ {
+ if(objects is null)
+ stderrConsole.MarkupLine(format);
+ else
+ stderrConsole.MarkupLine(format, objects);
+ };
}
if(verbose)
+ {
AaruConsole.WriteEvent += (format, objects) =>
- {
- if(objects is null)
- AnsiConsole.Markup(format);
- else
- AnsiConsole.Markup(format, objects);
- };
+ {
+ if(objects is null)
+ AnsiConsole.Markup(format);
+ else
+ AnsiConsole.Markup(format, objects);
+ };
+ }
Statistics.AddCommand("device-report");
- AaruConsole.DebugWriteLine(MODULE_NAME, "--debug={0}", debug);
- AaruConsole.DebugWriteLine(MODULE_NAME, "--device={0}", devicePath);
+ AaruConsole.DebugWriteLine(MODULE_NAME, "--debug={0}", debug);
+ AaruConsole.DebugWriteLine(MODULE_NAME, "--device={0}", devicePath);
AaruConsole.DebugWriteLine(MODULE_NAME, "--verbose={0}", verbose);
if(devicePath.Length == 2 &&
@@ -163,7 +162,7 @@ sealed class DeviceReportCommand : Command
Type = dev.Type
};
- bool removable = false;
+ var removable = false;
string jsonFile;
switch(string.IsNullOrWhiteSpace(dev.Manufacturer))
@@ -199,39 +198,48 @@ sealed class DeviceReportCommand : Command
var reporter = new Core.Devices.Report.DeviceReport(dev);
if(dev.IsUsb)
+ {
if(AnsiConsole.Confirm($"[italic]{UI.Is_the_device_natively_USB}[/]"))
{
Core.Spectre.ProgressSingleSpinner(ctx =>
- {
- ctx.AddTask(Localization.Core.Querying_USB_information).IsIndeterminate();
- report.USB = reporter.UsbReport();
- });
+ {
+ ctx.AddTask(Localization.Core.Querying_USB_information).
+ IsIndeterminate();
+ report.USB = reporter.UsbReport();
+ });
report.USB.RemovableMedia = AnsiConsole.Confirm($"[italic]{UI.Is_the_media_removable}[/]");
removable = report.USB.RemovableMedia;
}
+ }
if(dev.IsFireWire)
+ {
if(AnsiConsole.Confirm($"[italic]{UI.Is_the_device_natively_FireWire}[/]"))
{
Core.Spectre.ProgressSingleSpinner(ctx =>
- {
- ctx.AddTask("Querying FireWire information...").IsIndeterminate();
- report.FireWire = reporter.FireWireReport();
- });
+ {
+ ctx.AddTask("Querying FireWire information...").
+ IsIndeterminate();
+ report.FireWire = reporter.FireWireReport();
+ });
report.FireWire.RemovableMedia = AnsiConsole.Confirm($"[italic]{UI.Is_the_media_removable}[/]");
removable = report.FireWire.RemovableMedia;
}
+ }
if(dev.IsPcmcia)
+ {
Core.Spectre.ProgressSingleSpinner(ctx =>
- {
- ctx.AddTask(Localization.Core.Querying_PCMCIA_information).IsIndeterminate();
- report.PCMCIA = reporter.PcmciaReport();
- });
+ {
+ ctx.AddTask(Localization.Core.Querying_PCMCIA_information).
+ IsIndeterminate();
+ report.PCMCIA = reporter.PcmciaReport();
+ });
+ }
byte[] buffer = Array.Empty();
string mediumTypeName;
@@ -242,10 +250,11 @@ sealed class DeviceReportCommand : Command
case DeviceType.ATA:
{
Core.Spectre.ProgressSingleSpinner(ctx =>
- {
- ctx.AddTask(Localization.Core.Querying_ATA_IDENTIFY).IsIndeterminate();
- dev.AtaIdentify(out buffer, out _, dev.Timeout, out _);
- });
+ {
+ ctx.AddTask(Localization.Core.Querying_ATA_IDENTIFY).
+ IsIndeterminate();
+ dev.AtaIdentify(out buffer, out _, dev.Timeout, out _);
+ });
if(!Identify.Decode(buffer).HasValue)
break;
@@ -275,10 +284,11 @@ sealed class DeviceReportCommand : Command
System.Console.ReadKey(true);
Core.Spectre.ProgressSingleSpinner(ctx =>
- {
- ctx.AddTask(Localization.Core.Querying_ATA_IDENTIFY).IsIndeterminate();
- dev.AtaIdentify(out buffer, out _, dev.Timeout, out _);
- });
+ {
+ ctx.AddTask(Localization.Core.Querying_ATA_IDENTIFY).
+ IsIndeterminate();
+ dev.AtaIdentify(out buffer, out _, dev.Timeout, out _);
+ });
report.ATA.Identify = Core.Devices.Report.DeviceReport.ClearIdentify(buffer);
List mediaTests = new();
@@ -316,19 +326,23 @@ sealed class DeviceReportCommand : Command
report.SecureDigital = reporter.MmcSdReport();
break;
- case DeviceType.NVMe: throw new NotImplementedException(Localization.Core.NVMe_devices_not_yet_supported);
+ case DeviceType.NVMe:
+ throw new NotImplementedException(Localization.Core.NVMe_devices_not_yet_supported);
case DeviceType.ATAPI:
Core.Spectre.ProgressSingleSpinner(ctx =>
- {
- ctx.AddTask(Localization.Core.Querying_ATAPI_IDENTIFY).IsIndeterminate();
- dev.AtapiIdentify(out buffer, out _, dev.Timeout, out _);
- });
+ {
+ ctx.AddTask(Localization.Core.Querying_ATAPI_IDENTIFY).
+ IsIndeterminate();
+ dev.AtapiIdentify(out buffer, out _, dev.Timeout, out _);
+ });
if(Identify.Decode(buffer).HasValue)
+ {
report.ATAPI = new Ata
{
Identify = Core.Devices.Report.DeviceReport.ClearIdentify(buffer)
};
+ }
goto case DeviceType.SCSI;
case DeviceType.SCSI:
@@ -342,7 +356,8 @@ sealed class DeviceReportCommand : Command
case PeripheralDeviceTypes.BridgingExpander
when dev.Model.StartsWith("MDM", StringComparison.Ordinal) ||
dev.Model.StartsWith("MDH", StringComparison.Ordinal):
- case PeripheralDeviceTypes.SCSIZonedBlockDevice: break;
+ case PeripheralDeviceTypes.SCSIZonedBlockDevice:
+ break;
default:
{
AaruConsole.ErrorWriteLine(UI.Unsupported_device_type_for_report);
@@ -372,11 +387,12 @@ sealed class DeviceReportCommand : Command
dev.SpcAllowMediumRemoval(out buffer, dev.Timeout, out _);
Core.Spectre.ProgressSingleSpinner(ctx =>
- {
- ctx.AddTask(UI.Asking_drive_to_unload_tape).IsIndeterminate();
+ {
+ ctx.AddTask(UI.Asking_drive_to_unload_tape).
+ IsIndeterminate();
- dev.Unload(out buffer, dev.Timeout, out _);
- });
+ dev.Unload(out buffer, dev.Timeout, out _);
+ });
break;
}
@@ -399,7 +415,7 @@ sealed class DeviceReportCommand : Command
string mediumManufacturer;
byte[] senseBuffer = Array.Empty();
- bool sense = true;
+ var sense = true;
switch(dev.ScsiType)
{
@@ -407,7 +423,7 @@ sealed class DeviceReportCommand : Command
{
if(dev.IsUsb &&
mediumType is MediumTypes.UnknownBlockDevice or MediumTypes.ReadOnlyBlockDevice
- or MediumTypes.ReadWriteBlockDevice)
+ or MediumTypes.ReadWriteBlockDevice)
goto default;
bool iomegaRev = dev.Manufacturer.ToLowerInvariant() == "iomega" && dev.Model.
@@ -453,10 +469,15 @@ sealed class DeviceReportCommand : Command
Features.Separate(report.SCSI.MultiMediaDevice.Features.BinaryData);
if(ftr.Descriptors != null)
- foreach(Profile prof in from desc in ftr.Descriptors where desc.Code == 0x0000
- select Features.Decode_0000(desc.Data) into ftr0000
- where ftr0000 != null from prof in ftr0000.Value.Profiles
+ {
+ foreach(Profile prof in from desc in ftr.Descriptors
+ where desc.Code == 0x0000
+ select Features.Decode_0000(desc.Data)
+ into ftr0000
+ where ftr0000 != null
+ from prof in ftr0000.Value.Profiles
select prof)
+ {
switch(prof.Number)
{
case ProfileNumber.CDROM:
@@ -541,6 +562,8 @@ sealed class DeviceReportCommand : Command
break;
}
+ }
+ }
}
if(cdromMode != null &&
@@ -680,7 +703,10 @@ sealed class DeviceReportCommand : Command
mediaTypes = mediaTypes.Distinct().ToList();
mediaTypes.Sort();
- bool tryPlextor = false, tryHldtst = false, tryPioneer = false, tryNec = false,
+ bool tryPlextor = false,
+ tryHldtst = false,
+ tryPioneer = false,
+ tryNec = false,
tryMediaTekF106 = false;
tryPlextor |= dev.Manufacturer.ToLowerInvariant() == "plextor";
@@ -691,28 +717,36 @@ sealed class DeviceReportCommand : Command
if(!iomegaRev)
{
if(!tryPlextor)
+ {
tryPlextor |=
AnsiConsole.
Confirm($"[italic]{UI.Do_you_want_to_try_Plextor_commands} [red]{UI.This_is_dangerous}[/][/]",
false);
+ }
if(!tryNec)
+ {
tryNec |=
AnsiConsole.
Confirm($"[italic]{UI.Do_you_want_to_try_NEC_commands} [red]{UI.This_is_dangerous}[/][/]",
false);
+ }
if(!tryPioneer)
+ {
tryPioneer |=
AnsiConsole.
Confirm($"[italic]{UI.Do_you_want_to_try_Pioneer_commands} [red]{UI.This_is_dangerous}[/][/]",
false);
+ }
if(!tryHldtst)
+ {
tryHldtst |=
AnsiConsole.
Confirm($"[italic]{UI.Do_you_want_to_try_HLDTST_commands} [red]{UI.This_is_dangerous}[/][/]",
false);
+ }
tryMediaTekF106 =
AnsiConsole.
@@ -735,108 +769,130 @@ sealed class DeviceReportCommand : Command
System.Console.ReadKey(true);
- bool mediaIsRecognized = true;
+ var mediaIsRecognized = true;
Core.Spectre.ProgressSingleSpinner(ctx =>
- {
- ctx.AddTask(Localization.Core.Waiting_for_drive_to_become_ready).IsIndeterminate();
- sense = dev.ScsiTestUnitReady(out senseBuffer, dev.Timeout, out _);
+ {
+ ctx.AddTask(Localization.Core.
+ Waiting_for_drive_to_become_ready).
+ IsIndeterminate();
+ sense = dev.ScsiTestUnitReady(out senseBuffer,
+ dev.Timeout, out _);
- if(!sense)
- return;
+ if(!sense)
+ return;
- DecodedSense? decSense = Sense.Decode(senseBuffer);
+ DecodedSense? decSense =
+ Sense.Decode(senseBuffer);
- if(decSense.HasValue)
- switch(decSense.Value.ASC)
- {
- case 0x3A:
- {
- int leftRetries = 50;
+ if(decSense.HasValue)
+ {
+ switch(decSense.Value.ASC)
+ {
+ case 0x3A:
+ {
+ var leftRetries = 50;
- while(leftRetries > 0)
- {
- Thread.Sleep(2000);
+ while(leftRetries > 0)
+ {
+ Thread.Sleep(2000);
- sense = dev.ScsiTestUnitReady(out senseBuffer, dev.Timeout, out _);
+ sense =
+ dev.
+ ScsiTestUnitReady(out senseBuffer,
+ dev.Timeout,
+ out _);
- if(!sense)
- break;
+ if(!sense)
+ break;
- leftRetries--;
- }
+ leftRetries--;
+ }
- AaruConsole.WriteLine();
+ AaruConsole.WriteLine();
- mediaIsRecognized &= !sense;
+ mediaIsRecognized &= !sense;
- break;
- }
+ break;
+ }
- // These should be trapped by the OS but seems in some cases they're not
- case 0x04 when decSense.Value.ASCQ == 0x01:
- {
- int leftRetries = 50;
+ // These should be trapped by the OS but seems in some cases they're not
+ case 0x04
+ when decSense.Value.ASCQ == 0x01:
+ {
+ var leftRetries = 50;
- while(leftRetries > 0)
- {
- Thread.Sleep(2000);
+ while(leftRetries > 0)
+ {
+ Thread.Sleep(2000);
- sense = dev.ScsiTestUnitReady(out senseBuffer, dev.Timeout, out _);
+ sense =
+ dev.
+ ScsiTestUnitReady(out senseBuffer,
+ dev.Timeout,
+ out _);
- if(!sense)
- break;
+ if(!sense)
+ break;
- leftRetries--;
- }
+ leftRetries--;
+ }
- AaruConsole.WriteLine();
+ AaruConsole.WriteLine();
- mediaIsRecognized &= !sense;
+ mediaIsRecognized &= !sense;
- break;
- }
- case 0x28:
- {
- int leftRetries = 50;
+ break;
+ }
+ case 0x28:
+ {
+ var leftRetries = 50;
- while(leftRetries > 0)
- {
- Thread.Sleep(2000);
+ while(leftRetries > 0)
+ {
+ Thread.Sleep(2000);
- sense = dev.ScsiTestUnitReady(out senseBuffer, dev.Timeout, out _);
+ sense =
+ dev.
+ ScsiTestUnitReady(out senseBuffer,
+ dev.Timeout,
+ out _);
- if(!sense)
- break;
+ if(!sense)
+ break;
- leftRetries--;
- }
+ leftRetries--;
+ }
- AaruConsole.WriteLine();
+ AaruConsole.WriteLine();
- mediaIsRecognized &= !sense;
+ mediaIsRecognized &= !sense;
- break;
- }
- default:
- AaruConsole.DebugWriteLine(MODULE_NAME,
- Localization.Core.Device_not_ready_Sense,
- decSense.Value.SenseKey, decSense.Value.ASC,
- decSense.Value.ASCQ);
+ break;
+ }
+ default:
+ AaruConsole.
+ DebugWriteLine(MODULE_NAME,
+ Localization.Core.
+ Device_not_ready_Sense,
+ decSense.Value.SenseKey,
+ decSense.Value.ASC,
+ decSense.Value.ASCQ);
- mediaIsRecognized = false;
+ mediaIsRecognized = false;
- break;
- }
- else
- {
- AaruConsole.DebugWriteLine(MODULE_NAME,
- Localization.Core.
- Got_sense_status_but_no_sense_buffer);
+ break;
+ }
+ }
+ else
+ {
+ AaruConsole.DebugWriteLine(MODULE_NAME,
+ Localization.Core.
+ Got_sense_status_but_no_sense_buffer);
- mediaIsRecognized = false;
- }
- });
+ mediaIsRecognized = false;
+ }
+ });
var mediaTest = new TestedMedia();
@@ -852,16 +908,18 @@ sealed class DeviceReportCommand : Command
mediaTest.LongBlockSize == mediaTest.BlockSize &&
AnsiConsole.Confirm($"[italic]{Localization.Core.Try_to_find_SCSI_READ_LONG_size
}[/]"))
+ {
AnsiConsole.Progress().AutoClear(true).HideCompleted(true).
Columns(new TaskDescriptionColumn(), new ProgressBarColumn(),
new PercentageColumn()).Start(ctx =>
{
ProgressTask task =
- ctx.AddTask(Localization.Core.Trying_READ_LONG);
+ ctx.AddTask(Localization.Core.
+ Trying_READ_LONG);
task.MaxValue = ushort.MaxValue;
- for(ushort i = (ushort)mediaTest.BlockSize;; i++)
+ for(var i = (ushort)mediaTest.BlockSize;; i++)
{
task.Description =
string.
@@ -871,10 +929,14 @@ sealed class DeviceReportCommand : Command
task.Value = i;
sense = mediaTest.SupportsReadLong16 == true
- ? dev.ReadLong16(out buffer, out senseBuffer,
- false, 0, i, dev.Timeout, out _)
- : dev.ReadLong10(out buffer, out senseBuffer,
- false, false, 0, i, dev.Timeout,
+ ? dev.ReadLong16(out buffer,
+ out senseBuffer,
+ false, 0, i, dev.Timeout,
+ out _)
+ : dev.ReadLong10(out buffer,
+ out senseBuffer,
+ false, false, 0, i,
+ dev.Timeout,
out _);
if(!sense)
@@ -888,17 +950,25 @@ sealed class DeviceReportCommand : Command
break;
}
});
+ }
if(mediaTest.SupportsReadLong == true &&
mediaTest.LongBlockSize != mediaTest.BlockSize)
{
Core.Spectre.ProgressSingleSpinner(ctx =>
- {
- ctx.AddTask(Localization.Core.Trying_SCSI_READ_LONG_10).IsIndeterminate();
+ {
+ ctx.AddTask(Localization.Core.
+ Trying_SCSI_READ_LONG_10).
+ IsIndeterminate();
- sense = dev.ReadLong10(out buffer, out senseBuffer, false, false, 0,
- (ushort)mediaTest.LongBlockSize, dev.Timeout, out _);
- });
+ sense =
+ dev.ReadLong10(out buffer,
+ out senseBuffer, false,
+ false, 0,
+ (ushort)mediaTest.
+ LongBlockSize,
+ dev.Timeout, out _);
+ });
if(!sense)
mediaTest.ReadLong10Data = buffer;
@@ -908,12 +978,18 @@ sealed class DeviceReportCommand : Command
mediaTest.LongBlockSize != mediaTest.BlockSize)
{
Core.Spectre.ProgressSingleSpinner(ctx =>
- {
- ctx.AddTask(Localization.Core.Trying_SCSI_READ_LONG_16).IsIndeterminate();
+ {
+ ctx.AddTask(Localization.Core.
+ Trying_SCSI_READ_LONG_16).
+ IsIndeterminate();
- sense = dev.ReadLong16(out buffer, out senseBuffer, false, 0,
- mediaTest.LongBlockSize.Value, dev.Timeout, out _);
- });
+ sense =
+ dev.ReadLong16(out buffer,
+ out senseBuffer, false, 0,
+ mediaTest.LongBlockSize.
+ Value, dev.Timeout,
+ out _);
+ });
if(!sense)
mediaTest.ReadLong16Data = buffer;
@@ -953,109 +1029,127 @@ sealed class DeviceReportCommand : Command
mediumModel = AnsiConsole.Ask(Localization.Core.Please_write_media_model);
- bool mediaIsRecognized = true;
+ var mediaIsRecognized = true;
Core.Spectre.ProgressSingleSpinner(ctx =>
- {
- ctx.AddTask(Localization.Core.Waiting_for_drive_to_become_ready).IsIndeterminate();
+ {
+ ctx.AddTask(Localization.Core.
+ Waiting_for_drive_to_become_ready).
+ IsIndeterminate();
- sense = dev.ScsiTestUnitReady(out senseBuffer, dev.Timeout, out _);
- AaruConsole.DebugWriteLine(MODULE_NAME, "sense = {0}", sense);
+ sense = dev.ScsiTestUnitReady(out senseBuffer,
+ dev.Timeout, out _);
+ AaruConsole.DebugWriteLine(MODULE_NAME,
+ "sense = {0}", sense);
- if(!sense)
- return;
+ if(!sense)
+ return;
- DecodedSense? decSense = Sense.Decode(senseBuffer);
+ DecodedSense? decSense = Sense.Decode(senseBuffer);
- if(decSense.HasValue)
- switch(decSense.Value.ASC)
- {
- case 0x3A:
- {
- int leftRetries = 50;
+ if(decSense.HasValue)
+ {
+ switch(decSense.Value.ASC)
+ {
+ case 0x3A:
+ {
+ var leftRetries = 50;
- while(leftRetries > 0)
- {
- Thread.Sleep(2000);
+ while(leftRetries > 0)
+ {
+ Thread.Sleep(2000);
- sense = dev.ScsiTestUnitReady(out senseBuffer, dev.Timeout, out _);
+ sense =
+ dev.
+ ScsiTestUnitReady(out senseBuffer,
+ dev.Timeout, out _);
- if(!sense)
- break;
+ if(!sense)
+ break;
- leftRetries--;
- }
+ leftRetries--;
+ }
- AaruConsole.WriteLine();
+ AaruConsole.WriteLine();
- mediaIsRecognized &= !sense;
+ mediaIsRecognized &= !sense;
- break;
- }
+ break;
+ }
- // These should be trapped by the OS but seems in some cases they're not
- case 0x04 when decSense.Value.ASCQ == 0x01:
- {
- int leftRetries = 50;
+ // These should be trapped by the OS but seems in some cases they're not
+ case 0x04 when decSense.Value.ASCQ == 0x01:
+ {
+ var leftRetries = 50;
- while(leftRetries > 0)
- {
- Thread.Sleep(2000);
+ while(leftRetries > 0)
+ {
+ Thread.Sleep(2000);
- sense = dev.ScsiTestUnitReady(out senseBuffer, dev.Timeout, out _);
+ sense =
+ dev.
+ ScsiTestUnitReady(out senseBuffer,
+ dev.Timeout, out _);
- if(!sense)
- break;
+ if(!sense)
+ break;
- leftRetries--;
- }
+ leftRetries--;
+ }
- AaruConsole.WriteLine();
+ AaruConsole.WriteLine();
- mediaIsRecognized &= !sense;
+ mediaIsRecognized &= !sense;
- break;
- }
- case 0x28:
- {
- int leftRetries = 50;
+ break;
+ }
+ case 0x28:
+ {
+ var leftRetries = 50;
- while(leftRetries > 0)
- {
- Thread.Sleep(2000);
+ while(leftRetries > 0)
+ {
+ Thread.Sleep(2000);
- sense = dev.ScsiTestUnitReady(out senseBuffer, dev.Timeout, out _);
+ sense =
+ dev.
+ ScsiTestUnitReady(out senseBuffer,
+ dev.Timeout, out _);
- if(!sense)
- break;
+ if(!sense)
+ break;
- leftRetries--;
- }
+ leftRetries--;
+ }
- AaruConsole.WriteLine();
+ AaruConsole.WriteLine();
- mediaIsRecognized &= !sense;
+ mediaIsRecognized &= !sense;
- break;
- }
- default:
- AaruConsole.DebugWriteLine(MODULE_NAME,
- Localization.Core.Device_not_ready_Sense,
- decSense.Value.SenseKey, decSense.Value.ASC,
- decSense.Value.ASCQ);
+ break;
+ }
+ default:
+ AaruConsole.DebugWriteLine(MODULE_NAME,
+ Localization.Core.
+ Device_not_ready_Sense,
+ decSense.Value.SenseKey,
+ decSense.Value.ASC,
+ decSense.Value.ASCQ);
- mediaIsRecognized = false;
+ mediaIsRecognized = false;
- break;
- }
- else
- {
- AaruConsole.DebugWriteLine(MODULE_NAME,
- Localization.Core.Got_sense_status_but_no_sense_buffer);
+ break;
+ }
+ }
+ else
+ {
+ AaruConsole.DebugWriteLine(MODULE_NAME,
+ Localization.Core.
+ Got_sense_status_but_no_sense_buffer);
- mediaIsRecognized = false;
- }
- });
+ mediaIsRecognized = false;
+ }
+ });
var seqTest = new TestedSequentialMedia();
@@ -1070,12 +1164,14 @@ sealed class DeviceReportCommand : Command
seqTests.Add(seqTest);
Core.Spectre.ProgressSingleSpinner(ctx =>
- {
- ctx.AddTask(UI.Asking_drive_to_unload_tape).IsIndeterminate();
+ {
+ ctx.AddTask(UI.Asking_drive_to_unload_tape).
+ IsIndeterminate();
- dev.SpcAllowMediumRemoval(out buffer, dev.Timeout, out _);
- dev.Unload(out buffer, dev.Timeout, out _);
- });
+ dev.SpcAllowMediumRemoval(out buffer, dev.Timeout,
+ out _);
+ dev.Unload(out buffer, dev.Timeout, out _);
+ });
}
report.SCSI.SequentialDevice.TestedMedia = seqTests;
@@ -1108,102 +1204,119 @@ sealed class DeviceReportCommand : Command
System.Console.ReadKey(true);
- bool mediaIsRecognized = true;
+ var mediaIsRecognized = true;
Core.Spectre.ProgressSingleSpinner(ctx =>
- {
- ctx.AddTask(Localization.Core.Waiting_for_drive_to_become_ready).IsIndeterminate();
+ {
+ ctx.AddTask(Localization.Core.
+ Waiting_for_drive_to_become_ready).
+ IsIndeterminate();
- sense = dev.ScsiTestUnitReady(out senseBuffer, dev.Timeout, out _);
+ sense = dev.ScsiTestUnitReady(out senseBuffer,
+ dev.Timeout, out _);
- if(!sense)
- return;
+ if(!sense)
+ return;
- DecodedSense? decSense = Sense.Decode(senseBuffer);
+ DecodedSense? decSense = Sense.Decode(senseBuffer);
- if(decSense.HasValue)
- switch(decSense.Value.ASC)
- {
- case 0x3A:
- {
- int leftRetries = 50;
+ if(decSense.HasValue)
+ {
+ switch(decSense.Value.ASC)
+ {
+ case 0x3A:
+ {
+ var leftRetries = 50;
- while(leftRetries > 0)
- {
- Thread.Sleep(2000);
+ while(leftRetries > 0)
+ {
+ Thread.Sleep(2000);
- sense = dev.ScsiTestUnitReady(out senseBuffer, dev.Timeout, out _);
+ sense =
+ dev.
+ ScsiTestUnitReady(out senseBuffer,
+ dev.Timeout, out _);
- if(!sense)
- break;
+ if(!sense)
+ break;
- leftRetries--;
- }
+ leftRetries--;
+ }
- mediaIsRecognized &= !sense;
+ mediaIsRecognized &= !sense;
- break;
- }
+ break;
+ }
- // These should be trapped by the OS but seems in some cases they're not
- case 0x04 when decSense.Value.ASCQ == 0x01:
- {
- int leftRetries = 50;
+ // These should be trapped by the OS but seems in some cases they're not
+ case 0x04 when decSense.Value.ASCQ == 0x01:
+ {
+ var leftRetries = 50;
- while(leftRetries > 0)
- {
- Thread.Sleep(2000);
+ while(leftRetries > 0)
+ {
+ Thread.Sleep(2000);
- sense = dev.ScsiTestUnitReady(out senseBuffer, dev.Timeout, out _);
+ sense =
+ dev.
+ ScsiTestUnitReady(out senseBuffer,
+ dev.Timeout, out _);
- if(!sense)
- break;
+ if(!sense)
+ break;
- leftRetries--;
- }
+ leftRetries--;
+ }
- mediaIsRecognized &= !sense;
+ mediaIsRecognized &= !sense;
- break;
- }
- case 0x28:
- {
- int leftRetries = 50;
+ break;
+ }
+ case 0x28:
+ {
+ var leftRetries = 50;
- while(leftRetries > 0)
- {
- Thread.Sleep(2000);
+ while(leftRetries > 0)
+ {
+ Thread.Sleep(2000);
- sense = dev.ScsiTestUnitReady(out senseBuffer, dev.Timeout, out _);
+ sense =
+ dev.
+ ScsiTestUnitReady(out senseBuffer,
+ dev.Timeout, out _);
- if(!sense)
- break;
+ if(!sense)
+ break;
- leftRetries--;
- }
+ leftRetries--;
+ }
- mediaIsRecognized &= !sense;
+ mediaIsRecognized &= !sense;
- break;
- }
- default:
- AaruConsole.DebugWriteLine(MODULE_NAME,
- Localization.Core.Device_not_ready_Sense,
- decSense.Value.SenseKey, decSense.Value.ASC,
- decSense.Value.ASCQ);
+ break;
+ }
+ default:
+ AaruConsole.DebugWriteLine(MODULE_NAME,
+ Localization.Core.
+ Device_not_ready_Sense,
+ decSense.Value.SenseKey,
+ decSense.Value.ASC,
+ decSense.Value.ASCQ);
- mediaIsRecognized = false;
+ mediaIsRecognized = false;
- break;
- }
- else
- {
- AaruConsole.DebugWriteLine(MODULE_NAME,
- Localization.Core.Got_sense_status_but_no_sense_buffer);
+ break;
+ }
+ }
+ else
+ {
+ AaruConsole.DebugWriteLine(MODULE_NAME,
+ Localization.Core.
+ Got_sense_status_but_no_sense_buffer);
- mediaIsRecognized = false;
- }
- });
+ mediaIsRecognized = false;
+ }
+ });
var mediaTest = new TestedMedia();
@@ -1218,15 +1331,17 @@ sealed class DeviceReportCommand : Command
mediaTest.LongBlockSize == mediaTest.BlockSize &&
AnsiConsole.Confirm($"[italic]{Localization.Core.Try_to_find_SCSI_READ_LONG_size
}[/]"))
+ {
AnsiConsole.Progress().AutoClear(true).HideCompleted(true).
Columns(new TaskDescriptionColumn(), new ProgressBarColumn(),
new PercentageColumn()).Start(ctx =>
{
- ProgressTask task = ctx.AddTask(Localization.Core.Trying_READ_LONG);
+ ProgressTask task =
+ ctx.AddTask(Localization.Core.Trying_READ_LONG);
task.MaxValue = ushort.MaxValue;
- for(ushort i = (ushort)mediaTest.BlockSize;; i++)
+ for(var i = (ushort)mediaTest.BlockSize;; i++)
{
task.Value = i;
@@ -1236,10 +1351,13 @@ sealed class DeviceReportCommand : Command
i);
sense = mediaTest.SupportsReadLong16 == true
- ? dev.ReadLong16(out buffer, out senseBuffer, false,
+ ? dev.ReadLong16(out buffer,
+ out senseBuffer, false,
0, i, dev.Timeout, out _)
- : dev.ReadLong10(out buffer, out senseBuffer, false,
- false, 0, i, dev.Timeout, out _);
+ : dev.ReadLong10(out buffer,
+ out senseBuffer, false,
+ false, 0, i, dev.Timeout,
+ out _);
if(!sense)
{
@@ -1254,17 +1372,24 @@ sealed class DeviceReportCommand : Command
AaruConsole.WriteLine();
});
+ }
if(mediaTest.SupportsReadLong == true &&
mediaTest.LongBlockSize != mediaTest.BlockSize)
{
Core.Spectre.ProgressSingleSpinner(ctx =>
- {
- ctx.AddTask(Localization.Core.Trying_SCSI_READ_LONG_10).IsIndeterminate();
+ {
+ ctx.AddTask(Localization.Core.
+ Trying_SCSI_READ_LONG_10).
+ IsIndeterminate();
- sense = dev.ReadLong10(out buffer, out senseBuffer, false, false, 0,
- (ushort)mediaTest.LongBlockSize, dev.Timeout, out _);
- });
+ sense =
+ dev.ReadLong10(out buffer,
+ out senseBuffer, false, false,
+ 0,
+ (ushort)mediaTest.LongBlockSize,
+ dev.Timeout, out _);
+ });
if(!sense)
mediaTest.ReadLong10Data = buffer;
@@ -1274,12 +1399,17 @@ sealed class DeviceReportCommand : Command
mediaTest.LongBlockSize != mediaTest.BlockSize)
{
Core.Spectre.ProgressSingleSpinner(ctx =>
- {
- ctx.AddTask(Localization.Core.Trying_SCSI_READ_LONG_16).IsIndeterminate();
+ {
+ ctx.AddTask(Localization.Core.
+ Trying_SCSI_READ_LONG_16).
+ IsIndeterminate();
- sense = dev.ReadLong16(out buffer, out senseBuffer, false, 0,
- (ushort)mediaTest.LongBlockSize, dev.Timeout, out _);
- });
+ sense =
+ dev.ReadLong16(out buffer,
+ out senseBuffer, false, 0,
+ (ushort)mediaTest.LongBlockSize,
+ dev.Timeout, out _);
+ });
if(!sense)
mediaTest.ReadLong16Data = buffer;
@@ -1329,69 +1459,84 @@ sealed class DeviceReportCommand : Command
mediumModel = AnsiConsole.Ask(Localization.Core.Please_write_media_model);
- bool mediaIsRecognized = true;
+ var mediaIsRecognized = true;
Core.Spectre.ProgressSingleSpinner(ctx =>
- {
- ctx.AddTask(Localization.Core.Waiting_for_drive_to_become_ready).IsIndeterminate();
- sense = dev.ScsiTestUnitReady(out senseBuffer, dev.Timeout, out _);
+ {
+ ctx.AddTask(Localization.Core.
+ Waiting_for_drive_to_become_ready).
+ IsIndeterminate();
+ sense = dev.ScsiTestUnitReady(out senseBuffer,
+ dev.Timeout, out _);
- if(!sense)
- return;
+ if(!sense)
+ return;
- DecodedSense? decSense = Sense.Decode(senseBuffer);
+ DecodedSense? decSense =
+ Sense.Decode(senseBuffer);
- if(decSense.HasValue)
- switch(decSense.Value.ASC)
- {
- case 0x3A:
- {
- int leftRetries = 20;
+ if(decSense.HasValue)
+ {
+ switch(decSense.Value.ASC)
+ {
+ case 0x3A:
+ {
+ var leftRetries = 20;
- while(leftRetries > 0)
- {
- Thread.Sleep(2000);
+ while(leftRetries > 0)
+ {
+ Thread.Sleep(2000);
- sense = dev.ScsiTestUnitReady(out senseBuffer, dev.Timeout, out _);
+ sense =
+ dev.
+ ScsiTestUnitReady(out senseBuffer,
+ dev.Timeout,
+ out _);
- if(!sense)
- break;
+ if(!sense)
+ break;
- leftRetries--;
- }
+ leftRetries--;
+ }
- mediaIsRecognized &= !sense;
+ mediaIsRecognized &= !sense;
- break;
- }
- case 0x04 when decSense.Value.ASCQ == 0x01:
- {
- int leftRetries = 20;
+ break;
+ }
+ case 0x04
+ when decSense.Value.ASCQ == 0x01:
+ {
+ var leftRetries = 20;
- while(leftRetries > 0)
- {
- Thread.Sleep(2000);
+ while(leftRetries > 0)
+ {
+ Thread.Sleep(2000);
- sense = dev.ScsiTestUnitReady(out senseBuffer, dev.Timeout, out _);
+ sense =
+ dev.
+ ScsiTestUnitReady(out senseBuffer,
+ dev.Timeout,
+ out _);
- if(!sense)
- break;
+ if(!sense)
+ break;
- leftRetries--;
- }
+ leftRetries--;
+ }
- mediaIsRecognized &= !sense;
+ mediaIsRecognized &= !sense;
- break;
- }
- default:
- mediaIsRecognized = false;
+ break;
+ }
+ default:
+ mediaIsRecognized = false;
- break;
- }
- else
- mediaIsRecognized = false;
- });
+ break;
+ }
+ }
+ else
+ mediaIsRecognized = false;
+ });
var mediaTest = new TestedMedia();
@@ -1403,16 +1548,18 @@ sealed class DeviceReportCommand : Command
mediaTest.LongBlockSize == mediaTest.BlockSize &&
AnsiConsole.Confirm($"[italic]{Localization.Core.Try_to_find_SCSI_READ_LONG_size
}[/]"))
+ {
AnsiConsole.Progress().AutoClear(true).HideCompleted(true).
Columns(new TaskDescriptionColumn(), new ProgressBarColumn(),
new PercentageColumn()).Start(ctx =>
{
ProgressTask task =
- ctx.AddTask(Localization.Core.Trying_READ_LONG);
+ ctx.AddTask(Localization.Core.
+ Trying_READ_LONG);
task.MaxValue = ushort.MaxValue;
- for(ushort i = (ushort)mediaTest.BlockSize;; i++)
+ for(var i = (ushort)mediaTest.BlockSize;; i++)
{
task.Value = i;
@@ -1422,10 +1569,14 @@ sealed class DeviceReportCommand : Command
i);
sense = mediaTest.SupportsReadLong16 == true
- ? dev.ReadLong16(out buffer, out senseBuffer,
- false, 0, i, dev.Timeout, out _)
- : dev.ReadLong10(out buffer, out senseBuffer,
- false, false, 0, i, dev.Timeout,
+ ? dev.ReadLong16(out buffer,
+ out senseBuffer,
+ false, 0, i, dev.Timeout,
+ out _)
+ : dev.ReadLong10(out buffer,
+ out senseBuffer,
+ false, false, 0, i,
+ dev.Timeout,
out _);
if(!sense)
@@ -1441,17 +1592,25 @@ sealed class DeviceReportCommand : Command
AaruConsole.WriteLine();
});
+ }
if(mediaTest.SupportsReadLong == true &&
mediaTest.LongBlockSize != mediaTest.BlockSize)
{
Core.Spectre.ProgressSingleSpinner(ctx =>
- {
- ctx.AddTask(Localization.Core.Trying_SCSI_READ_LONG_10).IsIndeterminate();
+ {
+ ctx.AddTask(Localization.Core.
+ Trying_SCSI_READ_LONG_10).
+ IsIndeterminate();
- sense = dev.ReadLong10(out buffer, out senseBuffer, false, false, 0,
- (ushort)mediaTest.LongBlockSize, dev.Timeout, out _);
- });
+ sense =
+ dev.ReadLong10(out buffer,
+ out senseBuffer, false,
+ false, 0,
+ (ushort)mediaTest.
+ LongBlockSize,
+ dev.Timeout, out _);
+ });
if(!sense)
mediaTest.ReadLong10Data = buffer;
@@ -1461,12 +1620,18 @@ sealed class DeviceReportCommand : Command
mediaTest.LongBlockSize != mediaTest.BlockSize)
{
Core.Spectre.ProgressSingleSpinner(ctx =>
- {
- ctx.AddTask(Localization.Core.Trying_SCSI_READ_LONG_16).IsIndeterminate();
+ {
+ ctx.AddTask(Localization.Core.
+ Trying_SCSI_READ_LONG_16).
+ IsIndeterminate();
- sense = dev.ReadLong16(out buffer, out senseBuffer, false, 0,
- (ushort)mediaTest.LongBlockSize, dev.Timeout, out _);
- });
+ sense =
+ dev.ReadLong16(out buffer,
+ out senseBuffer, false, 0,
+ (ushort)mediaTest.
+ LongBlockSize,
+ dev.Timeout, out _);
+ });
if(!sense)
mediaTest.ReadLong16Data = buffer;
@@ -1493,17 +1658,22 @@ sealed class DeviceReportCommand : Command
if((report.SCSI.ReadCapabilities.SupportsReadLong == true ||
report.SCSI.ReadCapabilities.SupportsReadLong16 == true) &&
report.SCSI.ReadCapabilities.LongBlockSize == report.SCSI.ReadCapabilities.BlockSize)
+ {
if(AnsiConsole.Confirm($"[italic]{Localization.Core.Try_to_find_SCSI_READ_LONG_size
}[/]"))
+ {
AnsiConsole.Progress().AutoClear(true).HideCompleted(true).
Columns(new TaskDescriptionColumn(), new ProgressBarColumn(),
new PercentageColumn()).Start(ctx =>
{
- ProgressTask task = ctx.AddTask(Localization.Core.Trying_READ_LONG);
+ ProgressTask task =
+ ctx.AddTask(Localization.Core.Trying_READ_LONG);
task.MaxValue = ushort.MaxValue;
- for(ushort i = (ushort)report.SCSI.ReadCapabilities.BlockSize;; i++)
+ for(var i = (ushort)report.SCSI.ReadCapabilities.
+ BlockSize;;
+ i++)
{
task.Value = i;
@@ -1512,11 +1682,15 @@ sealed class DeviceReportCommand : Command
Format(Localization.Core.Trying_READ_LONG_with_size_0,
i);
- sense = report.SCSI.ReadCapabilities.SupportsReadLong16 == true
- ? dev.ReadLong16(out buffer, out senseBuffer, false,
+ sense = report.SCSI.ReadCapabilities.
+ SupportsReadLong16 == true
+ ? dev.ReadLong16(out buffer,
+ out senseBuffer, false,
0, i, dev.Timeout, out _)
- : dev.ReadLong10(out buffer, out senseBuffer, false,
- false, 0, i, dev.Timeout, out _);
+ : dev.ReadLong10(out buffer,
+ out senseBuffer, false,
+ false, 0, i, dev.Timeout,
+ out _);
if(!sense)
{
@@ -1531,18 +1705,25 @@ sealed class DeviceReportCommand : Command
AaruConsole.WriteLine();
});
+ }
+ }
if(report.SCSI.ReadCapabilities.SupportsReadLong == true &&
report.SCSI.ReadCapabilities.LongBlockSize != report.SCSI.ReadCapabilities.BlockSize)
{
Core.Spectre.ProgressSingleSpinner(ctx =>
- {
- ctx.AddTask(Localization.Core.Trying_SCSI_READ_LONG_10).IsIndeterminate();
+ {
+ ctx.AddTask(Localization.Core.
+ Trying_SCSI_READ_LONG_10).
+ IsIndeterminate();
- sense = dev.ReadLong10(out buffer, out senseBuffer, false, false, 0,
- (ushort)report.SCSI.ReadCapabilities.LongBlockSize,
- dev.Timeout, out _);
- });
+ sense =
+ dev.ReadLong10(out buffer, out senseBuffer,
+ false, false, 0,
+ (ushort)report.SCSI.
+ ReadCapabilities.LongBlockSize,
+ dev.Timeout, out _);
+ });
if(!sense)
report.SCSI.ReadCapabilities.ReadLong10Data = buffer;
@@ -1552,13 +1733,18 @@ sealed class DeviceReportCommand : Command
report.SCSI.ReadCapabilities.LongBlockSize != report.SCSI.ReadCapabilities.BlockSize)
{
Core.Spectre.ProgressSingleSpinner(ctx =>
- {
- ctx.AddTask(Localization.Core.Trying_SCSI_READ_LONG_16).IsIndeterminate();
+ {
+ ctx.AddTask(Localization.Core.
+ Trying_SCSI_READ_LONG_16).
+ IsIndeterminate();
- sense = dev.ReadLong16(out buffer, out senseBuffer, false, 0,
- report.SCSI.ReadCapabilities.LongBlockSize.Value,
- dev.Timeout, out _);
- });
+ sense =
+ dev.ReadLong16(out buffer, out senseBuffer,
+ false, 0,
+ report.SCSI.ReadCapabilities.
+ LongBlockSize.Value,
+ dev.Timeout, out _);
+ });
if(!sense)
report.SCSI.ReadCapabilities.ReadLong16Data = buffer;
@@ -1570,7 +1756,8 @@ sealed class DeviceReportCommand : Command
}
break;
- default: throw new NotSupportedException(Localization.Core.Unknown_device_type);
+ default:
+ throw new NotSupportedException(Localization.Core.Unknown_device_type);
}
var jsonFs = new FileStream(jsonFile, FileMode.Create);
diff --git a/Aaru/Commands/Device/Info.cs b/Aaru/Commands/Device/Info.cs
index 4fb74c83b..c7dcb304e 100644
--- a/Aaru/Commands/Device/Info.cs
+++ b/Aaru/Commands/Device/Info.cs
@@ -68,10 +68,7 @@ sealed class DeviceInfoCommand : Command
public DeviceInfoCommand() : base("info", UI.Device_Info_Command_Description)
{
- Add(new Option(new[]
- {
- "--output-prefix", "-w"
- }, () => null, UI.Prefix_for_saving_binary_information));
+ Add(new Option(new[] { "--output-prefix", "-w" }, () => null, UI.Prefix_for_saving_binary_information));
AddArgument(new Argument
{
@@ -95,29 +92,31 @@ sealed class DeviceInfoCommand : Command
});
AaruConsole.DebugWriteLineEvent += (format, objects) =>
- {
- if(objects is null)
- stderrConsole.MarkupLine(format);
- else
- stderrConsole.MarkupLine(format, objects);
- };
+ {
+ if(objects is null)
+ stderrConsole.MarkupLine(format);
+ else
+ stderrConsole.MarkupLine(format, objects);
+ };
}
if(verbose)
+ {
AaruConsole.WriteEvent += (format, objects) =>
- {
- if(objects is null)
- AnsiConsole.Markup(format);
- else
- AnsiConsole.Markup(format, objects);
- };
+ {
+ if(objects is null)
+ AnsiConsole.Markup(format);
+ else
+ AnsiConsole.Markup(format, objects);
+ };
+ }
Statistics.AddCommand("device-info");
- AaruConsole.DebugWriteLine(MODULE_NAME, "--debug={0}", debug);
- AaruConsole.DebugWriteLine(MODULE_NAME, "--device={0}", devicePath);
+ AaruConsole.DebugWriteLine(MODULE_NAME, "--debug={0}", debug);
+ AaruConsole.DebugWriteLine(MODULE_NAME, "--device={0}", devicePath);
AaruConsole.DebugWriteLine(MODULE_NAME, "--output-prefix={0}", outputPrefix);
- AaruConsole.DebugWriteLine(MODULE_NAME, "--verbose={0}", verbose);
+ AaruConsole.DebugWriteLine(MODULE_NAME, "--verbose={0}", verbose);
if(devicePath.Length == 2 &&
devicePath[1] == ':' &&
@@ -167,11 +166,11 @@ sealed class DeviceInfoCommand : Command
if(dev.UsbDescriptors != null)
table.AddRow(UI.Title_Descriptor_size, $"{dev.UsbDescriptors.Length}");
- table.AddRow(UI.Title_Vendor_ID, $"{dev.UsbVendorId:X4}");
- table.AddRow(UI.Title_Product_ID, $"{dev.UsbProductId:X4}");
- table.AddRow(UI.Title_Manufacturer, Markup.Escape(dev.UsbManufacturerString ?? ""));
- table.AddRow(UI.Title_Product, Markup.Escape(dev.UsbProductString ?? ""));
- table.AddRow(UI.Title_Serial_number, Markup.Escape(dev.UsbSerialString ?? ""));
+ table.AddRow(UI.Title_Vendor_ID, $"{dev.UsbVendorId:X4}");
+ table.AddRow(UI.Title_Product_ID, $"{dev.UsbProductId:X4}");
+ table.AddRow(UI.Title_Manufacturer, Markup.Escape(dev.UsbManufacturerString ?? ""));
+ table.AddRow(UI.Title_Product, Markup.Escape(dev.UsbProductString ?? ""));
+ table.AddRow(UI.Title_Serial_number, Markup.Escape(dev.UsbSerialString ?? ""));
AnsiConsole.Write(table);
AaruConsole.WriteLine();
@@ -190,10 +189,10 @@ sealed class DeviceInfoCommand : Command
table.Columns[0].RightAligned();
table.AddRow(UI.Title_Vendor_ID, $"{dev.FireWireVendor:X6}");
- table.AddRow(UI.Title_Model_ID, $"{dev.FireWireModel:X6}");
- table.AddRow(UI.Title_Vendor, $"{Markup.Escape(dev.FireWireVendorName ?? "")}");
- table.AddRow(UI.Title_Model, $"{Markup.Escape(dev.FireWireModelName ?? "")}");
- table.AddRow(UI.Title_GUID, $"{dev.FireWireGuid:X16}");
+ table.AddRow(UI.Title_Model_ID, $"{dev.FireWireModel:X6}");
+ table.AddRow(UI.Title_Vendor, $"{Markup.Escape(dev.FireWireVendorName ?? "")}");
+ table.AddRow(UI.Title_Model, $"{Markup.Escape(dev.FireWireModelName ?? "")}");
+ table.AddRow(UI.Title_GUID, $"{dev.FireWireGuid:X16}");
AnsiConsole.Write(table);
AaruConsole.WriteLine();
@@ -206,11 +205,14 @@ sealed class DeviceInfoCommand : Command
Tuple[] tuples = CIS.GetTuples(dev.Cis);
if(tuples != null)
+ {
foreach(Tuple tuple in tuples)
+ {
switch(tuple.Code)
{
case TupleCodes.CISTPL_NULL:
- case TupleCodes.CISTPL_END: break;
+ case TupleCodes.CISTPL_END:
+ break;
case TupleCodes.CISTPL_DEVICEGEO:
case TupleCodes.CISTPL_DEVICEGEO_A:
AaruConsole.WriteLine("{0}", CIS.PrettifyDeviceGeometryTuple(tuple));
@@ -268,6 +270,8 @@ sealed class DeviceInfoCommand : Command
break;
}
+ }
+ }
else
AaruConsole.DebugWriteLine(MODULE_NAME, Localization.Core.Could_not_get_tuples);
}
@@ -318,8 +322,8 @@ sealed class DeviceInfoCommand : Command
if((devInfo.AtaMcptError.Value.DeviceHead & 0x08) == 0x08)
AaruConsole.WriteLine(Localization.Core.Media_card_is_write_protected);
- ushort specificData = (ushort)((devInfo.AtaMcptError.Value.CylinderHigh * 0x100) +
- devInfo.AtaMcptError.Value.CylinderLow);
+ var specificData = (ushort)(devInfo.AtaMcptError.Value.CylinderHigh * 0x100 +
+ devInfo.AtaMcptError.Value.CylinderLow);
if(specificData != 0)
AaruConsole.WriteLine(Localization.Core.Card_specific_data_0, specificData);
@@ -332,8 +336,10 @@ sealed class DeviceInfoCommand : Command
ulong blocks;
if(ataid is { CurrentCylinders: > 0, CurrentHeads: > 0, CurrentSectorsPerTrack: > 0 })
+ {
blocks = (ulong)Math.Max(ataid.CurrentCylinders * ataid.CurrentHeads * ataid.CurrentSectorsPerTrack,
ataid.CurrentSectors);
+ }
else
blocks = (ulong)(ataid.Cylinders * ataid.Heads * ataid.SectorsPerTrack);
@@ -375,7 +381,9 @@ sealed class DeviceInfoCommand : Command
AaruConsole.WriteLine(Inquiry.Prettify(devInfo.ScsiInquiry));
if(devInfo.ScsiEvpdPages != null)
+ {
foreach(KeyValuePair page in devInfo.ScsiEvpdPages)
+ {
switch(page.Key)
{
case >= 0x01 and <= 0x7F:
@@ -563,19 +571,27 @@ sealed class DeviceInfoCommand : Command
break;
}
}
+ }
+ }
if(devInfo.ScsiModeSense6 != null)
+ {
DataFile.WriteTo(MODULE_NAME, outputPrefix, "_scsi_modesense6.bin", "SCSI MODE SENSE",
devInfo.ScsiModeSense6);
+ }
if(devInfo.ScsiModeSense10 != null)
+ {
DataFile.WriteTo(MODULE_NAME, outputPrefix, "_scsi_modesense10.bin", "SCSI MODE SENSE",
devInfo.ScsiModeSense10);
+ }
if(devInfo.ScsiMode.HasValue)
+ {
PrintScsiModePages.Print(devInfo.ScsiMode.Value,
(PeripheralDeviceTypes)devInfo.ScsiInquiry.Value.PeripheralDeviceType,
devInfo.ScsiInquiry.Value.VendorIdentification);
+ }
if(devInfo.MmcConfiguration != null)
{
@@ -841,8 +857,10 @@ sealed class DeviceInfoCommand : Command
}
}
else
+ {
AaruConsole.DebugWriteLine(MODULE_NAME,
Localization.Core.GET_CONFIGURATION_returned_no_feature_descriptors);
+ }
}
if(devInfo.RPC != null)
@@ -879,26 +897,34 @@ sealed class DeviceInfoCommand : Command
if(devInfo.PlextorFeatures.PoweRecEnabled)
{
if(devInfo.PlextorFeatures.PoweRecRecommendedSpeed > 0)
+ {
AaruConsole.WriteLine(Localization.Core.Drive_supports_PoweRec_is_enabled_and_recommends_0,
devInfo.PlextorFeatures.PoweRecRecommendedSpeed);
+ }
else
AaruConsole.WriteLine(Localization.Core.Drive_supports_PoweRec_and_has_it_enabled);
if(devInfo.PlextorFeatures.PoweRecSelected > 0)
+ {
AaruConsole.
WriteLine(Localization.Core.Selected_PoweRec_speed_for_currently_inserted_media_is_0_1,
devInfo.PlextorFeatures.PoweRecSelected,
devInfo.PlextorFeatures.PoweRecSelected / 177);
+ }
if(devInfo.PlextorFeatures.PoweRecMax > 0)
+ {
AaruConsole.
WriteLine(Localization.Core.Maximum_PoweRec_speed_for_currently_inserted_media_is_0_1,
devInfo.PlextorFeatures.PoweRecMax, devInfo.PlextorFeatures.PoweRecMax / 177);
+ }
if(devInfo.PlextorFeatures.PoweRecLast > 0)
+ {
AaruConsole.WriteLine(Localization.Core.Last_used_PoweRec_was_0_1,
devInfo.PlextorFeatures.PoweRecLast,
devInfo.PlextorFeatures.PoweRecLast / 177);
+ }
}
else
AaruConsole.WriteLine(Localization.Core.Drive_supports_PoweRec_and_has_it_disabled);
@@ -917,17 +943,23 @@ sealed class DeviceInfoCommand : Command
: Localization.Core.Access_time_is_fast));
if(devInfo.PlextorFeatures.CdReadSpeedLimit > 0)
+ {
AaruConsole.WriteLine("\t" + Localization.Core.CD_read_speed_limited_to_0,
devInfo.PlextorFeatures.CdReadSpeedLimit);
+ }
if(devInfo.PlextorFeatures.DvdReadSpeedLimit > 0 &&
devInfo.PlextorFeatures.IsDvd)
+ {
AaruConsole.WriteLine("\t" + Localization.Core.DVD_read_speed_limited_to_0,
devInfo.PlextorFeatures.DvdReadSpeedLimit);
+ }
if(devInfo.PlextorFeatures.CdWriteSpeedLimit > 0)
+ {
AaruConsole.WriteLine("\t" + Localization.Core.CD_write_speed_limited_to_0,
devInfo.PlextorFeatures.CdWriteSpeedLimit);
+ }
}
}
@@ -938,9 +970,11 @@ sealed class DeviceInfoCommand : Command
AaruConsole.WriteLine(Localization.Core.Drive_supports_Plextor_SecuRec);
if(devInfo.PlextorFeatures?.SpeedRead == true)
+ {
AaruConsole.WriteLine(devInfo.PlextorFeatures.SpeedReadEnabled
? Localization.Core.Drive_supports_Plextor_SpeedRead_and_has_it_enabled
: Localization.Core.Drive_supports_Plextor_SpeedRead);
+ }
if(devInfo.PlextorFeatures?.Hiding == true)
{
@@ -1046,7 +1080,7 @@ sealed class DeviceInfoCommand : Command
{
case DeviceType.MMC:
{
- bool noInfo = true;
+ var noInfo = true;
if(devInfo.CID != null)
{
@@ -1086,7 +1120,7 @@ sealed class DeviceInfoCommand : Command
break;
case DeviceType.SecureDigital:
{
- bool noInfo = true;
+ var noInfo = true;
if(devInfo.CID != null)
{
@@ -1166,7 +1200,8 @@ sealed class DeviceInfoCommand : Command
d.Manufacturer == dev.Manufacturer.Replace('/', '-')) &&
(d.Model == dev.Model || d.Model == dev.Model.Replace('/', '-')));
- AaruConsole.WriteLine(cdOffset is null ? "CD reading offset not found in database."
+ AaruConsole.WriteLine(cdOffset is null
+ ? "CD reading offset not found in database."
: $"CD reading offset is {cdOffset.Offset} samples ({cdOffset.Offset * 4} bytes).");
return (int)ErrorNumber.NoError;
diff --git a/Aaru/Commands/Device/List.cs b/Aaru/Commands/Device/List.cs
index 8c824df21..361a6a593 100644
--- a/Aaru/Commands/Device/List.cs
+++ b/Aaru/Commands/Device/List.cs
@@ -71,26 +71,28 @@ sealed class ListDevicesCommand : Command
});
AaruConsole.DebugWriteLineEvent += (format, objects) =>
- {
- if(objects is null)
- stderrConsole.MarkupLine(format);
- else
- stderrConsole.MarkupLine(format, objects);
- };
+ {
+ if(objects is null)
+ stderrConsole.MarkupLine(format);
+ else
+ stderrConsole.MarkupLine(format, objects);
+ };
}
if(verbose)
+ {
AaruConsole.WriteEvent += (format, objects) =>
- {
- if(objects is null)
- AnsiConsole.Markup(format);
- else
- AnsiConsole.Markup(format, objects);
- };
+ {
+ if(objects is null)
+ AnsiConsole.Markup(format);
+ else
+ AnsiConsole.Markup(format, objects);
+ };
+ }
Statistics.AddCommand("list-devices");
- AaruConsole.DebugWriteLine(MODULE_NAME, "--debug={0}", debug);
+ AaruConsole.DebugWriteLine(MODULE_NAME, "--debug={0}", debug);
AaruConsole.DebugWriteLine(MODULE_NAME, "--verbose={0}", verbose);
DeviceInfo[] devices = Devices.Device.ListDevices(out bool isRemote, out string serverApplication,
@@ -99,8 +101,10 @@ sealed class ListDevicesCommand : Command
out string serverArchitecture, aaruRemoteHost);
if(isRemote)
+ {
Statistics.AddRemote(serverApplication, serverVersion, serverOperatingSystem, serverOperatingSystemVersion,
serverArchitecture);
+ }
if(devices == null ||
devices.Length == 0)
@@ -116,9 +120,11 @@ sealed class ListDevicesCommand : Command
table.AddColumn(UI.Supported_Question);
foreach(DeviceInfo dev in devices.OrderBy(d => d.Path))
+ {
table.AddRow(Markup.Escape(dev.Path ?? ""), Markup.Escape(dev.Vendor ?? ""),
Markup.Escape(dev.Model ?? ""), Markup.Escape(dev.Serial ?? ""),
Markup.Escape(dev.Bus ?? ""), dev.Supported ? "[green]✓[/]" : "[red]✗[/]");
+ }
AnsiConsole.Write(table);
}
diff --git a/Aaru/Commands/Filesystem/ExtractFiles.cs b/Aaru/Commands/Filesystem/ExtractFiles.cs
index f78d02dc5..ccc302ea8 100644
--- a/Aaru/Commands/Filesystem/ExtractFiles.cs
+++ b/Aaru/Commands/Filesystem/ExtractFiles.cs
@@ -57,25 +57,14 @@ sealed class ExtractFilesCommand : Command
public ExtractFilesCommand() : base("extract", UI.Filesystem_Extract_Command_Description)
{
- Add(new Option(new[]
- {
- "--encoding", "-e"
- }, () => null, UI.Name_of_character_encoding_to_use));
+ Add(new Option(new[] { "--encoding", "-e" }, () => null, UI.Name_of_character_encoding_to_use));
- Add(new Option(new[]
- {
- "--options", "-O"
- }, () => null, UI.Comma_separated_name_value_pairs_of_filesystem_options));
+ Add(new Option(new[] { "--options", "-O" }, () => null,
+ UI.Comma_separated_name_value_pairs_of_filesystem_options));
- Add(new Option(new[]
- {
- "--xattrs", "-x"
- }, () => false, UI.Extract_extended_attributes_if_present));
+ Add(new Option(new[] { "--xattrs", "-x" }, () => false, UI.Extract_extended_attributes_if_present));
- Add(new Option(new[]
- {
- "--namespace", "-n"
- }, () => null, UI.Namespace_to_use_for_filenames));
+ Add(new Option(new[] { "--namespace", "-n" }, () => null, UI.Namespace_to_use_for_filenames));
AddArgument(new Argument
{
@@ -94,7 +83,7 @@ sealed class ExtractFilesCommand : Command
Handler = CommandHandler.Create(GetType().GetMethod(nameof(Invoke)));
}
- public static int Invoke(bool debug, bool verbose, string encoding, bool xattrs, string imagePath,
+ public static int Invoke(bool debug, bool verbose, string encoding, bool xattrs, string imagePath,
string @namespace, string outputDir, string options)
{
MainClass.PrintCopyright();
@@ -107,41 +96,43 @@ sealed class ExtractFilesCommand : Command
});
AaruConsole.DebugWriteLineEvent += (format, objects) =>
- {
- if(objects is null)
- stderrConsole.MarkupLine(format);
- else
- stderrConsole.MarkupLine(format, objects);
- };
+ {
+ if(objects is null)
+ stderrConsole.MarkupLine(format);
+ else
+ stderrConsole.MarkupLine(format, objects);
+ };
}
if(verbose)
+ {
AaruConsole.WriteEvent += (format, objects) =>
- {
- if(objects is null)
- AnsiConsole.Markup(format);
- else
- AnsiConsole.Markup(format, objects);
- };
+ {
+ if(objects is null)
+ AnsiConsole.Markup(format);
+ else
+ AnsiConsole.Markup(format, objects);
+ };
+ }
Statistics.AddCommand("extract-files");
- AaruConsole.DebugWriteLine(MODULE_NAME, "--debug={0}", debug);
+ AaruConsole.DebugWriteLine(MODULE_NAME, "--debug={0}", debug);
AaruConsole.DebugWriteLine(MODULE_NAME, "--encoding={0}", encoding);
- AaruConsole.DebugWriteLine(MODULE_NAME, "--input={0}", imagePath);
- AaruConsole.DebugWriteLine(MODULE_NAME, "--options={0}", options);
- AaruConsole.DebugWriteLine(MODULE_NAME, "--output={0}", outputDir);
- AaruConsole.DebugWriteLine(MODULE_NAME, "--verbose={0}", verbose);
- AaruConsole.DebugWriteLine(MODULE_NAME, "--xattrs={0}", xattrs);
+ AaruConsole.DebugWriteLine(MODULE_NAME, "--input={0}", imagePath);
+ AaruConsole.DebugWriteLine(MODULE_NAME, "--options={0}", options);
+ AaruConsole.DebugWriteLine(MODULE_NAME, "--output={0}", outputDir);
+ AaruConsole.DebugWriteLine(MODULE_NAME, "--verbose={0}", verbose);
+ AaruConsole.DebugWriteLine(MODULE_NAME, "--xattrs={0}", xattrs);
var filtersList = new FiltersList();
IFilter inputFilter = null;
Core.Spectre.ProgressSingleSpinner(ctx =>
- {
- ctx.AddTask(UI.Identifying_file_filter).IsIndeterminate();
- inputFilter = filtersList.GetFilter(imagePath);
- });
+ {
+ ctx.AddTask(UI.Identifying_file_filter).IsIndeterminate();
+ inputFilter = filtersList.GetFilter(imagePath);
+ });
Dictionary parsedOptions = Core.Options.Parse(options);
AaruConsole.DebugWriteLine(MODULE_NAME, UI.Parsed_options);
@@ -161,6 +152,7 @@ sealed class ExtractFilesCommand : Command
Encoding encodingClass = null;
if(encoding != null)
+ {
try
{
encodingClass = Claunia.Encoding.Encoding.GetEncoding(encoding);
@@ -174,6 +166,7 @@ sealed class ExtractFilesCommand : Command
return (int)ErrorNumber.EncodingUnknown;
}
+ }
PluginBase plugins = PluginBase.Singleton;
@@ -183,11 +176,11 @@ sealed class ExtractFilesCommand : Command
IBaseImage baseImage = null;
Core.Spectre.ProgressSingleSpinner(ctx =>
- {
- ctx.AddTask(UI.Identifying_image_format).IsIndeterminate();
- baseImage = ImageFormat.Detect(inputFilter);
- imageFormat = baseImage as IMediaImage;
- });
+ {
+ ctx.AddTask(UI.Identifying_image_format).IsIndeterminate();
+ baseImage = ImageFormat.Detect(inputFilter);
+ imageFormat = baseImage as IMediaImage;
+ });
if(baseImage == null)
{
@@ -230,10 +223,10 @@ sealed class ExtractFilesCommand : Command
ErrorNumber opened = ErrorNumber.NoData;
Core.Spectre.ProgressSingleSpinner(ctx =>
- {
- ctx.AddTask(UI.Invoke_Opening_image_file).IsIndeterminate();
- opened = imageFormat.Open(inputFilter);
- });
+ {
+ ctx.AddTask(UI.Invoke_Opening_image_file).IsIndeterminate();
+ opened = imageFormat.Open(inputFilter);
+ });
if(opened != ErrorNumber.NoError)
{
@@ -268,10 +261,10 @@ sealed class ExtractFilesCommand : Command
List partitions = null;
Core.Spectre.ProgressSingleSpinner(ctx =>
- {
- ctx.AddTask(UI.Enumerating_partitions).IsIndeterminate();
- partitions = Core.Partitions.GetAll(imageFormat);
- });
+ {
+ ctx.AddTask(UI.Enumerating_partitions).IsIndeterminate();
+ partitions = Core.Partitions.GetAll(imageFormat);
+ });
Core.Partitions.AddSchemesToStats(partitions);
@@ -292,7 +285,7 @@ sealed class ExtractFilesCommand : Command
AaruConsole.WriteLine(UI._0_partitions_found, partitions.Count);
- for(int i = 0; i < partitions.Count; i++)
+ for(var i = 0; i < partitions.Count; i++)
{
AaruConsole.WriteLine();
AaruConsole.WriteLine($"[bold]{string.Format(UI.Partition_0, partitions[i].Sequence)}[/]");
@@ -300,10 +293,12 @@ sealed class ExtractFilesCommand : Command
List idPlugins = null;
Core.Spectre.ProgressSingleSpinner(ctx =>
- {
- ctx.AddTask(UI.Identifying_filesystems_on_partition).IsIndeterminate();
- Core.Filesystems.Identify(imageFormat, out idPlugins, partitions[i]);
- });
+ {
+ ctx.AddTask(UI.Identifying_filesystems_on_partition).
+ IsIndeterminate();
+ Core.Filesystems.Identify(imageFormat, out idPlugins,
+ partitions[i]);
+ });
if(idPlugins.Count == 0)
AaruConsole.WriteLine(UI.Filesystem_not_identified);
@@ -318,6 +313,7 @@ sealed class ExtractFilesCommand : Command
}[/]");
foreach(string pluginName in idPlugins)
+ {
if(plugins.ReadOnlyFilesystems.TryGetValue(pluginName, out pluginType))
{
AaruConsole.WriteLine($"[bold]{string.Format(UI.As_identified_by_0, pluginType.Name)
@@ -327,16 +323,19 @@ sealed class ExtractFilesCommand : Command
continue;
Core.Spectre.ProgressSingleSpinner(ctx =>
- {
- ctx.AddTask(UI.Mounting_filesystem).IsIndeterminate();
+ {
+ ctx.AddTask(UI.Mounting_filesystem).
+ IsIndeterminate();
- error = fs.Mount(imageFormat, partitions[i], encodingClass, parsedOptions,
- @namespace);
- });
+ error = fs.Mount(imageFormat, partitions[i],
+ encodingClass, parsedOptions,
+ @namespace);
+ });
if(error == ErrorNumber.NoError)
{
- string volumeName = string.IsNullOrEmpty(fs.Metadata.VolumeName) ? "NO NAME"
+ string volumeName = string.IsNullOrEmpty(fs.Metadata.VolumeName)
+ ? "NO NAME"
: fs.Metadata.VolumeName;
ExtractFilesInDir("/", fs, volumeName, outputDir, xattrs);
@@ -346,6 +345,7 @@ sealed class ExtractFilesCommand : Command
else
AaruConsole.ErrorWriteLine(UI.Unable_to_mount_volume_error_0, error.ToString());
}
+ }
}
else
{
@@ -358,14 +358,17 @@ sealed class ExtractFilesCommand : Command
AaruConsole.WriteLine($"[bold]{string.Format(UI.Identified_by_0, pluginType.Name)}[/]");
Core.Spectre.ProgressSingleSpinner(ctx =>
- {
- ctx.AddTask(UI.Mounting_filesystem).IsIndeterminate();
- error = fs.Mount(imageFormat, partitions[i], encodingClass, parsedOptions, @namespace);
- });
+ {
+ ctx.AddTask(UI.Mounting_filesystem).IsIndeterminate();
+ error = fs.Mount(imageFormat, partitions[i],
+ encodingClass, parsedOptions,
+ @namespace);
+ });
if(error == ErrorNumber.NoError)
{
- string volumeName = string.IsNullOrEmpty(fs.Metadata.VolumeName) ? "NO NAME"
+ string volumeName = string.IsNullOrEmpty(fs.Metadata.VolumeName)
+ ? "NO NAME"
: fs.Metadata.VolumeName;
ExtractFilesInDir("/", fs, volumeName, outputDir, xattrs);
@@ -390,7 +393,7 @@ sealed class ExtractFilesCommand : Command
}
static void ExtractFilesInDir(string path, [NotNull] IReadOnlyFilesystem fs, string volumeName, string outputDir,
- bool doXattrs)
+ bool doXattrs)
{
if(path.StartsWith('/'))
path = path[1..];
@@ -410,10 +413,10 @@ sealed class ExtractFilesCommand : Command
FileEntryInfo stat = new();
Core.Spectre.ProgressSingleSpinner(ctx =>
- {
- ctx.AddTask(UI.Retrieving_file_information).IsIndeterminate();
- error = fs.Stat(path + "/" + entry, out stat);
- });
+ {
+ ctx.AddTask(UI.Retrieving_file_information).IsIndeterminate();
+ error = fs.Stat(path + "/" + entry, out stat);
+ });
if(error == ErrorNumber.NoError)
{
@@ -424,9 +427,11 @@ sealed class ExtractFilesCommand : Command
outputPath = Path.Combine(outputDir, fs.Metadata.Type, volumeName, path, entry);
if(RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
+ {
outputPath = outputPath.Replace('<', '\uFF1C').Replace('>', '\uFF1E').Replace(':', '\uFF1A').
Replace('\"', '\uFF02').Replace('|', '\uFF5C').Replace('?', '\uFF1F').
- Replace('*', '\uFF0A').Replace('/', '\\');
+ Replace('*', '\uFF0A').Replace('/', '\\');
+ }
Directory.CreateDirectory(outputPath);
@@ -436,7 +441,7 @@ sealed class ExtractFilesCommand : Command
var di = new DirectoryInfo(outputPath);
- #pragma warning disable RECS0022 // A catch clause that catches System.Exception and has an empty body
+ #pragma warning disable RECS0022 // A catch clause that catches System.Exception and has an empty body
try
{
if(stat.CreationTimeUtc.HasValue)
@@ -466,7 +471,7 @@ sealed class ExtractFilesCommand : Command
{
// ignored
}
- #pragma warning restore RECS0022 // A catch clause that catches System.Exception and has an empty body
+ #pragma warning restore RECS0022 // A catch clause that catches System.Exception and has an empty body
continue;
}
@@ -478,21 +483,25 @@ sealed class ExtractFilesCommand : Command
List xattrs = null;
Core.Spectre.ProgressSingleSpinner(ctx =>
- {
- ctx.AddTask(UI.Listing_extended_attributes).IsIndeterminate();
- error = fs.ListXAttr(path + "/" + entry, out xattrs);
- });
+ {
+ ctx.AddTask(UI.Listing_extended_attributes).
+ IsIndeterminate();
+ error = fs.ListXAttr(path + "/" + entry, out xattrs);
+ });
if(error == ErrorNumber.NoError)
+ {
foreach(string xattr in xattrs)
{
byte[] xattrBuf = Array.Empty();
Core.Spectre.ProgressSingleSpinner(ctx =>
- {
- ctx.AddTask(UI.Reading_extended_attribute).IsIndeterminate();
- error = fs.GetXattr(path + "/" + entry, xattr, ref xattrBuf);
- });
+ {
+ ctx.AddTask(UI.Reading_extended_attribute).
+ IsIndeterminate();
+ error = fs.GetXattr(path + "/" + entry, xattr,
+ ref xattrBuf);
+ });
if(error != ErrorNumber.NoError)
continue;
@@ -500,10 +509,12 @@ sealed class ExtractFilesCommand : Command
outputPath = Path.Combine(outputDir, fs.Metadata.Type, volumeName, ".xattrs", path, xattr);
if(RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
+ {
outputPath = outputPath.Replace('<', '\uFF1C').Replace('>', '\uFF1E').
Replace(':', '\uFF1A').Replace('\"', '\uFF02').
Replace('|', '\uFF5C').Replace('?', '\uFF1F').
Replace('*', '\uFF0A').Replace('/', '\\');
+ }
Directory.CreateDirectory(outputPath);
@@ -513,26 +524,32 @@ sealed class ExtractFilesCommand : Command
: Path.Combine(outputPath, entry);
if(RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
+ {
outputPath = outputPath.Replace('<', '\uFF1C').Replace('>', '\uFF1E').
Replace(':', '\uFF1A').Replace('\"', '\uFF02').
Replace('|', '\uFF5C').Replace('?', '\uFF1F').
Replace('*', '\uFF0A').Replace('/', '\\');
+ }
if(!File.Exists(outputPath))
{
Core.Spectre.ProgressSingleSpinner(ctx =>
- {
- ctx.AddTask(UI.Writing_extended_attribute).IsIndeterminate();
+ {
+ ctx.AddTask(UI.Writing_extended_attribute).
+ IsIndeterminate();
- outputFile = new FileStream(outputPath, FileMode.CreateNew, FileAccess.ReadWrite,
- FileShare.None);
+ outputFile =
+ new FileStream(outputPath,
+ FileMode.CreateNew,
+ FileAccess.ReadWrite,
+ FileShare.None);
- outputFile.Write(xattrBuf, 0, xattrBuf.Length);
- outputFile.Close();
- });
+ outputFile.Write(xattrBuf, 0, xattrBuf.Length);
+ outputFile.Close();
+ });
var fi = new FileInfo(outputPath);
- #pragma warning disable RECS0022 // A catch clause that catches System.Exception and has an empty body
+ #pragma warning disable RECS0022 // A catch clause that catches System.Exception and has an empty body
try
{
if(stat.CreationTimeUtc.HasValue)
@@ -562,21 +579,24 @@ sealed class ExtractFilesCommand : Command
{
// ignored
}
- #pragma warning restore RECS0022 // A catch clause that catches System.Exception and has an empty body
+ #pragma warning restore RECS0022 // A catch clause that catches System.Exception and has an empty body
AaruConsole.WriteLine(UI.Written_0_bytes_of_xattr_1_from_file_2_to_3, xattrBuf.Length,
xattr, entry, outputPath);
}
else
AaruConsole.ErrorWriteLine(UI.Cannot_write_xattr_0_for_1_output_exists, xattr, entry);
}
+ }
}
outputPath = Path.Combine(outputDir, fs.Metadata.Type, volumeName, path);
if(RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
+ {
outputPath = outputPath.Replace('<', '\uFF1C').Replace('>', '\uFF1E').Replace(':', '\uFF1A').
Replace('\"', '\uFF02').Replace('|', '\uFF5C').Replace('?', '\uFF1F').
- Replace('*', '\uFF0A').Replace('/', '\\');
+ Replace('*', '\uFF0A').Replace('/', '\\');
+ }
Directory.CreateDirectory(outputPath);
@@ -585,9 +605,11 @@ sealed class ExtractFilesCommand : Command
: Path.Combine(outputPath, entry);
if(RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
+ {
outputPath = outputPath.Replace('<', '\uFF1C').Replace('>', '\uFF1E').Replace(':', '\uFF1A').
Replace('\"', '\uFF02').Replace('|', '\uFF5C').Replace('?', '\uFF1F').
- Replace('*', '\uFF0A').Replace('/', '\\');
+ Replace('*', '\uFF0A').Replace('/', '\\');
+ }
if(!File.Exists(outputPath))
{
@@ -598,50 +620,52 @@ sealed class ExtractFilesCommand : Command
AnsiConsole.Progress().AutoClear(true).HideCompleted(true).
Columns(new TaskDescriptionColumn(), new ProgressBarColumn(), new PercentageColumn()).
Start(ctx =>
- {
- ProgressTask task =
- ctx.AddTask(string.Format(UI.Reading_file_0, Markup.Escape(entry)));
+ {
+ ProgressTask task =
+ ctx.AddTask(string.Format(UI.Reading_file_0, Markup.Escape(entry)));
- task.MaxValue = stat.Length;
- byte[] outBuf = new byte[BUFFER_SIZE];
- error = fs.OpenFile(path + "/" + entry, out IFileNode fileNode);
+ task.MaxValue = stat.Length;
+ var outBuf = new byte[BUFFER_SIZE];
+ error = fs.OpenFile(path + "/" + entry, out IFileNode fileNode);
- if(error == ErrorNumber.NoError)
- {
- while(position < stat.Length)
- {
- long bytesToRead;
+ if(error == ErrorNumber.NoError)
+ {
+ while(position < stat.Length)
+ {
+ long bytesToRead;
- if(stat.Length - position > BUFFER_SIZE)
- bytesToRead = BUFFER_SIZE;
- else
- bytesToRead = stat.Length - position;
+ if(stat.Length - position > BUFFER_SIZE)
+ bytesToRead = BUFFER_SIZE;
+ else
+ bytesToRead = stat.Length - position;
- error = fs.ReadFile(fileNode, bytesToRead, outBuf, out long bytesRead);
+ error = fs.ReadFile(fileNode, bytesToRead, outBuf,
+ out long bytesRead);
- if(error == ErrorNumber.NoError)
- outputFile.Write(outBuf, 0, (int)bytesRead);
- else
- {
- AaruConsole.ErrorWriteLine(UI.Error_0_reading_file_1, error, entry);
+ if(error == ErrorNumber.NoError)
+ outputFile.Write(outBuf, 0, (int)bytesRead);
+ else
+ {
+ AaruConsole.ErrorWriteLine(UI.Error_0_reading_file_1, error,
+ entry);
- break;
- }
+ break;
+ }
- position += bytesToRead;
- task.Increment(bytesToRead);
- }
+ position += bytesToRead;
+ task.Increment(bytesToRead);
+ }
- fs.CloseFile(fileNode);
- }
- else
- AaruConsole.ErrorWriteLine(UI.Error_0_reading_file_1, error, entry);
- });
+ fs.CloseFile(fileNode);
+ }
+ else
+ AaruConsole.ErrorWriteLine(UI.Error_0_reading_file_1, error, entry);
+ });
outputFile.Close();
var fi = new FileInfo(outputPath);
- #pragma warning disable RECS0022 // A catch clause that catches System.Exception and has an empty body
+ #pragma warning disable RECS0022 // A catch clause that catches System.Exception and has an empty body
try
{
if(stat.CreationTimeUtc.HasValue)
@@ -671,7 +695,7 @@ sealed class ExtractFilesCommand : Command
{
// ignored
}
- #pragma warning restore RECS0022 // A catch clause that catches System.Exception and has an empty body
+ #pragma warning restore RECS0022 // A catch clause that catches System.Exception and has an empty body
AaruConsole.WriteLine(UI.Written_0_bytes_of_file_1_to_2, position, Markup.Escape(entry),
Markup.Escape(outputPath));
}
diff --git a/Aaru/Commands/Filesystem/Info.cs b/Aaru/Commands/Filesystem/Info.cs
index 460b3ab55..7094a98b5 100644
--- a/Aaru/Commands/Filesystem/Info.cs
+++ b/Aaru/Commands/Filesystem/Info.cs
@@ -53,20 +53,12 @@ sealed class FilesystemInfoCommand : Command
public FilesystemInfoCommand() : base("info", UI.Filesystem_Info_Command_Description)
{
- Add(new Option(new[]
- {
- "--encoding", "-e"
- }, () => null, UI.Name_of_character_encoding_to_use));
+ Add(new Option(new[] { "--encoding", "-e" }, () => null, UI.Name_of_character_encoding_to_use));
- Add(new Option(new[]
- {
- "--filesystems", "-f"
- }, () => true, UI.Searches_and_prints_information_about_filesystems));
+ Add(new Option(new[] { "--filesystems", "-f" }, () => true,
+ UI.Searches_and_prints_information_about_filesystems));
- Add(new Option(new[]
- {
- "--partitions", "-p"
- }, () => true, UI.Searches_and_interprets_partitions));
+ Add(new Option(new[] { "--partitions", "-p" }, () => true, UI.Searches_and_interprets_partitions));
AddArgument(new Argument
{
@@ -78,7 +70,7 @@ sealed class FilesystemInfoCommand : Command
Handler = CommandHandler.Create(typeof(FilesystemInfoCommand).GetMethod(nameof(Invoke)));
}
- public static int Invoke(bool verbose, bool debug, string encoding, bool filesystems, bool partitions,
+ public static int Invoke(bool verbose, bool debug, string encoding, bool filesystems, bool partitions,
string imagePath)
{
MainClass.PrintCopyright();
@@ -91,40 +83,42 @@ sealed class FilesystemInfoCommand : Command
});
AaruConsole.DebugWriteLineEvent += (format, objects) =>
- {
- if(objects is null)
- stderrConsole.MarkupLine(format);
- else
- stderrConsole.MarkupLine(format, objects);
- };
+ {
+ if(objects is null)
+ stderrConsole.MarkupLine(format);
+ else
+ stderrConsole.MarkupLine(format, objects);
+ };
}
if(verbose)
+ {
AaruConsole.WriteEvent += (format, objects) =>
- {
- if(objects is null)
- AnsiConsole.Markup(format);
- else
- AnsiConsole.Markup(format, objects);
- };
+ {
+ if(objects is null)
+ AnsiConsole.Markup(format);
+ else
+ AnsiConsole.Markup(format, objects);
+ };
+ }
Statistics.AddCommand("fs-info");
- AaruConsole.DebugWriteLine(MODULE_NAME, "--debug={0}", debug);
- AaruConsole.DebugWriteLine(MODULE_NAME, "--encoding={0}", encoding);
+ AaruConsole.DebugWriteLine(MODULE_NAME, "--debug={0}", debug);
+ AaruConsole.DebugWriteLine(MODULE_NAME, "--encoding={0}", encoding);
AaruConsole.DebugWriteLine(MODULE_NAME, "--filesystems={0}", filesystems);
- AaruConsole.DebugWriteLine(MODULE_NAME, "--input={0}", imagePath);
- AaruConsole.DebugWriteLine(MODULE_NAME, "--partitions={0}", partitions);
- AaruConsole.DebugWriteLine(MODULE_NAME, "--verbose={0}", verbose);
+ AaruConsole.DebugWriteLine(MODULE_NAME, "--input={0}", imagePath);
+ AaruConsole.DebugWriteLine(MODULE_NAME, "--partitions={0}", partitions);
+ AaruConsole.DebugWriteLine(MODULE_NAME, "--verbose={0}", verbose);
var filtersList = new FiltersList();
IFilter inputFilter = null;
Core.Spectre.ProgressSingleSpinner(ctx =>
- {
- ctx.AddTask(UI.Identifying_file_filter).IsIndeterminate();
- inputFilter = filtersList.GetFilter(imagePath);
- });
+ {
+ ctx.AddTask(UI.Identifying_file_filter).IsIndeterminate();
+ inputFilter = filtersList.GetFilter(imagePath);
+ });
if(inputFilter == null)
{
@@ -136,6 +130,7 @@ sealed class FilesystemInfoCommand : Command
Encoding encodingClass = null;
if(encoding != null)
+ {
try
{
encodingClass = Claunia.Encoding.Encoding.GetEncoding(encoding);
@@ -149,10 +144,11 @@ sealed class FilesystemInfoCommand : Command
return (int)ErrorNumber.EncodingUnknown;
}
+ }
PluginBase plugins = PluginBase.Singleton;
- bool checkRaw = false;
+ var checkRaw = false;
try
{
@@ -160,11 +156,11 @@ sealed class FilesystemInfoCommand : Command
IBaseImage baseImage = null;
Core.Spectre.ProgressSingleSpinner(ctx =>
- {
- ctx.AddTask(UI.Identifying_image_format).IsIndeterminate();
- baseImage = ImageFormat.Detect(inputFilter);
- imageFormat = baseImage as IMediaImage;
- });
+ {
+ ctx.AddTask(UI.Identifying_image_format).IsIndeterminate();
+ baseImage = ImageFormat.Detect(inputFilter);
+ imageFormat = baseImage as IMediaImage;
+ });
if(baseImage == null)
{
@@ -192,10 +188,10 @@ sealed class FilesystemInfoCommand : Command
ErrorNumber opened = ErrorNumber.NoData;
Core.Spectre.ProgressSingleSpinner(ctx =>
- {
- ctx.AddTask(UI.Invoke_Opening_image_file).IsIndeterminate();
- opened = imageFormat.Open(inputFilter);
- });
+ {
+ ctx.AddTask(UI.Invoke_Opening_image_file).IsIndeterminate();
+ opened = imageFormat.Open(inputFilter);
+ });
if(opened != ErrorNumber.NoError)
{
@@ -233,10 +229,10 @@ sealed class FilesystemInfoCommand : Command
List partitionsList = null;
Core.Spectre.ProgressSingleSpinner(ctx =>
- {
- ctx.AddTask(UI.Enumerating_partitions).IsIndeterminate();
- partitionsList = Core.Partitions.GetAll(imageFormat);
- });
+ {
+ ctx.AddTask(UI.Enumerating_partitions).IsIndeterminate();
+ partitionsList = Core.Partitions.GetAll(imageFormat);
+ });
Core.Partitions.AddSchemesToStats(partitionsList);
@@ -257,7 +253,7 @@ sealed class FilesystemInfoCommand : Command
{
AaruConsole.WriteLine(UI._0_partitions_found, partitionsList.Count);
- for(int i = 0; i < partitionsList.Count; i++)
+ for(var i = 0; i < partitionsList.Count; i++)
{
Table table = new()
{
@@ -279,7 +275,7 @@ sealed class FilesystemInfoCommand : Command
string.Format(UI._0_sectors_1_bytes, partitionsList[i].Length,
partitionsList[i].Size));
- table.AddRow(UI.Title_Scheme, Markup.Escape(partitionsList[i].Scheme ?? ""));
+ table.AddRow(UI.Title_Scheme, Markup.Escape(partitionsList[i].Scheme ?? ""));
table.AddRow(UI.Title_Description, Markup.Escape(partitionsList[i].Description ?? ""));
AnsiConsole.Write(table);
@@ -288,10 +284,12 @@ sealed class FilesystemInfoCommand : Command
continue;
Core.Spectre.ProgressSingleSpinner(ctx =>
- {
- ctx.AddTask(UI.Identifying_filesystems_on_partition).IsIndeterminate();
- Core.Filesystems.Identify(imageFormat, out idPlugins, partitionsList[i]);
- });
+ {
+ ctx.AddTask(UI.Identifying_filesystems_on_partition).
+ IsIndeterminate();
+ Core.Filesystems.Identify(imageFormat, out idPlugins,
+ partitionsList[i]);
+ });
switch(idPlugins.Count)
{
@@ -305,6 +303,7 @@ sealed class FilesystemInfoCommand : Command
idPlugins.Count)}[/]");
foreach(string pluginName in idPlugins)
+ {
if(plugins.Filesystems.TryGetValue(pluginName, out pluginType))
{
if(Activator.CreateInstance(pluginType) is not IFilesystem fs)
@@ -319,6 +318,7 @@ sealed class FilesystemInfoCommand : Command
AaruConsole.Write(information);
Statistics.AddFilesystem(fsMetadata.Type);
}
+ }
break;
}
@@ -357,10 +357,10 @@ sealed class FilesystemInfoCommand : Command
};
Core.Spectre.ProgressSingleSpinner(ctx =>
- {
- ctx.AddTask(UI.Identifying_filesystems).IsIndeterminate();
- Core.Filesystems.Identify(imageFormat, out idPlugins, wholePart);
- });
+ {
+ ctx.AddTask(UI.Identifying_filesystems).IsIndeterminate();
+ Core.Filesystems.Identify(imageFormat, out idPlugins, wholePart);
+ });
switch(idPlugins.Count)
{
@@ -374,6 +374,7 @@ sealed class FilesystemInfoCommand : Command
}[/]");
foreach(string pluginName in idPlugins)
+ {
if(plugins.Filesystems.TryGetValue(pluginName, out pluginType))
{
if(Activator.CreateInstance(pluginType) is not IFilesystem fs)
@@ -387,6 +388,7 @@ sealed class FilesystemInfoCommand : Command
AaruConsole.Write(information);
Statistics.AddFilesystem(fsMetadata.Type);
}
+ }
break;
}
diff --git a/Aaru/Commands/Filesystem/Ls.cs b/Aaru/Commands/Filesystem/Ls.cs
index 6ec9038f2..9e9ad755a 100644
--- a/Aaru/Commands/Filesystem/Ls.cs
+++ b/Aaru/Commands/Filesystem/Ls.cs
@@ -56,25 +56,14 @@ sealed class LsCommand : Command
{
AddAlias("ls");
- Add(new Option(new[]
- {
- "--encoding", "-e"
- }, () => null, UI.Name_of_character_encoding_to_use));
+ Add(new Option(new[] { "--encoding", "-e" }, () => null, UI.Name_of_character_encoding_to_use));
- Add(new Option(new[]
- {
- "--long-format", "-l"
- }, () => true, UI.Use_long_format));
+ Add(new Option(new[] { "--long-format", "-l" }, () => true, UI.Use_long_format));
- Add(new Option(new[]
- {
- "--options", "-O"
- }, () => null, UI.Comma_separated_name_value_pairs_of_filesystem_options));
+ Add(new Option(new[] { "--options", "-O" }, () => null,
+ UI.Comma_separated_name_value_pairs_of_filesystem_options));
- Add(new Option(new[]
- {
- "--namespace", "-n"
- }, () => null, UI.Namespace_to_use_for_filenames));
+ Add(new Option(new[] { "--namespace", "-n" }, () => null, UI.Namespace_to_use_for_filenames));
AddArgument(new Argument
{
@@ -86,7 +75,7 @@ sealed class LsCommand : Command
Handler = CommandHandler.Create(GetType().GetMethod(nameof(Invoke)));
}
- public static int Invoke(bool debug, bool verbose, string encoding, string imagePath, bool longFormat,
+ public static int Invoke(bool debug, bool verbose, string encoding, string imagePath, bool longFormat,
string @namespace, string options)
{
MainClass.PrintCopyright();
@@ -99,38 +88,40 @@ sealed class LsCommand : Command
});
AaruConsole.DebugWriteLineEvent += (format, objects) =>
- {
- if(objects is null)
- stderrConsole.MarkupLine(Markup.Escape(format));
- else
- stderrConsole.MarkupLine(Markup.Escape(format), objects);
- };
+ {
+ if(objects is null)
+ stderrConsole.MarkupLine(Markup.Escape(format));
+ else
+ stderrConsole.MarkupLine(Markup.Escape(format), objects);
+ };
}
if(verbose)
+ {
AaruConsole.WriteEvent += (format, objects) =>
- {
- if(objects is null)
- AnsiConsole.Markup(format);
- else
- AnsiConsole.Markup(format, objects);
- };
+ {
+ if(objects is null)
+ AnsiConsole.Markup(format);
+ else
+ AnsiConsole.Markup(format, objects);
+ };
+ }
- AaruConsole.DebugWriteLine(MODULE_NAME, "--debug={0}", debug);
+ AaruConsole.DebugWriteLine(MODULE_NAME, "--debug={0}", debug);
AaruConsole.DebugWriteLine(MODULE_NAME, "--encoding={0}", encoding);
- AaruConsole.DebugWriteLine(MODULE_NAME, "--input={0}", imagePath);
- AaruConsole.DebugWriteLine(MODULE_NAME, "--options={0}", options);
- AaruConsole.DebugWriteLine(MODULE_NAME, "--verbose={0}", verbose);
+ AaruConsole.DebugWriteLine(MODULE_NAME, "--input={0}", imagePath);
+ AaruConsole.DebugWriteLine(MODULE_NAME, "--options={0}", options);
+ AaruConsole.DebugWriteLine(MODULE_NAME, "--verbose={0}", verbose);
Statistics.AddCommand("ls");
var filtersList = new FiltersList();
IFilter inputFilter = null;
Core.Spectre.ProgressSingleSpinner(ctx =>
- {
- ctx.AddTask(UI.Identifying_file_filter).IsIndeterminate();
- inputFilter = filtersList.GetFilter(imagePath);
- });
+ {
+ ctx.AddTask(UI.Identifying_file_filter).IsIndeterminate();
+ inputFilter = filtersList.GetFilter(imagePath);
+ });
Dictionary parsedOptions = Core.Options.Parse(options);
AaruConsole.DebugWriteLine(MODULE_NAME, UI.Parsed_options);
@@ -150,6 +141,7 @@ sealed class LsCommand : Command
Encoding encodingClass = null;
if(encoding != null)
+ {
try
{
encodingClass = Claunia.Encoding.Encoding.GetEncoding(encoding);
@@ -163,6 +155,7 @@ sealed class LsCommand : Command
return (int)ErrorNumber.EncodingUnknown;
}
+ }
PluginBase plugins = PluginBase.Singleton;
@@ -172,11 +165,11 @@ sealed class LsCommand : Command
IBaseImage baseImage = null;
Core.Spectre.ProgressSingleSpinner(ctx =>
- {
- ctx.AddTask(UI.Identifying_image_format).IsIndeterminate();
- baseImage = ImageFormat.Detect(inputFilter);
- imageFormat = baseImage as IMediaImage;
- });
+ {
+ ctx.AddTask(UI.Identifying_image_format).IsIndeterminate();
+ baseImage = ImageFormat.Detect(inputFilter);
+ imageFormat = baseImage as IMediaImage;
+ });
if(baseImage == null)
{
@@ -202,10 +195,10 @@ sealed class LsCommand : Command
ErrorNumber opened = ErrorNumber.NoData;
Core.Spectre.ProgressSingleSpinner(ctx =>
- {
- ctx.AddTask(UI.Invoke_Opening_image_file).IsIndeterminate();
- opened = imageFormat.Open(inputFilter);
- });
+ {
+ ctx.AddTask(UI.Invoke_Opening_image_file).IsIndeterminate();
+ opened = imageFormat.Open(inputFilter);
+ });
if(opened != ErrorNumber.NoError)
{
@@ -240,10 +233,10 @@ sealed class LsCommand : Command
List partitions = null;
Core.Spectre.ProgressSingleSpinner(ctx =>
- {
- ctx.AddTask(UI.Enumerating_partitions).IsIndeterminate();
- partitions = Core.Partitions.GetAll(imageFormat);
- });
+ {
+ ctx.AddTask(UI.Enumerating_partitions).IsIndeterminate();
+ partitions = Core.Partitions.GetAll(imageFormat);
+ });
Core.Partitions.AddSchemesToStats(partitions);
@@ -264,7 +257,7 @@ sealed class LsCommand : Command
AaruConsole.WriteLine(UI._0_partitions_found, partitions.Count);
- for(int i = 0; i < partitions.Count; i++)
+ for(var i = 0; i < partitions.Count; i++)
{
AaruConsole.WriteLine();
AaruConsole.WriteLine($"[bold]{string.Format(UI.Partition_0, partitions[i].Sequence)}[/]");
@@ -272,10 +265,12 @@ sealed class LsCommand : Command
List idPlugins = null;
Core.Spectre.ProgressSingleSpinner(ctx =>
- {
- ctx.AddTask(UI.Identifying_filesystems_on_partition).IsIndeterminate();
- Core.Filesystems.Identify(imageFormat, out idPlugins, partitions[i]);
- });
+ {
+ ctx.AddTask(UI.Identifying_filesystems_on_partition).
+ IsIndeterminate();
+ Core.Filesystems.Identify(imageFormat, out idPlugins,
+ partitions[i]);
+ });
if(idPlugins.Count == 0)
AaruConsole.WriteLine(UI.Filesystem_not_identified);
@@ -290,6 +285,7 @@ sealed class LsCommand : Command
}[/]");
foreach(string pluginName in idPlugins)
+ {
if(plugins.ReadOnlyFilesystems.TryGetValue(pluginName, out pluginType))
{
if(Activator.CreateInstance(pluginType) is not IReadOnlyFilesystem fs)
@@ -298,12 +294,14 @@ sealed class LsCommand : Command
AaruConsole.WriteLine($"[bold]{string.Format(UI.As_identified_by_0, fs.Name)}[/]");
Core.Spectre.ProgressSingleSpinner(ctx =>
- {
- ctx.AddTask(UI.Mounting_filesystem).IsIndeterminate();
+ {
+ ctx.AddTask(UI.Mounting_filesystem).
+ IsIndeterminate();
- error = fs.Mount(imageFormat, partitions[i], encodingClass, parsedOptions,
- @namespace);
- });
+ error = fs.Mount(imageFormat, partitions[i],
+ encodingClass, parsedOptions,
+ @namespace);
+ });
if(error == ErrorNumber.NoError)
{
@@ -314,6 +312,7 @@ sealed class LsCommand : Command
else
AaruConsole.ErrorWriteLine(UI.Unable_to_mount_volume_error_0, error.ToString());
}
+ }
}
else
{
@@ -325,10 +324,12 @@ sealed class LsCommand : Command
AaruConsole.WriteLine($"[bold]{string.Format(UI.Identified_by_0, fs.Name)}[/]");
Core.Spectre.ProgressSingleSpinner(ctx =>
- {
- ctx.AddTask(UI.Mounting_filesystem).IsIndeterminate();
- error = fs.Mount(imageFormat, partitions[i], encodingClass, parsedOptions, @namespace);
- });
+ {
+ ctx.AddTask(UI.Mounting_filesystem).IsIndeterminate();
+ error = fs.Mount(imageFormat, partitions[i],
+ encodingClass, parsedOptions,
+ @namespace);
+ });
if(error == ErrorNumber.NoError)
{
@@ -361,14 +362,15 @@ sealed class LsCommand : Command
if(path.StartsWith('/'))
path = path[1..];
- AaruConsole.WriteLine(string.IsNullOrEmpty(path) ? UI.Root_directory
+ AaruConsole.WriteLine(string.IsNullOrEmpty(path)
+ ? UI.Root_directory
: string.Format(UI.Directory_0, Markup.Escape(path)));
Core.Spectre.ProgressSingleSpinner(ctx =>
- {
- ctx.AddTask(UI.Reading_directory).IsIndeterminate();
- error = fs.OpenDir(path, out node);
- });
+ {
+ ctx.AddTask(UI.Reading_directory).IsIndeterminate();
+ error = fs.OpenDir(path, out node);
+ });
if(error != ErrorNumber.NoError)
{
@@ -380,32 +382,37 @@ sealed class LsCommand : Command
Dictionary stats = new();
Core.Spectre.ProgressSingleSpinner(ctx =>
- {
- ctx.AddTask(UI.Retrieving_file_information).IsIndeterminate();
+ {
+ ctx.AddTask(UI.Retrieving_file_information).IsIndeterminate();
- while(fs.ReadDir(node, out string entry) == ErrorNumber.NoError &&
- entry is not null)
- {
- fs.Stat(path + "/" + entry, out FileEntryInfo stat);
+ while(fs.ReadDir(node, out string entry) == ErrorNumber.NoError &&
+ entry is not null)
+ {
+ fs.Stat(path + "/" + entry, out FileEntryInfo stat);
- stats.Add(entry, stat);
- }
+ stats.Add(entry, stat);
+ }
- fs.CloseDir(node);
- });
+ fs.CloseDir(node);
+ });
foreach(KeyValuePair entry in
stats.OrderBy(e => e.Value?.Attributes.HasFlag(FileAttributes.Directory) == false))
+ {
if(longFormat)
{
if(entry.Value != null)
{
if(entry.Value.Attributes.HasFlag(FileAttributes.Directory))
+ {
AaruConsole.WriteLine("{0, 10:d} {0, 12:T} {1, -20} {2}", entry.Value.CreationTimeUtc,
UI.Directory_abbreviation, Markup.Escape(entry.Key));
+ }
else
+ {
AaruConsole.WriteLine("{0, 10:d} {0, 12:T} {1, 6}{2, 14:N0} {3}", entry.Value.CreationTimeUtc,
entry.Value.Inode, entry.Value.Length, Markup.Escape(entry.Key));
+ }
error = fs.ListXAttr(path + "/" + entry.Key, out List xattrs);
@@ -425,9 +432,12 @@ sealed class LsCommand : Command
AaruConsole.WriteLine("{0, 47}{1}", string.Empty, Markup.Escape(entry.Key));
}
else
+ {
AaruConsole.
WriteLine(entry.Value?.Attributes.HasFlag(FileAttributes.Directory) == true ? "{0}/" : "{0}",
entry.Key);
+ }
+ }
AaruConsole.WriteLine();
diff --git a/Aaru/Commands/Filesystem/Options.cs b/Aaru/Commands/Filesystem/Options.cs
index 1f282184f..260e56058 100644
--- a/Aaru/Commands/Filesystem/Options.cs
+++ b/Aaru/Commands/Filesystem/Options.cs
@@ -64,24 +64,26 @@ sealed class ListOptionsCommand : Command
});
AaruConsole.DebugWriteLineEvent += (format, objects) =>
- {
- if(objects is null)
- stderrConsole.MarkupLine(format);
- else
- stderrConsole.MarkupLine(format, objects);
- };
+ {
+ if(objects is null)
+ stderrConsole.MarkupLine(format);
+ else
+ stderrConsole.MarkupLine(format, objects);
+ };
}
if(verbose)
+ {
AaruConsole.WriteEvent += (format, objects) =>
- {
- if(objects is null)
- AnsiConsole.Markup(format);
- else
- AnsiConsole.Markup(format, objects);
- };
+ {
+ if(objects is null)
+ AnsiConsole.Markup(format);
+ else
+ AnsiConsole.Markup(format, objects);
+ };
+ }
- AaruConsole.DebugWriteLine(MODULE_NAME, "--debug={0}", debug);
+ AaruConsole.DebugWriteLine(MODULE_NAME, "--debug={0}", debug);
AaruConsole.DebugWriteLine(MODULE_NAME, "--verbose={0}", verbose);
Statistics.AddCommand("list-options");
@@ -94,7 +96,7 @@ sealed class ListOptionsCommand : Command
if(Activator.CreateInstance(kvp.Value) is not IReadOnlyFilesystem fs)
continue;
- List<(string name, Type type, string description)> options = fs.SupportedOptions.ToList();
+ var options = fs.SupportedOptions.ToList();
if(options.Count == 0)
continue;
@@ -109,8 +111,10 @@ sealed class ListOptionsCommand : Command
table.AddColumn(UI.Title_Description);
foreach((string name, Type type, string description) option in options.OrderBy(t => t.name))
+ {
table.AddRow(Markup.Escape(option.name), $"[italic]{TypeToString(option.type)}[/]",
Markup.Escape(option.description));
+ }
AnsiConsole.Write(table);
AaruConsole.WriteLine();
diff --git a/Aaru/Commands/Formats.cs b/Aaru/Commands/Formats.cs
index d3084982e..08db9c2b3 100644
--- a/Aaru/Commands/Formats.cs
+++ b/Aaru/Commands/Formats.cs
@@ -64,26 +64,28 @@ sealed class FormatsCommand : Command
});
AaruConsole.DebugWriteLineEvent += (format, objects) =>
- {
- if(objects is null)
- stderrConsole.MarkupLine(format);
- else
- stderrConsole.MarkupLine(format, objects);
- };
+ {
+ if(objects is null)
+ stderrConsole.MarkupLine(format);
+ else
+ stderrConsole.MarkupLine(format, objects);
+ };
}
if(verbose)
+ {
AaruConsole.WriteEvent += (format, objects) =>
- {
- if(objects is null)
- AnsiConsole.Markup(format);
- else
- AnsiConsole.Markup(format, objects);
- };
+ {
+ if(objects is null)
+ AnsiConsole.Markup(format);
+ else
+ AnsiConsole.Markup(format, objects);
+ };
+ }
Statistics.AddCommand("formats");
- AaruConsole.DebugWriteLine(MODULE_NAME, "--debug={0}", debug);
+ AaruConsole.DebugWriteLine(MODULE_NAME, "--debug={0}", debug);
AaruConsole.DebugWriteLine(MODULE_NAME, "--verbose={0}", verbose);
PluginBase plugins = PluginBase.Singleton;
@@ -100,10 +102,12 @@ sealed class FormatsCommand : Command
table.AddColumn(UI.Title_Filter);
foreach(KeyValuePair kvp in filtersList.Filters)
+ {
if(verbose)
table.AddRow(kvp.Value.Id.ToString(), Markup.Escape(kvp.Value.Name));
else
table.AddRow(Markup.Escape(kvp.Value.Name));
+ }
AnsiConsole.Write(table);
@@ -113,7 +117,7 @@ sealed class FormatsCommand : Command
{
Title = new TableTitle(string.Format(UI.Read_only_media_image_formats_0,
plugins.MediaImages.Count(t => !t.Value.GetInterfaces().
- Contains(typeof(IWritableImage)))))
+ Contains(typeof(IWritableImage)))))
};
if(verbose)
@@ -122,7 +126,7 @@ sealed class FormatsCommand : Command
table.AddColumn(UI.Title_Media_image_format);
foreach(KeyValuePair kvp in plugins.MediaImages.Where(t => !t.Value.GetInterfaces().
- Contains(typeof(IWritableImage))))
+ Contains(typeof(IWritableImage))))
{
if(Activator.CreateInstance(kvp.Value) is not IMediaImage imagePlugin)
continue;
@@ -166,8 +170,8 @@ sealed class FormatsCommand : Command
{
Title = new TableTitle(string.Format(UI.Supported_filesystems_for_identification_and_information_only_0,
plugins.Filesystems.Count(t => !t.Value.GetInterfaces().
- Contains(typeof(
- IReadOnlyFilesystem)))))
+ Contains(typeof(
+ IReadOnlyFilesystem)))))
};
if(verbose)
@@ -176,8 +180,8 @@ sealed class FormatsCommand : Command
table.AddColumn(UI.Title_Filesystem);
foreach(KeyValuePair kvp in plugins.Filesystems.Where(t => !t.Value.GetInterfaces().
- Contains(typeof(
- IReadOnlyFilesystem))))
+ Contains(typeof(
+ IReadOnlyFilesystem))))
{
if(Activator.CreateInstance(kvp.Value) is not IFilesystem fs)
continue;
diff --git a/Aaru/Commands/Image/Checksum.cs b/Aaru/Commands/Image/Checksum.cs
index e0140f9ec..74fd6133b 100644
--- a/Aaru/Commands/Image/Checksum.cs
+++ b/Aaru/Commands/Image/Checksum.cs
@@ -58,50 +58,29 @@ sealed class ChecksumCommand : Command
{
AddAlias("chk");
- Add(new Option(new[]
- {
- "--adler32", "-a"
- }, () => false, UI.Calculates_Adler_32));
+ Add(new Option(new[] { "--adler32", "-a" }, () => false, UI.Calculates_Adler_32));
Add(new Option("--crc16", () => true, UI.Calculates_CRC16));
- Add(new Option(new[]
- {
- "--crc32", "-c"
- }, () => true, UI.Calculates_CRC32));
+ Add(new Option(new[] { "--crc32", "-c" }, () => true, UI.Calculates_CRC32));
- Add(new Option("--crc64", () => true, UI.Calculates_CRC64_ECMA));
+ Add(new Option("--crc64", () => true, UI.Calculates_CRC64_ECMA));
Add(new Option("--fletcher16", () => false, UI.Calculates_Fletcher_16));
Add(new Option("--fletcher32", () => false, UI.Calculates_Fletcher_32));
- Add(new Option(new[]
- {
- "--md5", "-m"
- }, () => true, UI.Calculates_MD5));
+ Add(new Option(new[] { "--md5", "-m" }, () => true, UI.Calculates_MD5));
- Add(new Option(new[]
- {
- "--separated-tracks", "-t"
- }, () => true, UI.Checksums_each_track_separately));
+ Add(new Option(new[] { "--separated-tracks", "-t" }, () => true, UI.Checksums_each_track_separately));
- Add(new Option(new[]
- {
- "--sha1", "-s"
- }, () => true, UI.Calculates_SHA1));
+ Add(new Option(new[] { "--sha1", "-s" }, () => true, UI.Calculates_SHA1));
Add(new Option("--sha256", () => false, UI.Calculates_SHA256));
Add(new Option("--sha384", () => false, UI.Calculates_SHA384));
- Add(new Option("--sha512", () => true, UI.Calculates_SHA512));
+ Add(new Option("--sha512", () => true, UI.Calculates_SHA512));
- Add(new Option(new[]
- {
- "--spamsum", "-f"
- }, () => true, UI.Calculates_SpamSum_fuzzy_hash));
+ Add(new Option(new[] { "--spamsum", "-f" }, () => true, UI.Calculates_SpamSum_fuzzy_hash));
- Add(new Option(new[]
- {
- "--whole-disc", "-w"
- }, () => true, UI.Checksums_the_whole_disc));
+ Add(new Option(new[] { "--whole-disc", "-w" }, () => true, UI.Checksums_the_whole_disc));
AddArgument(new Argument
{
@@ -113,9 +92,9 @@ sealed class ChecksumCommand : Command
Handler = CommandHandler.Create(GetType().GetMethod(nameof(Invoke)));
}
- public static int Invoke(bool debug, bool verbose, bool adler32, bool crc16, bool crc32, bool crc64,
- bool fletcher16, bool fletcher32, bool md5, bool sha1, bool sha256, bool sha384,
- bool sha512, bool spamSum, string imagePath, bool separatedTracks, bool wholeDisc)
+ public static int Invoke(bool debug, bool verbose, bool adler32, bool crc16, bool crc32, bool crc64,
+ bool fletcher16, bool fletcher32, bool md5, bool sha1, bool sha256, bool sha384,
+ bool sha512, bool spamSum, string imagePath, bool separatedTracks, bool wholeDisc)
{
MainClass.PrintCopyright();
@@ -127,51 +106,53 @@ sealed class ChecksumCommand : Command
});
AaruConsole.DebugWriteLineEvent += (format, objects) =>
- {
- if(objects is null)
- stderrConsole.MarkupLine(format);
- else
- stderrConsole.MarkupLine(format, objects);
- };
+ {
+ if(objects is null)
+ stderrConsole.MarkupLine(format);
+ else
+ stderrConsole.MarkupLine(format, objects);
+ };
}
if(verbose)
+ {
AaruConsole.WriteEvent += (format, objects) =>
- {
- if(objects is null)
- AnsiConsole.Markup(format);
- else
- AnsiConsole.Markup(format, objects);
- };
+ {
+ if(objects is null)
+ AnsiConsole.Markup(format);
+ else
+ AnsiConsole.Markup(format, objects);
+ };
+ }
Statistics.AddCommand("checksum");
- AaruConsole.DebugWriteLine(MODULE_NAME, "--adler32={0}", adler32);
- AaruConsole.DebugWriteLine(MODULE_NAME, "--crc16={0}", crc16);
- AaruConsole.DebugWriteLine(MODULE_NAME, "--crc32={0}", crc32);
- AaruConsole.DebugWriteLine(MODULE_NAME, "--crc64={0}", crc64);
- AaruConsole.DebugWriteLine(MODULE_NAME, "--debug={0}", debug);
- AaruConsole.DebugWriteLine(MODULE_NAME, "--fletcher16={0}", fletcher16);
- AaruConsole.DebugWriteLine(MODULE_NAME, "--fletcher32={0}", fletcher32);
- AaruConsole.DebugWriteLine(MODULE_NAME, "--input={0}", imagePath);
- AaruConsole.DebugWriteLine(MODULE_NAME, "--md5={0}", md5);
+ AaruConsole.DebugWriteLine(MODULE_NAME, "--adler32={0}", adler32);
+ AaruConsole.DebugWriteLine(MODULE_NAME, "--crc16={0}", crc16);
+ AaruConsole.DebugWriteLine(MODULE_NAME, "--crc32={0}", crc32);
+ AaruConsole.DebugWriteLine(MODULE_NAME, "--crc64={0}", crc64);
+ AaruConsole.DebugWriteLine(MODULE_NAME, "--debug={0}", debug);
+ AaruConsole.DebugWriteLine(MODULE_NAME, "--fletcher16={0}", fletcher16);
+ AaruConsole.DebugWriteLine(MODULE_NAME, "--fletcher32={0}", fletcher32);
+ AaruConsole.DebugWriteLine(MODULE_NAME, "--input={0}", imagePath);
+ AaruConsole.DebugWriteLine(MODULE_NAME, "--md5={0}", md5);
AaruConsole.DebugWriteLine(MODULE_NAME, "--separated-tracks={0}", separatedTracks);
- AaruConsole.DebugWriteLine(MODULE_NAME, "--sha1={0}", sha1);
- AaruConsole.DebugWriteLine(MODULE_NAME, "--sha256={0}", sha256);
- AaruConsole.DebugWriteLine(MODULE_NAME, "--sha384={0}", sha384);
- AaruConsole.DebugWriteLine(MODULE_NAME, "--sha512={0}", sha512);
- AaruConsole.DebugWriteLine(MODULE_NAME, "--spamsum={0}", spamSum);
- AaruConsole.DebugWriteLine(MODULE_NAME, "--verbose={0}", verbose);
- AaruConsole.DebugWriteLine(MODULE_NAME, "--whole-disc={0}", wholeDisc);
+ AaruConsole.DebugWriteLine(MODULE_NAME, "--sha1={0}", sha1);
+ AaruConsole.DebugWriteLine(MODULE_NAME, "--sha256={0}", sha256);
+ AaruConsole.DebugWriteLine(MODULE_NAME, "--sha384={0}", sha384);
+ AaruConsole.DebugWriteLine(MODULE_NAME, "--sha512={0}", sha512);
+ AaruConsole.DebugWriteLine(MODULE_NAME, "--spamsum={0}", spamSum);
+ AaruConsole.DebugWriteLine(MODULE_NAME, "--verbose={0}", verbose);
+ AaruConsole.DebugWriteLine(MODULE_NAME, "--whole-disc={0}", wholeDisc);
var filtersList = new FiltersList();
IFilter inputFilter = null;
Core.Spectre.ProgressSingleSpinner(ctx =>
- {
- ctx.AddTask(UI.Identifying_file_filter).IsIndeterminate();
- inputFilter = filtersList.GetFilter(imagePath);
- });
+ {
+ ctx.AddTask(UI.Identifying_file_filter).IsIndeterminate();
+ inputFilter = filtersList.GetFilter(imagePath);
+ });
if(inputFilter == null)
{
@@ -183,10 +164,10 @@ sealed class ChecksumCommand : Command
IBaseImage inputFormat = null;
Core.Spectre.ProgressSingleSpinner(ctx =>
- {
- ctx.AddTask(UI.Identifying_image_format).IsIndeterminate();
- inputFormat = ImageFormat.Detect(inputFilter);
- });
+ {
+ ctx.AddTask(UI.Identifying_image_format).IsIndeterminate();
+ inputFormat = ImageFormat.Detect(inputFilter);
+ });
if(inputFormat == null)
{
@@ -198,10 +179,10 @@ sealed class ChecksumCommand : Command
ErrorNumber opened = ErrorNumber.NoData;
Core.Spectre.ProgressSingleSpinner(ctx =>
- {
- ctx.AddTask(UI.Invoke_Opening_image_file).IsIndeterminate();
- opened = inputFormat.Open(inputFilter);
- });
+ {
+ ctx.AddTask(UI.Invoke_Opening_image_file).IsIndeterminate();
+ opened = inputFormat.Open(inputFilter);
+ });
if(opened != ErrorNumber.NoError)
{
@@ -258,7 +239,7 @@ sealed class ChecksumCommand : Command
switch(inputFormat)
{
- case IOpticalMediaImage { Tracks: {} } opticalInput:
+ case IOpticalMediaImage { Tracks: not null } opticalInput:
try
{
Checksum trackChecksum = null;
@@ -271,143 +252,154 @@ sealed class ChecksumCommand : Command
AnsiConsole.Progress().AutoClear(true).HideCompleted(true).
Columns(new TaskDescriptionColumn(), new ProgressBarColumn(), new PercentageColumn()).
Start(ctx =>
- {
- ProgressTask discTask = ctx.AddTask(Localization.Core.Hashing_tracks);
- discTask.MaxValue = inputTracks.Count;
+ {
+ ProgressTask discTask = ctx.AddTask(Localization.Core.Hashing_tracks);
+ discTask.MaxValue = inputTracks.Count;
- foreach(Track currentTrack in inputTracks)
- {
- discTask.Description =
- string.Format(UI.Hashing_track_0_of_1, discTask.Value + 1,
- inputTracks.Count);
+ foreach(Track currentTrack in inputTracks)
+ {
+ discTask.Description =
+ string.Format(UI.Hashing_track_0_of_1, discTask.Value + 1,
+ inputTracks.Count);
- ProgressTask trackTask = ctx.AddTask(UI.Hashing_sector);
+ ProgressTask trackTask = ctx.AddTask(UI.Hashing_sector);
- /*
- if(currentTrack.StartSector - previousTrackEnd != 0 && wholeDisc)
- for(ulong i = previousTrackEnd + 1; i < currentTrack.StartSector; i++)
- {
- AaruConsole.Write("\rHashing track-less sector {0}", i);
+ /*
+ if(currentTrack.StartSector - previousTrackEnd != 0 && wholeDisc)
+ for(ulong i = previousTrackEnd + 1; i < currentTrack.StartSector; i++)
+ {
+ AaruConsole.Write("\rHashing track-less sector {0}", i);
- byte[] hiddenSector = inputFormat.ReadSector(i);
+ byte[] hiddenSector = inputFormat.ReadSector(i);
- mediaChecksum?.Update(hiddenSector);
- }
- */
+ mediaChecksum?.Update(hiddenSector);
+ }
+ */
- AaruConsole.DebugWriteLine(MODULE_NAME,
- UI.Track_0_starts_at_sector_1_and_ends_at_sector_2,
- currentTrack.Sequence, currentTrack.StartSector,
- currentTrack.EndSector);
+ AaruConsole.DebugWriteLine(MODULE_NAME,
+ UI.
+ Track_0_starts_at_sector_1_and_ends_at_sector_2,
+ currentTrack.Sequence,
+ currentTrack.StartSector,
+ currentTrack.EndSector);
- if(separatedTracks)
- trackChecksum = new Checksum(enabledChecksums);
+ if(separatedTracks)
+ trackChecksum = new Checksum(enabledChecksums);
- ulong sectors = currentTrack.EndSector - currentTrack.StartSector + 1;
+ ulong sectors = currentTrack.EndSector - currentTrack.StartSector + 1;
- trackTask.MaxValue = sectors;
+ trackTask.MaxValue = sectors;
- ulong doneSectors = 0;
+ ulong doneSectors = 0;
- while(doneSectors < sectors)
- {
- byte[] sector;
+ while(doneSectors < sectors)
+ {
+ byte[] sector;
- if(sectors - doneSectors >= SECTORS_TO_READ)
- {
- errno = opticalInput.ReadSectors(doneSectors, SECTORS_TO_READ,
- currentTrack.Sequence, out sector);
+ if(sectors - doneSectors >= SECTORS_TO_READ)
+ {
+ errno = opticalInput.ReadSectors(doneSectors, SECTORS_TO_READ,
+ currentTrack.Sequence, out sector);
- trackTask.Description =
- string.Format(UI.Hashing_sectors_0_to_2_of_track_1, doneSectors,
- currentTrack.Sequence, doneSectors + SECTORS_TO_READ);
+ trackTask.Description =
+ string.Format(UI.Hashing_sectors_0_to_2_of_track_1,
+ doneSectors,
+ currentTrack.Sequence,
+ doneSectors + SECTORS_TO_READ);
- if(errno != ErrorNumber.NoError)
- {
- AaruConsole.
- ErrorWriteLine(string.
- Format(UI.Error_0_while_reading_1_sectors_from_sector_2,
- errno, SECTORS_TO_READ,
- doneSectors));
+ if(errno != ErrorNumber.NoError)
+ {
+ AaruConsole.
+ ErrorWriteLine(string.
+ Format(UI.Error_0_while_reading_1_sectors_from_sector_2,
+ errno, SECTORS_TO_READ,
+ doneSectors));
- return;
- }
+ return;
+ }
- doneSectors += SECTORS_TO_READ;
- }
- else
- {
- errno = opticalInput.ReadSectors(doneSectors,
- (uint)(sectors - doneSectors), currentTrack.Sequence,
- out sector);
+ doneSectors += SECTORS_TO_READ;
+ }
+ else
+ {
+ errno = opticalInput.ReadSectors(doneSectors,
+ (uint)(sectors - doneSectors), currentTrack.Sequence,
+ out sector);
- trackTask.Description =
- string.Format(UI.Hashing_sectors_0_to_2_of_track_1, doneSectors,
- currentTrack.Sequence,
- doneSectors + (sectors - doneSectors));
+ trackTask.Description =
+ string.Format(UI.Hashing_sectors_0_to_2_of_track_1,
+ doneSectors,
+ currentTrack.Sequence,
+ doneSectors + (sectors - doneSectors));
- if(errno != ErrorNumber.NoError)
- {
- AaruConsole.
- ErrorWriteLine(string.
- Format(UI.Error_0_while_reading_1_sectors_from_sector_2,
- errno, sectors - doneSectors,
- doneSectors));
+ if(errno != ErrorNumber.NoError)
+ {
+ AaruConsole.
+ ErrorWriteLine(string.
+ Format(UI.Error_0_while_reading_1_sectors_from_sector_2,
+ errno, sectors - doneSectors,
+ doneSectors));
- return;
- }
+ return;
+ }
- doneSectors += sectors - doneSectors;
- }
+ doneSectors += sectors - doneSectors;
+ }
- if(wholeDisc)
- mediaChecksum?.Update(sector);
+ if(wholeDisc)
+ mediaChecksum?.Update(sector);
- if(separatedTracks)
- trackChecksum?.Update(sector);
+ if(separatedTracks)
+ trackChecksum?.Update(sector);
- trackTask.Value = doneSectors;
- }
+ trackTask.Value = doneSectors;
+ }
- trackTask.StopTask();
- AaruConsole.WriteLine();
+ trackTask.StopTask();
+ AaruConsole.WriteLine();
- if(!separatedTracks)
- continue;
+ if(!separatedTracks)
+ continue;
- if(trackChecksum == null)
- continue;
+ if(trackChecksum == null)
+ continue;
- foreach(CommonTypes.AaruMetadata.Checksum chk in trackChecksum.End())
- AaruConsole.WriteLine($"[bold]{string.Format(UI.Checksums_Track_0_has_1,
- currentTrack.Sequence, chk.Type)}[/] {chk.Value}");
+ foreach(CommonTypes.AaruMetadata.Checksum chk in trackChecksum.End())
+ {
+ AaruConsole.
+ WriteLine($"[bold]{string.Format(UI.Checksums_Track_0_has_1,
+ currentTrack.Sequence, chk.Type)}[/] {chk.Value}");
+ }
- discTask.Increment(1);
- }
+ discTask.Increment(1);
+ }
- /*
- if(opticalInput.Info.Sectors - previousTrackEnd != 0 && wholeDisc)
- for(ulong i = previousTrackEnd + 1; i < opticalInput.Info.Sectors; i++)
- {
- AaruConsole.Write("\rHashing track-less sector {0}", i);
+ /*
+ if(opticalInput.Info.Sectors - previousTrackEnd != 0 && wholeDisc)
+ for(ulong i = previousTrackEnd + 1; i < opticalInput.Info.Sectors; i++)
+ {
+ AaruConsole.Write("\rHashing track-less sector {0}", i);
- byte[] hiddenSector = inputFormat.ReadSector(i);
- mediaChecksum?.Update(hiddenSector);
- }
- */
+ byte[] hiddenSector = inputFormat.ReadSector(i);
+ mediaChecksum?.Update(hiddenSector);
+ }
+ */
- if(!wholeDisc)
- return;
+ if(!wholeDisc)
+ return;
- if(mediaChecksum == null)
- return;
+ if(mediaChecksum == null)
+ return;
- AaruConsole.WriteLine();
+ AaruConsole.WriteLine();
- foreach(CommonTypes.AaruMetadata.Checksum chk in mediaChecksum.End())
- AaruConsole.WriteLine($"[bold]{string.Format(UI.Checksums_Disc_has_0, chk.Type)
- }:[/] {chk.Value}");
- });
+ foreach(CommonTypes.AaruMetadata.Checksum chk in mediaChecksum.End())
+ {
+ AaruConsole.
+ WriteLine($"[bold]{string.Format(UI.Checksums_Disc_has_0, chk.Type)
+ }:[/] {chk.Value}");
+ }
+ });
if(errno != ErrorNumber.NoError)
return (int)errno;
@@ -434,153 +426,166 @@ sealed class ChecksumCommand : Command
AnsiConsole.Progress().AutoClear(true).HideCompleted(true).
Columns(new TaskDescriptionColumn(), new ProgressBarColumn(), new PercentageColumn()).
Start(ctx =>
- {
- ProgressTask tapeTask = ctx.AddTask(Localization.Core.Hashing_files);
- tapeTask.MaxValue = tapeImage.Files.Count;
+ {
+ ProgressTask tapeTask = ctx.AddTask(Localization.Core.Hashing_files);
+ tapeTask.MaxValue = tapeImage.Files.Count;
- foreach(TapeFile currentFile in tapeImage.Files)
- {
- tapeTask.Description =
- string.Format(UI.Hashing_file_0_of_1, currentFile.File, tapeImage.Files.Count);
+ foreach(TapeFile currentFile in tapeImage.Files)
+ {
+ tapeTask.Description =
+ string.Format(UI.Hashing_file_0_of_1, currentFile.File,
+ tapeImage.Files.Count);
- if(currentFile.FirstBlock - previousFileEnd != 0 && wholeDisc)
- {
- ProgressTask preFileTask = ctx.AddTask(UI.Hashing_sector);
- preFileTask.MaxValue = currentFile.FirstBlock - previousFileEnd;
+ if(currentFile.FirstBlock - previousFileEnd != 0 && wholeDisc)
+ {
+ ProgressTask preFileTask = ctx.AddTask(UI.Hashing_sector);
+ preFileTask.MaxValue = currentFile.FirstBlock - previousFileEnd;
- for(ulong i = previousFileEnd + 1; i < currentFile.FirstBlock; i++)
- {
- preFileTask.Description = string.Format(UI.Hashing_file_less_block_0, i);
+ for(ulong i = previousFileEnd + 1; i < currentFile.FirstBlock; i++)
+ {
+ preFileTask.Description =
+ string.Format(UI.Hashing_file_less_block_0, i);
- errno = tapeImage.ReadSector(i, out byte[] hiddenSector);
+ errno = tapeImage.ReadSector(i, out byte[] hiddenSector);
- if(errno != ErrorNumber.NoError)
- {
- AaruConsole.
- ErrorWriteLine(string.Format(UI.Error_0_while_reading_block_1,
- errno, i));
+ if(errno != ErrorNumber.NoError)
+ {
+ AaruConsole.
+ ErrorWriteLine(string.Format(UI.Error_0_while_reading_block_1,
+ errno, i));
- return;
- }
+ return;
+ }
- mediaChecksum?.Update(hiddenSector);
- preFileTask.Increment(1);
- }
+ mediaChecksum?.Update(hiddenSector);
+ preFileTask.Increment(1);
+ }
- preFileTask.StopTask();
- }
+ preFileTask.StopTask();
+ }
- AaruConsole.DebugWriteLine(MODULE_NAME,
- UI.File_0_starts_at_block_1_and_ends_at_block_2,
- currentFile.File, currentFile.FirstBlock,
- currentFile.LastBlock);
+ AaruConsole.DebugWriteLine(MODULE_NAME,
+ UI.File_0_starts_at_block_1_and_ends_at_block_2,
+ currentFile.File, currentFile.FirstBlock,
+ currentFile.LastBlock);
- if(separatedTracks)
- trackChecksum = new Checksum(enabledChecksums);
+ if(separatedTracks)
+ trackChecksum = new Checksum(enabledChecksums);
- ulong sectors = currentFile.LastBlock - currentFile.FirstBlock + 1;
- ulong doneSectors = 0;
+ ulong sectors = currentFile.LastBlock - currentFile.FirstBlock + 1;
+ ulong doneSectors = 0;
- ProgressTask fileTask = ctx.AddTask(UI.Hashing_sector);
- fileTask.MaxValue = sectors;
+ ProgressTask fileTask = ctx.AddTask(UI.Hashing_sector);
+ fileTask.MaxValue = sectors;
- while(doneSectors < sectors)
- {
- byte[] sector;
+ while(doneSectors < sectors)
+ {
+ byte[] sector;
- if(sectors - doneSectors >= SECTORS_TO_READ)
- {
- errno = tapeImage.ReadSectors(doneSectors + currentFile.FirstBlock,
- SECTORS_TO_READ, out sector);
+ if(sectors - doneSectors >= SECTORS_TO_READ)
+ {
+ errno = tapeImage.ReadSectors(doneSectors + currentFile.FirstBlock,
+ SECTORS_TO_READ, out sector);
- if(errno != ErrorNumber.NoError)
- {
- AaruConsole.
- ErrorWriteLine(string.
- Format(UI.Error_0_while_reading_1_sectors_from_sector_2,
- errno, SECTORS_TO_READ,
- doneSectors + currentFile.FirstBlock));
+ if(errno != ErrorNumber.NoError)
+ {
+ AaruConsole.
+ ErrorWriteLine(string.
+ Format(UI.Error_0_while_reading_1_sectors_from_sector_2,
+ errno, SECTORS_TO_READ,
+ doneSectors +
+ currentFile.FirstBlock));
- return;
- }
+ return;
+ }
- fileTask.Description =
- string.Format(UI.Hashing_blocks_0_to_2_of_file_1, doneSectors,
- currentFile.File, doneSectors + SECTORS_TO_READ);
+ fileTask.Description =
+ string.Format(UI.Hashing_blocks_0_to_2_of_file_1, doneSectors,
+ currentFile.File, doneSectors + SECTORS_TO_READ);
- doneSectors += SECTORS_TO_READ;
- }
- else
- {
- errno = tapeImage.ReadSectors(doneSectors + currentFile.FirstBlock,
- (uint)(sectors - doneSectors), out sector);
+ doneSectors += SECTORS_TO_READ;
+ }
+ else
+ {
+ errno = tapeImage.ReadSectors(doneSectors + currentFile.FirstBlock,
+ (uint)(sectors - doneSectors),
+ out sector);
- if(errno != ErrorNumber.NoError)
- {
- AaruConsole.
- ErrorWriteLine(string.
- Format(UI.Error_0_while_reading_1_sectors_from_sector_2,
- errno, sectors - doneSectors,
- doneSectors + currentFile.FirstBlock));
+ if(errno != ErrorNumber.NoError)
+ {
+ AaruConsole.
+ ErrorWriteLine(string.
+ Format(UI.Error_0_while_reading_1_sectors_from_sector_2,
+ errno, sectors - doneSectors,
+ doneSectors +
+ currentFile.FirstBlock));
- return;
- }
+ return;
+ }
- fileTask.Description =
- string.Format(UI.Hashing_blocks_0_to_2_of_file_1, doneSectors,
- currentFile.File, doneSectors + (sectors - doneSectors));
+ fileTask.Description =
+ string.Format(UI.Hashing_blocks_0_to_2_of_file_1, doneSectors,
+ currentFile.File,
+ doneSectors + (sectors - doneSectors));
- doneSectors += sectors - doneSectors;
- }
+ doneSectors += sectors - doneSectors;
+ }
- fileTask.Value = doneSectors;
+ fileTask.Value = doneSectors;
- if(wholeDisc)
- mediaChecksum?.Update(sector);
+ if(wholeDisc)
+ mediaChecksum?.Update(sector);
- if(separatedTracks)
- trackChecksum?.Update(sector);
- }
+ if(separatedTracks)
+ trackChecksum?.Update(sector);
+ }
- fileTask.StopTask();
- AaruConsole.WriteLine();
+ fileTask.StopTask();
+ AaruConsole.WriteLine();
- if(separatedTracks)
- if(trackChecksum != null)
- foreach(CommonTypes.AaruMetadata.Checksum chk in trackChecksum.End())
- AaruConsole.WriteLine($"[bold]{string.Format(UI.Checksums_File_0_has_1,
- currentFile.File, chk.Type)}[/]: {chk.Value}");
+ if(separatedTracks)
+ {
+ if(trackChecksum != null)
+ {
+ foreach(CommonTypes.AaruMetadata.Checksum chk in trackChecksum.End())
+ {
+ AaruConsole.
+ WriteLine($"[bold]{string.Format(UI.Checksums_File_0_has_1,
+ currentFile.File, chk.Type)}[/]: {chk.Value}");
+ }
+ }
+ }
- previousFileEnd = currentFile.LastBlock;
+ previousFileEnd = currentFile.LastBlock;
- tapeTask.Increment(1);
- }
+ tapeTask.Increment(1);
+ }
- if(tapeImage.Info.Sectors - previousFileEnd == 0 ||
- !wholeDisc)
- return;
+ if(tapeImage.Info.Sectors - previousFileEnd == 0 ||
+ !wholeDisc)
+ return;
- ProgressTask postFileTask = ctx.AddTask(UI.Hashing_sector);
- postFileTask.MaxValue = tapeImage.Info.Sectors - previousFileEnd;
+ ProgressTask postFileTask = ctx.AddTask(UI.Hashing_sector);
+ postFileTask.MaxValue = tapeImage.Info.Sectors - previousFileEnd;
- for(ulong i = previousFileEnd + 1; i < tapeImage.Info.Sectors; i++)
- {
- postFileTask.Description = string.Format(UI.Hashing_file_less_block_0, i);
+ for(ulong i = previousFileEnd + 1; i < tapeImage.Info.Sectors; i++)
+ {
+ postFileTask.Description = string.Format(UI.Hashing_file_less_block_0, i);
- errno = tapeImage.ReadSector(i, out byte[] hiddenSector);
+ errno = tapeImage.ReadSector(i, out byte[] hiddenSector);
- if(errno != ErrorNumber.NoError)
- {
- AaruConsole.ErrorWriteLine(string.Format(UI.Error_0_while_reading_block_1,
- errno, i));
+ if(errno != ErrorNumber.NoError)
+ {
+ AaruConsole.ErrorWriteLine(string.Format(UI.Error_0_while_reading_block_1,
+ errno, i));
- return;
- }
+ return;
+ }
- mediaChecksum?.Update(hiddenSector);
- postFileTask.Increment(1);
- }
- });
+ mediaChecksum?.Update(hiddenSector);
+ postFileTask.Increment(1);
+ }
+ });
if(errno != ErrorNumber.NoError)
return (int)errno;
@@ -590,8 +595,10 @@ sealed class ChecksumCommand : Command
AaruConsole.WriteLine();
foreach(CommonTypes.AaruMetadata.Checksum chk in mediaChecksum.End())
+ {
AaruConsole.WriteLine($"[bold]{string.Format(UI.Checksums_Tape_has_0, chk.Type)}[/] {chk.Value
}");
+ }
}
break;
@@ -604,64 +611,68 @@ sealed class ChecksumCommand : Command
AnsiConsole.Progress().AutoClear(true).HideCompleted(true).
Columns(new TaskDescriptionColumn(), new ProgressBarColumn(), new PercentageColumn()).
Start(ctx =>
- {
- ProgressTask imageTask = ctx.AddTask(UI.Hashing_image);
- ulong length = byteAddressableImage.Info.Sectors;
- imageTask.MaxValue = length;
- ulong doneBytes = 0;
- byte[] data = new byte[BYTES_TO_READ];
+ {
+ ProgressTask imageTask = ctx.AddTask(UI.Hashing_image);
+ ulong length = byteAddressableImage.Info.Sectors;
+ imageTask.MaxValue = length;
+ ulong doneBytes = 0;
+ var data = new byte[BYTES_TO_READ];
- while(doneBytes < length)
- {
- int bytesRead;
+ while(doneBytes < length)
+ {
+ int bytesRead;
- if(length - doneBytes >= BYTES_TO_READ)
- {
- errno = byteAddressableImage.ReadBytes(data, 0, BYTES_TO_READ, out bytesRead);
+ if(length - doneBytes >= BYTES_TO_READ)
+ {
+ errno = byteAddressableImage.ReadBytes(data, 0, BYTES_TO_READ,
+ out bytesRead);
- if(errno != ErrorNumber.NoError)
- {
- AaruConsole.
- ErrorWriteLine(string.Format(UI.Error_0_while_reading_1_bytes_from_2,
- errno, BYTES_TO_READ, doneBytes));
+ if(errno != ErrorNumber.NoError)
+ {
+ AaruConsole.
+ ErrorWriteLine(string.
+ Format(UI.Error_0_while_reading_1_bytes_from_2,
+ errno, BYTES_TO_READ, doneBytes));
- return;
- }
+ return;
+ }
- imageTask.Description =
- string.Format(UI.Hashing_bytes_0_to_1, doneBytes,
- doneBytes + BYTES_TO_READ);
+ imageTask.Description =
+ string.Format(UI.Hashing_bytes_0_to_1, doneBytes,
+ doneBytes + BYTES_TO_READ);
- doneBytes += (ulong)bytesRead;
+ doneBytes += (ulong)bytesRead;
- if(bytesRead == 0)
- break;
- }
- else
- {
- errno = byteAddressableImage.ReadBytes(data, 0, (int)(length - doneBytes),
- out bytesRead);
+ if(bytesRead == 0)
+ break;
+ }
+ else
+ {
+ errno = byteAddressableImage.ReadBytes(data, 0, (int)(length - doneBytes),
+ out bytesRead);
- if(errno != ErrorNumber.NoError)
- {
- AaruConsole.
- ErrorWriteLine(string.Format(UI.Error_0_while_reading_1_bytes_from_2,
- errno, length - doneBytes, doneBytes));
+ if(errno != ErrorNumber.NoError)
+ {
+ AaruConsole.
+ ErrorWriteLine(string.
+ Format(UI.Error_0_while_reading_1_bytes_from_2,
+ errno, length - doneBytes,
+ doneBytes));
- return;
- }
+ return;
+ }
- imageTask.Description =
- string.Format(UI.Hashing_bytes_0_to_1, doneBytes,
- doneBytes + (length - doneBytes));
+ imageTask.Description =
+ string.Format(UI.Hashing_bytes_0_to_1, doneBytes,
+ doneBytes + (length - doneBytes));
- doneBytes += length - doneBytes;
- }
+ doneBytes += length - doneBytes;
+ }
- mediaChecksum.Update(data);
- imageTask.Value = doneBytes;
- }
- });
+ mediaChecksum.Update(data);
+ imageTask.Value = doneBytes;
+ }
+ });
if(errno != ErrorNumber.NoError)
return (int)errno;
@@ -682,62 +693,64 @@ sealed class ChecksumCommand : Command
AnsiConsole.Progress().AutoClear(true).HideCompleted(true).
Columns(new TaskDescriptionColumn(), new ProgressBarColumn(), new PercentageColumn()).
Start(ctx =>
- {
- ProgressTask diskTask = ctx.AddTask(Localization.Core.Hashing_sectors);
- ulong sectors = mediaImage.Info.Sectors;
- diskTask.MaxValue = sectors;
- ulong doneSectors = 0;
+ {
+ ProgressTask diskTask = ctx.AddTask(Localization.Core.Hashing_sectors);
+ ulong sectors = mediaImage.Info.Sectors;
+ diskTask.MaxValue = sectors;
+ ulong doneSectors = 0;
- while(doneSectors < sectors)
- {
- byte[] sector;
+ while(doneSectors < sectors)
+ {
+ byte[] sector;
- if(sectors - doneSectors >= SECTORS_TO_READ)
- {
- errno = mediaImage.ReadSectors(doneSectors, SECTORS_TO_READ, out sector);
+ if(sectors - doneSectors >= SECTORS_TO_READ)
+ {
+ errno = mediaImage.ReadSectors(doneSectors, SECTORS_TO_READ, out sector);
- if(errno != ErrorNumber.NoError)
- {
- AaruConsole.
- ErrorWriteLine(string.
- Format(UI.Error_0_while_reading_1_sectors_from_sector_2,
- errno, SECTORS_TO_READ, doneSectors));
+ if(errno != ErrorNumber.NoError)
+ {
+ AaruConsole.
+ ErrorWriteLine(string.
+ Format(UI.Error_0_while_reading_1_sectors_from_sector_2,
+ errno, SECTORS_TO_READ,
+ doneSectors));
- return;
- }
+ return;
+ }
- diskTask.Description =
- string.Format(UI.Hashing_sectors_0_to_1, doneSectors,
- doneSectors + SECTORS_TO_READ);
+ diskTask.Description =
+ string.Format(UI.Hashing_sectors_0_to_1, doneSectors,
+ doneSectors + SECTORS_TO_READ);
- doneSectors += SECTORS_TO_READ;
- }
- else
- {
- errno = mediaImage.ReadSectors(doneSectors, (uint)(sectors - doneSectors),
- out sector);
+ doneSectors += SECTORS_TO_READ;
+ }
+ else
+ {
+ errno = mediaImage.ReadSectors(doneSectors, (uint)(sectors - doneSectors),
+ out sector);
- if(errno != ErrorNumber.NoError)
- {
- AaruConsole.
- ErrorWriteLine(string.
- Format(UI.Error_0_while_reading_1_sectors_from_sector_2,
- errno, sectors - doneSectors, doneSectors));
+ if(errno != ErrorNumber.NoError)
+ {
+ AaruConsole.
+ ErrorWriteLine(string.
+ Format(UI.Error_0_while_reading_1_sectors_from_sector_2,
+ errno, sectors - doneSectors,
+ doneSectors));
- return;
- }
+ return;
+ }
- diskTask.Description =
- string.Format(UI.Hashing_sectors_0_to_1, doneSectors,
- doneSectors + (sectors - doneSectors));
+ diskTask.Description =
+ string.Format(UI.Hashing_sectors_0_to_1, doneSectors,
+ doneSectors + (sectors - doneSectors));
- doneSectors += sectors - doneSectors;
- }
+ doneSectors += sectors - doneSectors;
+ }
- mediaChecksum.Update(sector);
- diskTask.Value = doneSectors;
- }
- });
+ mediaChecksum.Update(sector);
+ diskTask.Value = doneSectors;
+ }
+ });
if(errno != ErrorNumber.NoError)
return (int)errno;
diff --git a/Aaru/Commands/Image/Compare.cs b/Aaru/Commands/Image/Compare.cs
index 27d6fa756..25c149762 100644
--- a/Aaru/Commands/Image/Compare.cs
+++ b/Aaru/Commands/Image/Compare.cs
@@ -86,28 +86,30 @@ sealed class CompareCommand : Command
});
AaruConsole.DebugWriteLineEvent += (format, objects) =>
- {
- if(objects is null)
- stderrConsole.MarkupLine(format);
- else
- stderrConsole.MarkupLine(format, objects);
- };
+ {
+ if(objects is null)
+ stderrConsole.MarkupLine(format);
+ else
+ stderrConsole.MarkupLine(format, objects);
+ };
}
if(verbose)
+ {
AaruConsole.WriteEvent += (format, objects) =>
- {
- if(objects is null)
- AnsiConsole.Markup(format);
- else
- AnsiConsole.Markup(format, objects);
- };
+ {
+ if(objects is null)
+ AnsiConsole.Markup(format);
+ else
+ AnsiConsole.Markup(format, objects);
+ };
+ }
Statistics.AddCommand("compare");
- AaruConsole.DebugWriteLine(MODULE_NAME, "--debug={0}", debug);
- AaruConsole.DebugWriteLine(MODULE_NAME, "--input1={0}", imagePath1);
- AaruConsole.DebugWriteLine(MODULE_NAME, "--input2={0}", imagePath2);
+ AaruConsole.DebugWriteLine(MODULE_NAME, "--debug={0}", debug);
+ AaruConsole.DebugWriteLine(MODULE_NAME, "--input1={0}", imagePath1);
+ AaruConsole.DebugWriteLine(MODULE_NAME, "--input2={0}", imagePath2);
AaruConsole.DebugWriteLine(MODULE_NAME, "--verbose={0}", verbose);
var filtersList = new FiltersList();
@@ -115,18 +117,18 @@ sealed class CompareCommand : Command
IFilter inputFilter2 = null;
Core.Spectre.ProgressSingleSpinner(ctx =>
- {
- ctx.AddTask(UI.Identifying_first_file_filter).IsIndeterminate();
- inputFilter1 = filtersList.GetFilter(imagePath1);
- });
+ {
+ ctx.AddTask(UI.Identifying_first_file_filter).IsIndeterminate();
+ inputFilter1 = filtersList.GetFilter(imagePath1);
+ });
filtersList = new FiltersList();
Core.Spectre.ProgressSingleSpinner(ctx =>
- {
- ctx.AddTask(UI.Identifying_second_file_filter).IsIndeterminate();
- inputFilter2 = filtersList.GetFilter(imagePath2);
- });
+ {
+ ctx.AddTask(UI.Identifying_second_file_filter).IsIndeterminate();
+ inputFilter2 = filtersList.GetFilter(imagePath2);
+ });
if(inputFilter1 == null)
{
@@ -146,16 +148,16 @@ sealed class CompareCommand : Command
IBaseImage input2Format = null;
Core.Spectre.ProgressSingleSpinner(ctx =>
- {
- ctx.AddTask(UI.Identifying_first_image_format).IsIndeterminate();
- input1Format = ImageFormat.Detect(inputFilter1);
- });
+ {
+ ctx.AddTask(UI.Identifying_first_image_format).IsIndeterminate();
+ input1Format = ImageFormat.Detect(inputFilter1);
+ });
Core.Spectre.ProgressSingleSpinner(ctx =>
- {
- ctx.AddTask(UI.Identifying_second_image_format).IsIndeterminate();
- input2Format = ImageFormat.Detect(inputFilter2);
- });
+ {
+ ctx.AddTask(UI.Identifying_second_image_format).IsIndeterminate();
+ input2Format = ImageFormat.Detect(inputFilter2);
+ });
if(input1Format == null)
{
@@ -165,8 +167,10 @@ sealed class CompareCommand : Command
}
if(verbose)
+ {
AaruConsole.VerboseWriteLine(UI.First_input_file_format_identified_by_0_1, input1Format.Name,
input1Format.Id);
+ }
else
AaruConsole.WriteLine(UI.First_input_file_format_identified_by_0, input1Format.Name);
@@ -178,8 +182,10 @@ sealed class CompareCommand : Command
}
if(verbose)
+ {
AaruConsole.VerboseWriteLine(UI.Second_input_file_format_identified_by_0_1, input2Format.Name,
input2Format.Id);
+ }
else
AaruConsole.WriteLine(UI.Second_input_file_format_identified_by_0, input2Format.Name);
@@ -187,10 +193,10 @@ sealed class CompareCommand : Command
ErrorNumber opened2 = ErrorNumber.NoData;
Core.Spectre.ProgressSingleSpinner(ctx =>
- {
- ctx.AddTask(UI.Opening_first_image_file).IsIndeterminate();
- opened1 = input1Format.Open(inputFilter1);
- });
+ {
+ ctx.AddTask(UI.Opening_first_image_file).IsIndeterminate();
+ opened1 = input1Format.Open(inputFilter1);
+ });
if(opened1 != ErrorNumber.NoError)
{
@@ -201,10 +207,10 @@ sealed class CompareCommand : Command
}
Core.Spectre.ProgressSingleSpinner(ctx =>
- {
- ctx.AddTask(UI.Opening_second_image_file).IsIndeterminate();
- opened2 = input2Format.Open(inputFilter2);
- });
+ {
+ ctx.AddTask(UI.Opening_second_image_file).IsIndeterminate();
+ opened2 = input2Format.Open(inputFilter2);
+ });
if(opened2 != ErrorNumber.NoError)
{
@@ -230,8 +236,8 @@ sealed class CompareCommand : Command
if(verbose)
{
- table.AddRow(UI.Title_File, Markup.Escape(imagePath1), Markup.Escape(imagePath2));
- table.AddRow(UI.Title_Media_image_format, input1Format.Name, input2Format.Name);
+ table.AddRow(UI.Title_File, Markup.Escape(imagePath1), Markup.Escape(imagePath2));
+ table.AddRow(UI.Title_Media_image_format, input1Format.Name, input2Format.Name);
}
else
{
@@ -239,7 +245,7 @@ sealed class CompareCommand : Command
sb.AppendFormat($"[bold]{UI.Title_Second_Media_image}:[/] {imagePath2}").AppendLine();
}
- bool imagesDiffer = false;
+ var imagesDiffer = false;
ErrorNumber errno;
ImageInfo image1Info = input1Format.Info;
@@ -250,6 +256,7 @@ sealed class CompareCommand : Command
var input2MediaImage = input2Format as IMediaImage;
if(input1MediaImage != null)
+ {
foreach(MediaTagType diskTag in Enum.GetValues(typeof(MediaTagType)))
{
errno = input1MediaImage.ReadMediaTag(diskTag, out byte[] tempArray);
@@ -257,8 +264,10 @@ sealed class CompareCommand : Command
if(errno == ErrorNumber.NoError)
image1DiskTags.Add(diskTag, tempArray);
}
+ }
if(input2MediaImage != null)
+ {
foreach(MediaTagType diskTag in Enum.GetValues(typeof(MediaTagType)))
{
errno = input2MediaImage.ReadMediaTag(diskTag, out byte[] tempArray);
@@ -266,6 +275,7 @@ sealed class CompareCommand : Command
if(errno == ErrorNumber.NoError)
image2DiskTags.Add(diskTag, tempArray);
}
+ }
if(verbose)
{
@@ -335,76 +345,78 @@ sealed class CompareCommand : Command
foreach(MediaTagType diskTag in
(Enum.GetValues(typeof(MediaTagType)) as MediaTagType[]).OrderBy(e => e.ToString()))
+ {
table.AddRow(string.Format(UI.Has_tag_0_Question, diskTag),
image1DiskTags.ContainsKey(diskTag).ToString(),
image2DiskTags.ContainsKey(diskTag).ToString());
+ }
}
ulong leastSectors = 0;
Core.Spectre.ProgressSingleSpinner(ctx =>
- {
- ctx.AddTask(UI.Comparing_media_image_characteristics).IsIndeterminate();
+ {
+ ctx.AddTask(UI.Comparing_media_image_characteristics).IsIndeterminate();
- if(image1Info.HasPartitions != image2Info.HasPartitions)
- {
- imagesDiffer = true;
+ if(image1Info.HasPartitions != image2Info.HasPartitions)
+ {
+ imagesDiffer = true;
- if(!verbose)
- sb.AppendLine(UI.Image_partitioned_status_differ);
- }
+ if(!verbose)
+ sb.AppendLine(UI.Image_partitioned_status_differ);
+ }
- if(image1Info.HasSessions != image2Info.HasSessions)
- {
- imagesDiffer = true;
+ if(image1Info.HasSessions != image2Info.HasSessions)
+ {
+ imagesDiffer = true;
- if(!verbose)
- sb.AppendLine(UI.Image_session_status_differ);
- }
+ if(!verbose)
+ sb.AppendLine(UI.Image_session_status_differ);
+ }
- if(image1Info.Sectors != image2Info.Sectors)
- {
- imagesDiffer = true;
+ if(image1Info.Sectors != image2Info.Sectors)
+ {
+ imagesDiffer = true;
- if(!verbose)
- sb.AppendLine(UI.Image_sectors_differ);
- }
+ if(!verbose)
+ sb.AppendLine(UI.Image_sectors_differ);
+ }
- if(image1Info.SectorSize != image2Info.SectorSize)
- {
- imagesDiffer = true;
+ if(image1Info.SectorSize != image2Info.SectorSize)
+ {
+ imagesDiffer = true;
- if(!verbose)
- sb.AppendLine(UI.Image_sector_size_differ);
- }
+ if(!verbose)
+ sb.AppendLine(UI.Image_sector_size_differ);
+ }
- if(image1Info.MediaType != image2Info.MediaType)
- {
- imagesDiffer = true;
+ if(image1Info.MediaType != image2Info.MediaType)
+ {
+ imagesDiffer = true;
- if(!verbose)
- sb.AppendLine(UI.Media_type_differs);
- }
+ if(!verbose)
+ sb.AppendLine(UI.Media_type_differs);
+ }
- if(image1Info.Sectors < image2Info.Sectors)
- {
- imagesDiffer = true;
- leastSectors = image1Info.Sectors;
+ if(image1Info.Sectors < image2Info.Sectors)
+ {
+ imagesDiffer = true;
+ leastSectors = image1Info.Sectors;
- if(!verbose)
- sb.AppendLine(UI.Second_image_has_more_sectors);
- }
- else if(image1Info.Sectors > image2Info.Sectors)
- {
- imagesDiffer = true;
- leastSectors = image2Info.Sectors;
+ if(!verbose)
+ sb.AppendLine(UI.Second_image_has_more_sectors);
+ }
+ else if(image1Info.Sectors > image2Info.Sectors)
+ {
+ imagesDiffer = true;
+ leastSectors = image2Info.Sectors;
- if(!verbose)
- sb.AppendLine(UI.First_image_has_more_sectors);
- }
- else
- leastSectors = image1Info.Sectors;
- });
+ if(!verbose)
+ sb.AppendLine(UI.First_image_has_more_sectors);
+ }
+ else
+ leastSectors = image1Info.Sectors;
+ });
var input1ByteAddressable = input1Format as IByteAddressableImage;
var input2ByteAddressable = input2Format as IByteAddressableImage;
@@ -427,94 +439,105 @@ sealed class CompareCommand : Command
if(input1MediaImage is not null &&
input2MediaImage is not null)
+ {
AnsiConsole.Progress().AutoClear(true).HideCompleted(true).
Columns(new TaskDescriptionColumn(), new ProgressBarColumn(), new PercentageColumn()).
Start(ctx =>
- {
- ProgressTask task = ctx.AddTask(UI.Comparing_sectors);
- task.MaxValue = leastSectors;
+ {
+ ProgressTask task = ctx.AddTask(UI.Comparing_sectors);
+ task.MaxValue = leastSectors;
- for(ulong sector = 0; sector < leastSectors; sector++)
- {
- task.Value = sector;
- task.Description = string.Format(UI.Comparing_sector_0_of_1, sector + 1, leastSectors);
+ for(ulong sector = 0; sector < leastSectors; sector++)
+ {
+ task.Value = sector;
+ task.Description =
+ string.Format(UI.Comparing_sector_0_of_1, sector + 1, leastSectors);
- try
- {
- errno = input1MediaImage.ReadSector(sector, out byte[] image1Sector);
+ try
+ {
+ errno = input1MediaImage.ReadSector(sector, out byte[] image1Sector);
- if(errno != ErrorNumber.NoError)
- AaruConsole.
- ErrorWriteLine(string.Format(UI.Error_0_reading_sector_1_from_first_image,
- errno, sector));
+ if(errno != ErrorNumber.NoError)
+ {
+ AaruConsole.
+ ErrorWriteLine(string.
+ Format(UI.Error_0_reading_sector_1_from_first_image,
+ errno, sector));
+ }
- errno = input2MediaImage.ReadSector(sector, out byte[] image2Sector);
+ errno = input2MediaImage.ReadSector(sector, out byte[] image2Sector);
- if(errno != ErrorNumber.NoError)
- AaruConsole.
- ErrorWriteLine(string.Format(UI.Error_0_reading_sector_1_from_second_image,
- errno, sector));
+ if(errno != ErrorNumber.NoError)
+ {
+ AaruConsole.
+ ErrorWriteLine(string.
+ Format(UI.Error_0_reading_sector_1_from_second_image,
+ errno, sector));
+ }
- ArrayHelpers.CompareBytes(out bool different, out bool sameSize, image1Sector,
- image2Sector);
+ ArrayHelpers.CompareBytes(out bool different, out bool sameSize, image1Sector,
+ image2Sector);
- if(different)
- imagesDiffer = true;
+ if(different)
+ imagesDiffer = true;
- // sb.AppendFormat("Sector {0} is different", sector).AppendLine();
- else if(!sameSize)
- imagesDiffer = true;
- /* sb.
+ // sb.AppendFormat("Sector {0} is different", sector).AppendLine();
+ else if(!sameSize)
+ imagesDiffer = true;
+ /* sb.
AppendFormat("Sector {0} has different sizes ({1} bytes in image 1, {2} in image 2) but are otherwise identical",
sector, image1Sector.LongLength, image2Sector.LongLength).AppendLine();*/
- }
- #pragma warning disable RECS0022 // A catch clause that catches System.Exception and has an empty body
- catch
- {
- // ignored
- }
- #pragma warning restore RECS0022 // A catch clause that catches System.Exception and has an empty body
- }
- });
+ }
+ #pragma warning disable RECS0022 // A catch clause that catches System.Exception and has an empty body
+ catch
+ {
+ // ignored
+ }
+ #pragma warning restore RECS0022 // A catch clause that catches System.Exception and has an empty body
+ }
+ });
+ }
if(input1ByteAddressable is not null &&
input2ByteAddressable is not null)
+ {
AnsiConsole.Progress().AutoClear(true).HideCompleted(true).
Columns(new TaskDescriptionColumn(), new ProgressBarColumn(), new PercentageColumn()).
Start(ctx =>
- {
- ProgressTask task = ctx.AddTask(UI.Comparing_images);
- task.IsIndeterminate = true;
+ {
+ ProgressTask task = ctx.AddTask(UI.Comparing_images);
+ task.IsIndeterminate = true;
- byte[] data1 = new byte[input1ByteAddressable.Info.Sectors];
- byte[] data2 = new byte[input2ByteAddressable.Info.Sectors];
- byte[] tmp;
+ var data1 = new byte[input1ByteAddressable.Info.Sectors];
+ var data2 = new byte[input2ByteAddressable.Info.Sectors];
+ byte[] tmp;
- input1ByteAddressable.ReadBytes(data1, 0, data1.Length, out int bytesRead);
+ input1ByteAddressable.ReadBytes(data1, 0, data1.Length, out int bytesRead);
- if(bytesRead != data1.Length)
- {
- tmp = new byte[bytesRead];
- Array.Copy(data1, 0, tmp, 0, bytesRead);
- data1 = tmp;
- }
+ if(bytesRead != data1.Length)
+ {
+ tmp = new byte[bytesRead];
+ Array.Copy(data1, 0, tmp, 0, bytesRead);
+ data1 = tmp;
+ }
- input2ByteAddressable.ReadBytes(data2, 0, data2.Length, out bytesRead);
+ input2ByteAddressable.ReadBytes(data2, 0, data2.Length, out bytesRead);
- if(bytesRead != data2.Length)
- {
- tmp = new byte[bytesRead];
- Array.Copy(data2, 0, tmp, 0, bytesRead);
- data2 = tmp;
- }
+ if(bytesRead != data2.Length)
+ {
+ tmp = new byte[bytesRead];
+ Array.Copy(data2, 0, tmp, 0, bytesRead);
+ data2 = tmp;
+ }
- ArrayHelpers.CompareBytes(out bool different, out bool sameSize, data1, data2);
+ ArrayHelpers.CompareBytes(out bool different, out bool sameSize, data1, data2);
- if(different)
- imagesDiffer = true;
- else if(!sameSize)
- imagesDiffer = true;
- });
+ if(different)
+ imagesDiffer = true;
+ else if(!sameSize)
+ imagesDiffer = true;
+ });
+ }
AaruConsole.WriteLine();
diff --git a/Aaru/Commands/Image/Convert.cs b/Aaru/Commands/Image/Convert.cs
index cd2b51ddc..530b84992 100644
--- a/Aaru/Commands/Image/Convert.cs
+++ b/Aaru/Commands/Image/Convert.cs
@@ -69,17 +69,12 @@ sealed class ConvertImageCommand : Command
public ConvertImageCommand() : base("convert", UI.Image_Convert_Command_Description)
{
- Add(new Option(new[]
- {
- "--cicm-xml", "-x"
- }, () => null, UI.Take_metadata_from_existing_CICM_XML_sidecar));
+ Add(new Option(new[] { "--cicm-xml", "-x" }, () => null,
+ UI.Take_metadata_from_existing_CICM_XML_sidecar));
Add(new Option("--comments", () => null, UI.Image_comments));
- Add(new Option(new[]
- {
- "--count", "-c"
- }, () => 64, UI.How_many_sectors_to_convert_at_once));
+ Add(new Option(new[] { "--count", "-c" }, () => 64, UI.How_many_sectors_to_convert_at_once));
Add(new Option("--creator", () => null, UI.Who_person_created_the_image));
@@ -91,15 +86,10 @@ sealed class ConvertImageCommand : Command
Add(new Option("--drive-serial", () => null, UI.Serial_number_of_drive_read_the_media_by_image));
- Add(new Option(new[]
- {
- "--force", "-f"
- }, UI.Continue_conversion_even_if_data_lost));
+ Add(new Option(new[] { "--force", "-f" }, UI.Continue_conversion_even_if_data_lost));
- Add(new Option(new[]
- {
- "--format", "-p"
- }, () => null, UI.Format_of_the_output_image_as_plugin_name_or_plugin_id));
+ Add(new Option(new[] { "--format", "-p" }, () => null,
+ UI.Format_of_the_output_image_as_plugin_name_or_plugin_id));
Add(new Option("--media-barcode", () => null, UI.Barcode_of_the_media_by_image));
@@ -107,56 +97,32 @@ sealed class ConvertImageCommand : Command
Add(new Option("--media-manufacturer", () => null, UI.Manufacturer_of_media_by_image));
- Add(new Option("--media-model", () => null, UI.Model_of_media_by_image));
+ Add(new Option("--media-model", () => null, UI.Model_of_media_by_image));
Add(new Option("--media-partnumber", () => null, UI.Part_number_of_media_by_image));
Add(new Option("--media-sequence", () => 0, UI.Number_in_sequence_for_media_by_image));
Add(new Option("--media-serial", () => null, UI.Serial_number_of_media_by_image));
- Add(new Option("--media-title", () => null, UI.Title_of_media_represented_by_image));
+ Add(new Option("--media-title", () => null, UI.Title_of_media_represented_by_image));
- Add(new Option(new[]
- {
- "--options", "-O"
- }, () => null, UI.Comma_separated_name_value_pairs_of_image_options));
+ Add(new Option(new[] { "--options", "-O" }, () => null,
+ UI.Comma_separated_name_value_pairs_of_image_options));
- Add(new Option(new[]
- {
- "--resume-file", "-r"
- }, () => null, UI.Take_dump_hardware_from_existing_resume));
+ Add(new Option(new[] { "--resume-file", "-r" }, () => null,
+ UI.Take_dump_hardware_from_existing_resume));
- Add(new Option(new[]
- {
- "--geometry", "-g"
- }, () => null, UI.Force_geometry_help));
+ Add(new Option(new[] { "--geometry", "-g" }, () => null, UI.Force_geometry_help));
- Add(new Option(new[]
- {
- "--fix-subchannel-position"
- }, () => true, UI.Fix_subchannel_position_help));
+ Add(new Option(new[] { "--fix-subchannel-position" }, () => true, UI.Fix_subchannel_position_help));
- Add(new Option(new[]
- {
- "--fix-subchannel"
- }, () => false, UI.Fix_subchannel_help));
+ Add(new Option(new[] { "--fix-subchannel" }, () => false, UI.Fix_subchannel_help));
- Add(new Option(new[]
- {
- "--fix-subchannel-crc"
- }, () => false, UI.Fix_subchannel_crc_help));
+ Add(new Option(new[] { "--fix-subchannel-crc" }, () => false, UI.Fix_subchannel_crc_help));
- Add(new Option(new[]
- {
- "--generate-subchannels"
- }, () => false, UI.Generates_subchannels_help));
-
- Add(new Option(new[]
- {
- "--decrypt"
- }, () => false, UI.Decrypt_sectors_help));
+ Add(new Option(new[] { "--generate-subchannels" }, () => false, UI.Generates_subchannels_help));
- Add(new Option(new[]
- {
- "--aaru-metadata", "-m"
- }, () => null, "Take metadata from existing Aaru Metadata sidecar."));
+ Add(new Option(new[] { "--decrypt" }, () => false, UI.Decrypt_sectors_help));
+
+ Add(new Option(new[] { "--aaru-metadata", "-m" }, () => null,
+ "Take metadata from existing Aaru Metadata sidecar."));
AddArgument(new Argument
{
@@ -175,14 +141,14 @@ sealed class ConvertImageCommand : Command
Handler = CommandHandler.Create(GetType().GetMethod(nameof(Invoke)));
}
- 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 driveSerialNumber, bool force, string inputPath, int lastMediaSequence,
string mediaBarcode, string mediaManufacturer, string mediaModel, string mediaPartNumber,
- int mediaSequence, string mediaSerialNumber, string mediaTitle, string outputPath,
+ int mediaSequence, string mediaSerialNumber, string mediaTitle, string outputPath,
string options, string resumeFile, string format, string geometry,
- bool fixSubchannelPosition, bool fixSubchannel, bool fixSubchannelCrc,
- bool generateSubchannels, bool decrypt, string aaruMetadata)
+ bool fixSubchannelPosition, bool fixSubchannel, bool fixSubchannelCrc,
+ bool generateSubchannels, bool decrypt, string aaruMetadata)
{
MainClass.PrintCopyright();
@@ -194,22 +160,24 @@ sealed class ConvertImageCommand : Command
});
AaruConsole.DebugWriteLineEvent += (format, objects) =>
- {
- if(objects is null)
- stderrConsole.MarkupLine(format);
- else
- stderrConsole.MarkupLine(format, objects);
- };
+ {
+ if(objects is null)
+ stderrConsole.MarkupLine(format);
+ else
+ stderrConsole.MarkupLine(format, objects);
+ };
}
if(verbose)
+ {
AaruConsole.WriteEvent += (format, objects) =>
- {
- if(objects is null)
- AnsiConsole.Markup(format);
- else
- AnsiConsole.Markup(format, objects);
- };
+ {
+ if(objects is null)
+ AnsiConsole.Markup(format);
+ else
+ AnsiConsole.Markup(format, objects);
+ };
+ }
if(fixSubchannelCrc)
fixSubchannel = true;
@@ -219,37 +187,37 @@ sealed class ConvertImageCommand : Command
Statistics.AddCommand("convert-image");
- AaruConsole.DebugWriteLine(MODULE_NAME, "--cicm-xml={0}", cicmXml);
- AaruConsole.DebugWriteLine(MODULE_NAME, "--comments={0}", comments);
- AaruConsole.DebugWriteLine(MODULE_NAME, "--count={0}", count);
- AaruConsole.DebugWriteLine(MODULE_NAME, "--creator={0}", creator);
- AaruConsole.DebugWriteLine(MODULE_NAME, "--debug={0}", debug);
- AaruConsole.DebugWriteLine(MODULE_NAME, "--drive-manufacturer={0}", driveManufacturer);
- AaruConsole.DebugWriteLine(MODULE_NAME, "--drive-model={0}", driveModel);
- AaruConsole.DebugWriteLine(MODULE_NAME, "--drive-revision={0}", driveFirmwareRevision);
- AaruConsole.DebugWriteLine(MODULE_NAME, "--drive-serial={0}", driveSerialNumber);
- AaruConsole.DebugWriteLine(MODULE_NAME, "--force={0}", force);
- AaruConsole.DebugWriteLine(MODULE_NAME, "--format={0}", format);
- AaruConsole.DebugWriteLine(MODULE_NAME, "--geometry={0}", geometry);
- AaruConsole.DebugWriteLine(MODULE_NAME, "--input={0}", inputPath);
- AaruConsole.DebugWriteLine(MODULE_NAME, "--media-barcode={0}", mediaBarcode);
- AaruConsole.DebugWriteLine(MODULE_NAME, "--media-lastsequence={0}", lastMediaSequence);
- AaruConsole.DebugWriteLine(MODULE_NAME, "--media-manufacturer={0}", mediaManufacturer);
- AaruConsole.DebugWriteLine(MODULE_NAME, "--media-model={0}", mediaModel);
- AaruConsole.DebugWriteLine(MODULE_NAME, "--media-partnumber={0}", mediaPartNumber);
- AaruConsole.DebugWriteLine(MODULE_NAME, "--media-sequence={0}", mediaSequence);
- AaruConsole.DebugWriteLine(MODULE_NAME, "--media-serial={0}", mediaSerialNumber);
- AaruConsole.DebugWriteLine(MODULE_NAME, "--media-title={0}", mediaTitle);
- AaruConsole.DebugWriteLine(MODULE_NAME, "--options={0}", options);
- AaruConsole.DebugWriteLine(MODULE_NAME, "--output={0}", outputPath);
- AaruConsole.DebugWriteLine(MODULE_NAME, "--resume-file={0}", resumeFile);
- AaruConsole.DebugWriteLine(MODULE_NAME, "--verbose={0}", verbose);
+ AaruConsole.DebugWriteLine(MODULE_NAME, "--cicm-xml={0}", cicmXml);
+ AaruConsole.DebugWriteLine(MODULE_NAME, "--comments={0}", comments);
+ AaruConsole.DebugWriteLine(MODULE_NAME, "--count={0}", count);
+ AaruConsole.DebugWriteLine(MODULE_NAME, "--creator={0}", creator);
+ AaruConsole.DebugWriteLine(MODULE_NAME, "--debug={0}", debug);
+ AaruConsole.DebugWriteLine(MODULE_NAME, "--drive-manufacturer={0}", driveManufacturer);
+ AaruConsole.DebugWriteLine(MODULE_NAME, "--drive-model={0}", driveModel);
+ AaruConsole.DebugWriteLine(MODULE_NAME, "--drive-revision={0}", driveFirmwareRevision);
+ AaruConsole.DebugWriteLine(MODULE_NAME, "--drive-serial={0}", driveSerialNumber);
+ AaruConsole.DebugWriteLine(MODULE_NAME, "--force={0}", force);
+ AaruConsole.DebugWriteLine(MODULE_NAME, "--format={0}", format);
+ AaruConsole.DebugWriteLine(MODULE_NAME, "--geometry={0}", geometry);
+ AaruConsole.DebugWriteLine(MODULE_NAME, "--input={0}", inputPath);
+ AaruConsole.DebugWriteLine(MODULE_NAME, "--media-barcode={0}", mediaBarcode);
+ AaruConsole.DebugWriteLine(MODULE_NAME, "--media-lastsequence={0}", lastMediaSequence);
+ AaruConsole.DebugWriteLine(MODULE_NAME, "--media-manufacturer={0}", mediaManufacturer);
+ AaruConsole.DebugWriteLine(MODULE_NAME, "--media-model={0}", mediaModel);
+ AaruConsole.DebugWriteLine(MODULE_NAME, "--media-partnumber={0}", mediaPartNumber);
+ AaruConsole.DebugWriteLine(MODULE_NAME, "--media-sequence={0}", mediaSequence);
+ AaruConsole.DebugWriteLine(MODULE_NAME, "--media-serial={0}", mediaSerialNumber);
+ AaruConsole.DebugWriteLine(MODULE_NAME, "--media-title={0}", mediaTitle);
+ AaruConsole.DebugWriteLine(MODULE_NAME, "--options={0}", options);
+ AaruConsole.DebugWriteLine(MODULE_NAME, "--output={0}", outputPath);
+ AaruConsole.DebugWriteLine(MODULE_NAME, "--resume-file={0}", resumeFile);
+ AaruConsole.DebugWriteLine(MODULE_NAME, "--verbose={0}", verbose);
AaruConsole.DebugWriteLine(MODULE_NAME, "--fix-subchannel-position={0}", fixSubchannelPosition);
- AaruConsole.DebugWriteLine(MODULE_NAME, "--fix-subchannel={0}", fixSubchannel);
- AaruConsole.DebugWriteLine(MODULE_NAME, "--fix-subchannel-crc={0}", fixSubchannelCrc);
- AaruConsole.DebugWriteLine(MODULE_NAME, "--generate-subchannels={0}", generateSubchannels);
- AaruConsole.DebugWriteLine(MODULE_NAME, "--decrypt={0}", decrypt);
- AaruConsole.DebugWriteLine(MODULE_NAME, "--aaru-metadata={0}", aaruMetadata);
+ AaruConsole.DebugWriteLine(MODULE_NAME, "--fix-subchannel={0}", fixSubchannel);
+ AaruConsole.DebugWriteLine(MODULE_NAME, "--fix-subchannel-crc={0}", fixSubchannelCrc);
+ AaruConsole.DebugWriteLine(MODULE_NAME, "--generate-subchannels={0}", generateSubchannels);
+ AaruConsole.DebugWriteLine(MODULE_NAME, "--decrypt={0}", decrypt);
+ AaruConsole.DebugWriteLine(MODULE_NAME, "--aaru-metadata={0}", aaruMetadata);
Dictionary parsedOptions = Core.Options.Parse(options);
AaruConsole.DebugWriteLine(MODULE_NAME, UI.Parsed_options);
@@ -313,7 +281,9 @@ sealed class ConvertImageCommand : Command
if(aaruMetadata != null)
+ {
if(File.Exists(aaruMetadata))
+ {
try
{
var fs = new FileStream(aaruMetadata, FileMode.Open);
@@ -331,28 +301,32 @@ sealed class ConvertImageCommand : Command
return (int)ErrorNumber.InvalidSidecar;
}
+ }
else
{
AaruConsole.ErrorWriteLine(UI.Could_not_find_metadata_sidecar);
return (int)ErrorNumber.NoSuchFile;
}
+ }
else if(cicmXml != null)
+ {
if(File.Exists(cicmXml))
+ {
try
{
// Should be covered by virtue of being the same exact class as the JSON above
- #pragma warning disable IL2026
+ #pragma warning disable IL2026
var xs = new XmlSerializer(typeof(CICMMetadataType));
- #pragma warning restore IL2026
+ #pragma warning restore IL2026
var sr = new StreamReader(cicmXml);
// Should be covered by virtue of being the same exact class as the JSON above
- #pragma warning disable IL2026
+ #pragma warning disable IL2026
sidecar = (CICMMetadataType)xs.Deserialize(sr);
- #pragma warning restore IL2026
+ #pragma warning restore IL2026
sr.Close();
}
@@ -363,12 +337,14 @@ sealed class ConvertImageCommand : Command
return (int)ErrorNumber.InvalidSidecar;
}
+ }
else
{
AaruConsole.ErrorWriteLine(UI.Could_not_find_metadata_sidecar);
return (int)ErrorNumber.NoSuchFile;
}
+ }
if(resumeFile != null)
{
@@ -389,16 +365,16 @@ sealed class ConvertImageCommand : Command
else
{
// Bypassed by JSON source generator used above
- #pragma warning disable IL2026
+ #pragma warning disable IL2026
var xs = new XmlSerializer(typeof(Resume));
- #pragma warning restore IL2026
+ #pragma warning restore IL2026
var sr = new StreamReader(resumeFile);
// Bypassed by JSON source generator used above
- #pragma warning disable IL2026
+ #pragma warning disable IL2026
resume = (Resume)xs.Deserialize(sr);
- #pragma warning restore IL2026
+ #pragma warning restore IL2026
sr.Close();
}
@@ -423,10 +399,10 @@ sealed class ConvertImageCommand : Command
IFilter inputFilter = null;
Core.Spectre.ProgressSingleSpinner(ctx =>
- {
- ctx.AddTask(UI.Identifying_file_filter).IsIndeterminate();
- inputFilter = filtersList.GetFilter(inputPath);
- });
+ {
+ ctx.AddTask(UI.Identifying_file_filter).IsIndeterminate();
+ inputFilter = filtersList.GetFilter(inputPath);
+ });
if(inputFilter == null)
{
@@ -447,11 +423,11 @@ sealed class ConvertImageCommand : Command
IBaseImage baseImage = null;
Core.Spectre.ProgressSingleSpinner(ctx =>
- {
- ctx.AddTask(UI.Identifying_image_format).IsIndeterminate();
- baseImage = ImageFormat.Detect(inputFilter);
- inputFormat = baseImage as IMediaImage;
- });
+ {
+ ctx.AddTask(UI.Identifying_image_format).IsIndeterminate();
+ baseImage = ImageFormat.Detect(inputFilter);
+ inputFormat = baseImage as IMediaImage;
+ });
if(inputFormat == null)
{
@@ -478,10 +454,10 @@ sealed class ConvertImageCommand : Command
ErrorNumber opened = ErrorNumber.NoData;
Core.Spectre.ProgressSingleSpinner(ctx =>
- {
- ctx.AddTask(UI.Invoke_Opening_image_file).IsIndeterminate();
- opened = inputFormat.Open(inputFilter);
- });
+ {
+ ctx.AddTask(UI.Invoke_Opening_image_file).IsIndeterminate();
+ opened = inputFormat.Open(inputFilter);
+ });
if(opened != ErrorNumber.NoError)
{
@@ -494,15 +470,15 @@ sealed class ConvertImageCommand : Command
mediaType = inputFormat.Info.MediaType;
// Obsolete types
- #pragma warning disable 612
+ #pragma warning disable 612
mediaType = mediaType switch
- {
- MediaType.SQ1500 => MediaType.SyJet,
- MediaType.Bernoulli => MediaType.Bernoulli10,
- MediaType.Bernoulli2 => MediaType.BernoulliBox2_20,
- _ => inputFormat.Info.MediaType
- };
- #pragma warning restore 612
+ {
+ MediaType.SQ1500 => MediaType.SyJet,
+ MediaType.Bernoulli => MediaType.Bernoulli10,
+ MediaType.Bernoulli2 => MediaType.BernoulliBox2_20,
+ _ => inputFormat.Info.MediaType
+ };
+ #pragma warning restore 612
AaruConsole.DebugWriteLine(MODULE_NAME, UI.Correctly_opened_image_file);
@@ -530,24 +506,36 @@ sealed class ConvertImageCommand : Command
// Try extension
if(string.IsNullOrEmpty(format))
+ {
candidates.AddRange(from pluginType in plugins.WritableImages.Values
- select Activator.CreateInstance(pluginType) as IBaseWritableImage into plugin
+ select Activator.CreateInstance(pluginType) as IBaseWritableImage
+ into plugin
where plugin is not null
- where plugin.KnownExtensions.Contains(Path.GetExtension(outputPath)) select plugin);
+ where plugin.KnownExtensions.Contains(Path.GetExtension(outputPath))
+ select plugin);
+ }
// Try Id
else if(Guid.TryParse(format, out Guid outId))
+ {
candidates.AddRange(from pluginType in plugins.WritableImages.Values
- select Activator.CreateInstance(pluginType) as IBaseWritableImage into plugin
- where plugin is not null where plugin.Id.Equals(outId) select plugin);
+ select Activator.CreateInstance(pluginType) as IBaseWritableImage
+ into plugin
+ where plugin is not null
+ where plugin.Id.Equals(outId)
+ select plugin);
+ }
// Try name
else
+ {
candidates.AddRange(from pluginType in plugins.WritableImages.Values
- select Activator.CreateInstance(pluginType) as IBaseWritableImage into plugin
+ select Activator.CreateInstance(pluginType) as IBaseWritableImage
+ into plugin
where plugin is not null
where plugin.Name.Equals(format, StringComparison.InvariantCultureIgnoreCase)
select plugin);
+ }
switch(candidates.Count)
{
@@ -618,7 +606,7 @@ sealed class ConvertImageCommand : Command
return (int)ErrorNumber.UnsupportedMedia;
}
- bool ret = false;
+ var ret = false;
if(inputTape?.IsTape == true &&
outputTape != null)
@@ -665,15 +653,16 @@ sealed class ConvertImageCommand : Command
AaruConsole.ErrorWriteLine("Output format does not support sessions, this will end in a loss of data, continuing...");*/
}
- bool created = false;
+ var created = false;
Core.Spectre.ProgressSingleSpinner(ctx =>
- {
- ctx.AddTask(UI.Invoke_Opening_image_file).IsIndeterminate();
+ {
+ ctx.AddTask(UI.Invoke_Opening_image_file).IsIndeterminate();
- created = outputFormat.Create(outputPath, mediaType, parsedOptions, inputFormat.Info.Sectors,
- inputFormat.Info.SectorSize);
- });
+ created = outputFormat.Create(outputPath, mediaType, parsedOptions,
+ inputFormat.Info.Sectors,
+ inputFormat.Info.SectorSize);
+ });
if(!created)
{
@@ -725,7 +714,8 @@ sealed class ConvertImageCommand : Command
AnsiConsole.Progress().AutoClear(false).HideCompleted(false).
Columns(new TaskDescriptionColumn(), new SpinnerColumn()).Start(ctx =>
{
- ctx.AddTask(string.Format(UI.Converting_media_tag_0, Markup.Escape(mediaTag.ToString())));
+ ctx.AddTask(string.Format(UI.Converting_media_tag_0,
+ Markup.Escape(mediaTag.ToString())));
ErrorNumber errno = inputFormat.ReadMediaTag(mediaTag, out byte[] tag);
if(errno != ErrorNumber.NoError)
@@ -734,7 +724,8 @@ sealed class ConvertImageCommand : Command
AaruConsole.ErrorWriteLine(UI.Error_0_reading_media_tag, errno);
else
{
- AaruConsole.ErrorWriteLine(UI.Error_0_reading_media_tag_not_continuing, errno);
+ AaruConsole.ErrorWriteLine(UI.Error_0_reading_media_tag_not_continuing,
+ errno);
errorNumber = errno;
}
@@ -746,7 +737,8 @@ sealed class ConvertImageCommand : Command
return;
if(force)
- AaruConsole.ErrorWriteLine(UI.Error_0_writing_media_tag, outputFormat.ErrorMessage);
+ AaruConsole.ErrorWriteLine(UI.Error_0_writing_media_tag,
+ outputFormat.ErrorMessage);
else
{
AaruConsole.ErrorWriteLine(UI.Error_0_writing_media_tag_not_continuing,
@@ -775,253 +767,298 @@ sealed class ConvertImageCommand : Command
}
ErrorNumber errno = ErrorNumber.NoError;
-
+
if(decrypt)
AaruConsole.WriteLine("Decrypting encrypted sectors.");
AnsiConsole.Progress().AutoClear(true).HideCompleted(true).
Columns(new TaskDescriptionColumn(), new ProgressBarColumn(), new PercentageColumn()).
Start(ctx =>
- {
- ProgressTask discTask = ctx.AddTask(UI.Converting_disc);
- discTask.MaxValue = inputOptical.Tracks.Count;
- byte[] generatedTitleKeys = null;
+ {
+ ProgressTask discTask = ctx.AddTask(UI.Converting_disc);
+ discTask.MaxValue = inputOptical.Tracks.Count;
+ byte[] generatedTitleKeys = null;
- foreach(Track track in inputOptical.Tracks)
- {
- discTask.Description = string.Format(UI.Converting_sectors_in_track_0_of_1,
- discTask.Value + 1, discTask.MaxValue);
+ foreach(Track track in inputOptical.Tracks)
+ {
+ discTask.Description = string.Format(UI.Converting_sectors_in_track_0_of_1,
+ discTask.Value + 1, discTask.MaxValue);
- doneSectors = 0;
- ulong trackSectors = track.EndSector - track.StartSector + 1;
+ doneSectors = 0;
+ ulong trackSectors = track.EndSector - track.StartSector + 1;
- ProgressTask trackTask = ctx.AddTask(UI.Converting_track);
- trackTask.MaxValue = trackSectors;
+ ProgressTask trackTask = ctx.AddTask(UI.Converting_track);
+ trackTask.MaxValue = trackSectors;
- while(doneSectors < trackSectors)
- {
- byte[] sector;
+ while(doneSectors < trackSectors)
+ {
+ byte[] sector;
- uint sectorsToDo;
+ uint sectorsToDo;
- if(trackSectors - doneSectors >= (ulong)count)
- sectorsToDo = (uint)count;
- else
- sectorsToDo = (uint)(trackSectors - doneSectors);
+ if(trackSectors - doneSectors >= (ulong)count)
+ sectorsToDo = (uint)count;
+ else
+ sectorsToDo = (uint)(trackSectors - doneSectors);
- trackTask.Description =
- string.Format(UI.Converting_sectors_0_to_1_in_track_2,
- doneSectors + track.StartSector,
- doneSectors + sectorsToDo + track.StartSector, track.Sequence);
+ trackTask.Description =
+ string.Format(UI.Converting_sectors_0_to_1_in_track_2,
+ doneSectors + track.StartSector,
+ doneSectors + sectorsToDo + track.StartSector,
+ track.Sequence);
- bool useNotLong = false;
- bool result = false;
+ var useNotLong = false;
+ var result = false;
- if(useLong)
- {
- errno = sectorsToDo == 1
- ? inputOptical.ReadSectorLong(doneSectors + track.StartSector,
- out sector)
- : inputOptical.ReadSectorsLong(doneSectors + track.StartSector,
- sectorsToDo, out sector);
+ if(useLong)
+ {
+ errno = sectorsToDo == 1
+ ? inputOptical.ReadSectorLong(doneSectors + track.StartSector,
+ out sector)
+ : inputOptical.
+ ReadSectorsLong(doneSectors + track.StartSector,
+ sectorsToDo, out sector);
- if(errno == ErrorNumber.NoError)
- result = sectorsToDo == 1
- ? outputOptical.WriteSectorLong(sector,
- doneSectors + track.StartSector)
- : outputOptical.WriteSectorsLong(sector,
- doneSectors + track.StartSector, sectorsToDo);
- else
- {
- result = true;
+ if(errno == ErrorNumber.NoError)
+ {
+ result = sectorsToDo == 1
+ ? outputOptical.WriteSectorLong(sector,
+ doneSectors + track.StartSector)
+ : outputOptical.WriteSectorsLong(sector,
+ doneSectors + track.StartSector, sectorsToDo);
+ }
+ else
+ {
+ result = true;
- if(force)
- AaruConsole.ErrorWriteLine(UI.Error_0_reading_sector_1_continuing,
- errno, doneSectors + track.StartSector);
- else
- {
- AaruConsole.ErrorWriteLine(UI.Error_0_reading_sector_1_not_continuing,
- errno, doneSectors + track.StartSector);
+ if(force)
+ {
+ AaruConsole.ErrorWriteLine(UI.Error_0_reading_sector_1_continuing,
+ errno, doneSectors + track.StartSector);
+ }
+ else
+ {
+ AaruConsole.
+ ErrorWriteLine(UI.Error_0_reading_sector_1_not_continuing,
+ errno, doneSectors + track.StartSector);
- errno = ErrorNumber.WriteError;
+ errno = ErrorNumber.WriteError;
- return;
- }
- }
+ return;
+ }
+ }
- if(!result &&
- sector.Length % 2352 != 0)
- {
- if(!force)
- {
- AaruConsole.
- ErrorWriteLine(UI.
- Input_image_is_not_returning_raw_sectors_use_force_if_you_want_to_continue);
+ if(!result &&
+ sector.Length % 2352 != 0)
+ {
+ if(!force)
+ {
+ AaruConsole.
+ ErrorWriteLine(UI.
+ Input_image_is_not_returning_raw_sectors_use_force_if_you_want_to_continue);
- errno = ErrorNumber.InOutError;
+ errno = ErrorNumber.InOutError;
- return;
- }
+ return;
+ }
- useNotLong = true;
- }
- }
+ useNotLong = true;
+ }
+ }
- if(!useLong || useNotLong)
- {
- errno = sectorsToDo == 1
- ? inputOptical.ReadSector(doneSectors + track.StartSector,
- out sector)
- : inputOptical.ReadSectors(doneSectors + track.StartSector,
- sectorsToDo, out sector);
+ if(!useLong || useNotLong)
+ {
+ errno = sectorsToDo == 1
+ ? inputOptical.ReadSector(doneSectors + track.StartSector,
+ out sector)
+ : inputOptical.ReadSectors(doneSectors + track.StartSector,
+ sectorsToDo, out sector);
- // TODO: Move to generic place when anything but CSS DVDs can be decrypted
- if(inputOptical.Info.MediaType is MediaType.DVDROM or MediaType.DVDR
- or MediaType.DVDRDL or MediaType.DVDPR or MediaType.DVDPRDL && decrypt)
- {
- // Only sectors which are MPEG packets can be encrypted.
- if(MPEG.ContainsMpegPackets(sector, sectorsToDo))
- {
- byte[] cmi, titleKey;
+ // TODO: Move to generic place when anything but CSS DVDs can be decrypted
+ if(inputOptical.Info.MediaType is MediaType.DVDROM or MediaType.DVDR
+ or MediaType.DVDRDL or MediaType.DVDPR or MediaType.DVDPRDL &&
+ decrypt)
+ {
+ // Only sectors which are MPEG packets can be encrypted.
+ if(MPEG.ContainsMpegPackets(sector, sectorsToDo))
+ {
+ byte[] cmi, titleKey;
- if(sectorsToDo == 1)
- {
- if(inputOptical.ReadSectorTag(doneSectors + track.StartSector,
- SectorTagType.DvdSectorCmi, out cmi) == ErrorNumber.NoError &&
- inputOptical.ReadSectorTag(doneSectors + track.StartSector,
- SectorTagType.DvdTitleKeyDecrypted, out titleKey) ==
- ErrorNumber.NoError)
- sector = CSS.DecryptSector(sector, titleKey, cmi);
- else
- {
- if(generatedTitleKeys == null)
- {
- List partitions =
- Core.Partitions.GetAll(inputOptical);
+ if(sectorsToDo == 1)
+ {
+ if(inputOptical.ReadSectorTag(doneSectors + track.StartSector,
+ SectorTagType.DvdSectorCmi, out cmi) ==
+ ErrorNumber.NoError &&
+ inputOptical.ReadSectorTag(doneSectors + track.StartSector,
+ SectorTagType.DvdTitleKeyDecrypted,
+ out titleKey) ==
+ ErrorNumber.NoError)
+ sector = CSS.DecryptSector(sector, titleKey, cmi);
+ else
+ {
+ if(generatedTitleKeys == null)
+ {
+ List partitions =
+ Core.Partitions.GetAll(inputOptical);
- partitions = partitions.FindAll(p =>
- {
- Core.Filesystems.Identify(inputOptical,
- out List idPlugins, p);
+ partitions = partitions.FindAll(p =>
+ {
+ Core.Filesystems.
+ Identify(inputOptical,
+ out List
+ idPlugins, p);
- return idPlugins.Contains("iso9660 filesystem");
- });
+ return idPlugins.
+ Contains("iso9660 filesystem");
+ });
- if(plugins.ReadOnlyFilesystems.
- TryGetValue("iso9660 filesystem",
- out Type pluginType))
- {
- AaruConsole.DebugWriteLine(MODULE_NAME,
- UI.Generating_decryption_keys);
+ if(plugins.ReadOnlyFilesystems.
+ TryGetValue("iso9660 filesystem",
+ out Type pluginType))
+ {
+ AaruConsole.DebugWriteLine(MODULE_NAME,
+ UI.Generating_decryption_keys);
- generatedTitleKeys = CSS.GenerateTitleKeys(inputOptical,
- partitions, trackSectors, pluginType);
- }
- }
+ generatedTitleKeys =
+ CSS.GenerateTitleKeys(inputOptical,
+ partitions, trackSectors,
+ pluginType);
+ }
+ }
- if(generatedTitleKeys != null)
- sector = CSS.DecryptSector(sector,
- generatedTitleKeys.
- Skip((int)(5 * (doneSectors + track.StartSector))).
- Take(5).ToArray(), null);
- }
- }
- else
- {
- if(inputOptical.ReadSectorsTag(doneSectors + track.StartSector,
- sectorsToDo, SectorTagType.DvdSectorCmi, out cmi) ==
- ErrorNumber.NoError &&
- inputOptical.ReadSectorsTag(doneSectors + track.StartSector,
- sectorsToDo, SectorTagType.DvdTitleKeyDecrypted,
- out titleKey) == ErrorNumber.NoError)
- sector = CSS.DecryptSector(sector, titleKey, cmi, sectorsToDo);
- else
- {
- if(generatedTitleKeys == null)
- {
- List partitions =
- Core.Partitions.GetAll(inputOptical);
+ if(generatedTitleKeys != null)
+ {
+ sector = CSS.DecryptSector(sector,
+ generatedTitleKeys.
+ Skip((int)(5 * (doneSectors +
+ track.
+ StartSector))).
+ Take(5).ToArray(), null);
+ }
+ }
+ }
+ else
+ {
+ if(inputOptical.
+ ReadSectorsTag(doneSectors + track.StartSector,
+ sectorsToDo,
+ SectorTagType.DvdSectorCmi,
+ out cmi) ==
+ ErrorNumber.NoError &&
+ inputOptical.
+ ReadSectorsTag(doneSectors + track.StartSector,
+ sectorsToDo,
+ SectorTagType.DvdTitleKeyDecrypted,
+ out titleKey) ==
+ ErrorNumber.NoError)
+ sector = CSS.DecryptSector(sector, titleKey, cmi,
+ sectorsToDo);
+ else
+ {
+ if(generatedTitleKeys == null)
+ {
+ List partitions =
+ Core.Partitions.GetAll(inputOptical);
- partitions = partitions.FindAll(p =>
- {
- Core.Filesystems.Identify(inputOptical,
- out List idPlugins, p);
+ partitions = partitions.FindAll(p =>
+ {
+ Core.Filesystems.
+ Identify(inputOptical,
+ out List
+ idPlugins, p);
- return idPlugins.Contains("iso9660 filesystem");
- });
+ return idPlugins.
+ Contains("iso9660 filesystem");
+ });
- if(plugins.ReadOnlyFilesystems.
- TryGetValue("iso9660 filesystem",
- out Type pluginType))
- {
- AaruConsole.DebugWriteLine(MODULE_NAME,
- UI.Generating_decryption_keys);
+ if(plugins.ReadOnlyFilesystems.
+ TryGetValue("iso9660 filesystem",
+ out Type pluginType))
+ {
+ AaruConsole.DebugWriteLine(MODULE_NAME,
+ UI.Generating_decryption_keys);
- generatedTitleKeys = CSS.GenerateTitleKeys(inputOptical,
- partitions, trackSectors, pluginType);
- }
- }
+ generatedTitleKeys =
+ CSS.GenerateTitleKeys(inputOptical,
+ partitions, trackSectors,
+ pluginType);
+ }
+ }
- if(generatedTitleKeys != null)
- sector = CSS.DecryptSector(sector,
- generatedTitleKeys.
- Skip((int)(5 * (doneSectors + track.StartSector))).
- Take((int)(5 * sectorsToDo)).ToArray(), null,
- sectorsToDo);
- }
- }
- }
- }
+ if(generatedTitleKeys != null)
+ {
+ sector = CSS.DecryptSector(sector,
+ generatedTitleKeys.
+ Skip((int)(5 * (doneSectors +
+ track.
+ StartSector))).
+ Take((int)(5 * sectorsToDo)).ToArray(),
+ null,
+ sectorsToDo);
+ }
+ }
+ }
+ }
+ }
- if(errno == ErrorNumber.NoError)
- result = sectorsToDo == 1
- ? outputOptical.WriteSector(sector,
- doneSectors + track.StartSector)
- : outputOptical.WriteSectors(sector,
- doneSectors + track.StartSector, sectorsToDo);
- else
- {
- result = true;
+ if(errno == ErrorNumber.NoError)
+ {
+ result = sectorsToDo == 1
+ ? outputOptical.WriteSector(sector,
+ doneSectors + track.StartSector)
+ : outputOptical.WriteSectors(sector,
+ doneSectors + track.StartSector, sectorsToDo);
+ }
+ else
+ {
+ result = true;
- if(force)
- AaruConsole.ErrorWriteLine(UI.Error_0_reading_sector_1_continuing,
- errno, doneSectors + track.StartSector);
- else
- {
- AaruConsole.ErrorWriteLine(UI.Error_0_reading_sector_1_not_continuing,
- errno, doneSectors + track.StartSector);
+ if(force)
+ {
+ AaruConsole.ErrorWriteLine(UI.Error_0_reading_sector_1_continuing,
+ errno, doneSectors + track.StartSector);
+ }
+ else
+ {
+ AaruConsole.
+ ErrorWriteLine(UI.Error_0_reading_sector_1_not_continuing,
+ errno, doneSectors + track.StartSector);
- errno = ErrorNumber.WriteError;
+ errno = ErrorNumber.WriteError;
- return;
- }
- }
- }
+ return;
+ }
+ }
+ }
- if(!result)
- if(force)
- AaruConsole.ErrorWriteLine(UI.Error_0_writing_sector_1_continuing,
- outputOptical.ErrorMessage,
- doneSectors + track.StartSector);
- else
- {
- AaruConsole.ErrorWriteLine(UI.Error_0_writing_sector_1_not_continuing,
- outputOptical.ErrorMessage,
- doneSectors + track.StartSector);
+ if(!result)
+ {
+ if(force)
+ {
+ AaruConsole.ErrorWriteLine(UI.Error_0_writing_sector_1_continuing,
+ outputOptical.ErrorMessage,
+ doneSectors + track.StartSector);
+ }
+ else
+ {
+ AaruConsole.ErrorWriteLine(UI.Error_0_writing_sector_1_not_continuing,
+ outputOptical.ErrorMessage,
+ doneSectors + track.StartSector);
- errno = ErrorNumber.WriteError;
+ errno = ErrorNumber.WriteError;
- return;
- }
+ return;
+ }
+ }
- doneSectors += sectorsToDo;
- trackTask.Value += sectorsToDo;
- }
+ doneSectors += sectorsToDo;
+ trackTask.Value += sectorsToDo;
+ }
- trackTask.StopTask();
- discTask.Increment(1);
- }
- });
+ trackTask.StopTask();
+ discTask.Increment(1);
+ }
+ });
if(errno != ErrorNumber.NoError)
return (int)errno;
@@ -1031,9 +1068,9 @@ sealed class ConvertImageCommand : Command
string mcn = null;
HashSet subchannelExtents = new();
Dictionary smallestPregapLbaPerTrack = new();
- Track[] tracks = new Track[inputOptical.Tracks.Count];
+ var tracks = new Track[inputOptical.Tracks.Count];
- for(int i = 0; i < tracks.Length; i++)
+ for(var i = 0; i < tracks.Length; i++)
{
tracks[i] = new Track
{
@@ -1120,210 +1157,236 @@ sealed class ConvertImageCommand : Command
AnsiConsole.Progress().AutoClear(true).HideCompleted(true).
Columns(new TaskDescriptionColumn(), new ProgressBarColumn(), new PercentageColumn()).
Start(ctx =>
- {
- ProgressTask discTask = ctx.AddTask(UI.Converting_disc);
- discTask.MaxValue = inputOptical.Tracks.Count;
+ {
+ ProgressTask discTask = ctx.AddTask(UI.Converting_disc);
+ discTask.MaxValue = inputOptical.Tracks.Count;
- foreach(Track track in inputOptical.Tracks)
- {
- discTask.Description =
- string.Format(UI.Converting_tags_in_track_0_of_1, discTask.Value + 1,
- discTask.MaxValue);
+ foreach(Track track in inputOptical.Tracks)
+ {
+ discTask.Description =
+ string.Format(UI.Converting_tags_in_track_0_of_1, discTask.Value + 1,
+ discTask.MaxValue);
- doneSectors = 0;
- ulong trackSectors = track.EndSector - track.StartSector + 1;
- byte[] sector;
- bool result;
+ doneSectors = 0;
+ ulong trackSectors = track.EndSector - track.StartSector + 1;
+ byte[] sector;
+ bool result;
- switch(tag)
- {
- case SectorTagType.CdTrackFlags:
- case SectorTagType.CdTrackIsrc:
- errno = inputOptical.ReadSectorTag(track.Sequence, tag, out sector);
+ switch(tag)
+ {
+ case SectorTagType.CdTrackFlags:
+ case SectorTagType.CdTrackIsrc:
+ errno = inputOptical.ReadSectorTag(track.Sequence, tag, out sector);
- switch(errno)
- {
- case ErrorNumber.NoData:
- errno = ErrorNumber.NoError;
+ switch(errno)
+ {
+ case ErrorNumber.NoData:
+ errno = ErrorNumber.NoError;
- continue;
- case ErrorNumber.NoError:
- result = outputOptical.WriteSectorTag(sector, track.Sequence, tag);
+ continue;
+ case ErrorNumber.NoError:
+ result = outputOptical.WriteSectorTag(sector, track.Sequence,
+ tag);
- break;
- default:
- {
- if(force)
- {
- AaruConsole.ErrorWriteLine(UI.Error_0_writing_tag_continuing,
- outputOptical.ErrorMessage);
+ break;
+ default:
+ {
+ if(force)
+ {
+ AaruConsole.
+ ErrorWriteLine(UI.Error_0_writing_tag_continuing,
+ outputOptical.ErrorMessage);
- continue;
- }
+ continue;
+ }
- AaruConsole.ErrorWriteLine(UI.Error_0_writing_tag_not_continuing,
- outputOptical.ErrorMessage);
+ AaruConsole.
+ ErrorWriteLine(UI.Error_0_writing_tag_not_continuing,
+ outputOptical.ErrorMessage);
- errno = ErrorNumber.WriteError;
+ errno = ErrorNumber.WriteError;
- return;
- }
- }
+ return;
+ }
+ }
- if(!result)
- if(force)
- AaruConsole.ErrorWriteLine(UI.Error_0_writing_tag_continuing,
- outputOptical.ErrorMessage);
- else
- {
- AaruConsole.ErrorWriteLine(UI.Error_0_writing_tag_not_continuing,
- outputOptical.ErrorMessage);
+ if(!result)
+ {
+ if(force)
+ {
+ AaruConsole.ErrorWriteLine(UI.Error_0_writing_tag_continuing,
+ outputOptical.ErrorMessage);
+ }
+ else
+ {
+ AaruConsole.
+ ErrorWriteLine(UI.Error_0_writing_tag_not_continuing,
+ outputOptical.ErrorMessage);
- errno = ErrorNumber.WriteError;
+ errno = ErrorNumber.WriteError;
- return;
- }
+ return;
+ }
+ }
- continue;
- }
+ continue;
+ }
- ProgressTask trackTask = ctx.AddTask(UI.Converting_track);
- trackTask.MaxValue = trackSectors;
+ ProgressTask trackTask = ctx.AddTask(UI.Converting_track);
+ trackTask.MaxValue = trackSectors;
- while(doneSectors < trackSectors)
- {
- uint sectorsToDo;
+ while(doneSectors < trackSectors)
+ {
+ uint sectorsToDo;
- if(trackSectors - doneSectors >= (ulong)count)
- sectorsToDo = (uint)count;
- else
- sectorsToDo = (uint)(trackSectors - doneSectors);
+ if(trackSectors - doneSectors >= (ulong)count)
+ sectorsToDo = (uint)count;
+ else
+ sectorsToDo = (uint)(trackSectors - doneSectors);
- trackTask.Description =
- string.Format(UI.Converting_tag_3_for_sectors_0_to_1_in_track_2,
- doneSectors + track.StartSector,
- doneSectors + sectorsToDo + track.StartSector, track.Sequence,
- tag);
+ trackTask.Description =
+ string.Format(UI.Converting_tag_3_for_sectors_0_to_1_in_track_2,
+ doneSectors + track.StartSector,
+ doneSectors + sectorsToDo + track.StartSector,
+ track.Sequence,
+ tag);
- if(sectorsToDo == 1)
- {
- errno = inputOptical.ReadSectorTag(doneSectors + track.StartSector, tag,
- out sector);
+ if(sectorsToDo == 1)
+ {
+ errno = inputOptical.ReadSectorTag(doneSectors + track.StartSector,
+ tag,
+ out sector);
- if(errno == ErrorNumber.NoError)
- {
- if(tag == SectorTagType.CdSectorSubchannel)
- {
- bool indexesChanged =
- CompactDisc.WriteSubchannelToImage(MmcSubchannel.Raw,
- MmcSubchannel.Raw, sector,
- doneSectors + track.StartSector, 1, null, isrcs,
- (byte)track.Sequence, ref mcn, tracks,
- subchannelExtents, fixSubchannelPosition,
- outputOptical, fixSubchannel, fixSubchannelCrc, null,
- null, smallestPregapLbaPerTrack, false, out _);
+ if(errno == ErrorNumber.NoError)
+ {
+ if(tag == SectorTagType.CdSectorSubchannel)
+ {
+ bool indexesChanged =
+ CompactDisc.WriteSubchannelToImage(MmcSubchannel.Raw,
+ MmcSubchannel.Raw, sector,
+ doneSectors + track.StartSector, 1, null, isrcs,
+ (byte)track.Sequence, ref mcn, tracks,
+ subchannelExtents, fixSubchannelPosition,
+ outputOptical, fixSubchannel, fixSubchannelCrc,
+ null,
+ null, smallestPregapLbaPerTrack, false, out _);
- if(indexesChanged)
- outputOptical.SetTracks(tracks.ToList());
+ if(indexesChanged)
+ outputOptical.SetTracks(tracks.ToList());
- result = true;
- }
- else
- result =
- outputOptical.WriteSectorTag(sector,
- doneSectors + track.StartSector, tag);
- }
- else
- {
- result = true;
+ result = true;
+ }
+ else
+ {
+ result =
+ outputOptical.WriteSectorTag(sector,
+ doneSectors + track.StartSector, tag);
+ }
+ }
+ else
+ {
+ result = true;
- if(force)
- AaruConsole.
- ErrorWriteLine(UI.Error_0_reading_tag_for_sector_1_continuing,
- errno, doneSectors + track.StartSector);
- else
- {
- AaruConsole.
- ErrorWriteLine(UI.Error_0_reading_tag_for_sector_1_not_continuing,
- errno, doneSectors + track.StartSector);
+ if(force)
+ {
+ AaruConsole.
+ ErrorWriteLine(UI.Error_0_reading_tag_for_sector_1_continuing,
+ errno, doneSectors + track.StartSector);
+ }
+ else
+ {
+ AaruConsole.
+ ErrorWriteLine(UI.Error_0_reading_tag_for_sector_1_not_continuing,
+ errno, doneSectors + track.StartSector);
- return;
- }
- }
- }
- else
- {
- errno = inputOptical.ReadSectorsTag(doneSectors + track.StartSector,
- sectorsToDo, tag, out sector);
+ return;
+ }
+ }
+ }
+ else
+ {
+ errno = inputOptical.ReadSectorsTag(doneSectors + track.StartSector,
+ sectorsToDo, tag, out sector);
- if(errno == ErrorNumber.NoError)
- {
- if(tag == SectorTagType.CdSectorSubchannel)
- {
- bool indexesChanged =
- CompactDisc.WriteSubchannelToImage(MmcSubchannel.Raw,
- MmcSubchannel.Raw, sector,
- doneSectors + track.StartSector, sectorsToDo, null,
- isrcs, (byte)track.Sequence, ref mcn, tracks,
- subchannelExtents, fixSubchannelPosition,
- outputOptical, fixSubchannel, fixSubchannelCrc, null,
- null, smallestPregapLbaPerTrack, false, out _);
+ if(errno == ErrorNumber.NoError)
+ {
+ if(tag == SectorTagType.CdSectorSubchannel)
+ {
+ bool indexesChanged =
+ CompactDisc.WriteSubchannelToImage(MmcSubchannel.Raw,
+ MmcSubchannel.Raw, sector,
+ doneSectors + track.StartSector, sectorsToDo,
+ null,
+ isrcs, (byte)track.Sequence, ref mcn, tracks,
+ subchannelExtents, fixSubchannelPosition,
+ outputOptical, fixSubchannel, fixSubchannelCrc,
+ null,
+ null, smallestPregapLbaPerTrack, false, out _);
- if(indexesChanged)
- outputOptical.SetTracks(tracks.ToList());
+ if(indexesChanged)
+ outputOptical.SetTracks(tracks.ToList());
- result = true;
- }
- else
- result =
- outputOptical.WriteSectorsTag(sector,
- doneSectors + track.StartSector, sectorsToDo, tag);
- }
- else
- {
- result = true;
+ result = true;
+ }
+ else
+ {
+ result =
+ outputOptical.WriteSectorsTag(sector,
+ doneSectors + track.StartSector, sectorsToDo,
+ tag);
+ }
+ }
+ else
+ {
+ result = true;
- if(force)
- AaruConsole.
- ErrorWriteLine(UI.Error_0_reading_tag_for_sector_1_continuing,
- errno, doneSectors + track.StartSector);
- else
- {
- AaruConsole.
- ErrorWriteLine(UI.Error_0_reading_tag_for_sector_1_not_continuing,
- errno, doneSectors + track.StartSector);
+ if(force)
+ {
+ AaruConsole.
+ ErrorWriteLine(UI.Error_0_reading_tag_for_sector_1_continuing,
+ errno, doneSectors + track.StartSector);
+ }
+ else
+ {
+ AaruConsole.
+ ErrorWriteLine(UI.Error_0_reading_tag_for_sector_1_not_continuing,
+ errno, doneSectors + track.StartSector);
- return;
- }
- }
- }
+ return;
+ }
+ }
+ }
- if(!result)
- if(force)
- AaruConsole.
- ErrorWriteLine(UI.Error_0_writing_tag_for_sector_1_continuing,
- outputOptical.ErrorMessage,
- doneSectors + track.StartSector);
- else
- {
- AaruConsole.
- ErrorWriteLine(UI.Error_0_writing_tag_for_sector_1_not_continuing,
- outputOptical.ErrorMessage,
- doneSectors + track.StartSector);
+ if(!result)
+ {
+ if(force)
+ {
+ AaruConsole.
+ ErrorWriteLine(UI.Error_0_writing_tag_for_sector_1_continuing,
+ outputOptical.ErrorMessage,
+ doneSectors + track.StartSector);
+ }
+ else
+ {
+ AaruConsole.
+ ErrorWriteLine(UI.Error_0_writing_tag_for_sector_1_not_continuing,
+ outputOptical.ErrorMessage,
+ doneSectors + track.StartSector);
- errno = ErrorNumber.WriteError;
+ errno = ErrorNumber.WriteError;
- return;
- }
+ return;
+ }
+ }
- doneSectors += sectorsToDo;
- trackTask.Value += sectorsToDo;
- }
+ doneSectors += sectorsToDo;
+ trackTask.Value += sectorsToDo;
+ }
- trackTask.StopTask();
- discTask.Increment(1);
- }
- });
+ trackTask.StopTask();
+ discTask.Increment(1);
+ }
+ });
if(errno != ErrorNumber.NoError &&
!force)
@@ -1331,37 +1394,53 @@ sealed class ConvertImageCommand : Command
}
if(isrcs.Count > 0)
+ {
foreach(KeyValuePair isrc in isrcs)
+ {
outputOptical.WriteSectorTag(Encoding.UTF8.GetBytes(isrc.Value), isrc.Key,
SectorTagType.CdTrackIsrc);
+ }
+ }
if(trackFlags.Count > 0)
+ {
foreach((byte track, byte flags) in trackFlags)
- outputOptical.WriteSectorTag(new[]
- {
- flags
- }, track, SectorTagType.CdTrackFlags);
+ {
+ outputOptical.WriteSectorTag(new[] { flags }, track, SectorTagType.CdTrackFlags);
+ }
+ }
if(mcn != null)
outputOptical.WriteMediaTag(Encoding.UTF8.GetBytes(mcn), MediaTagType.CD_MCN);
// TODO: Progress
if(inputOptical.Info.MediaType is MediaType.CD or MediaType.CDDA or MediaType.CDG or MediaType.CDEG
- or MediaType.CDI or MediaType.CDROM or MediaType.CDROMXA or MediaType.CDPLUS or MediaType.CDMO
- or MediaType.CDR or MediaType.CDRW or MediaType.CDMRW or MediaType.VCD or MediaType.SVCD
- or MediaType.PCD or MediaType.DTSCD or MediaType.CDMIDI or MediaType.CDV or MediaType.CDIREADY
- or MediaType.FMTOWNS or MediaType.PS1CD or MediaType.PS2CD or MediaType.MEGACD or MediaType.SATURNCD
- or MediaType.GDROM or MediaType.GDR or MediaType.MilCD or MediaType.SuperCDROM2 or MediaType.JaguarCD
- or MediaType.ThreeDO or MediaType.PCFX or MediaType.NeoGeoCD or MediaType.CDTV or MediaType.CD32
- or MediaType.Playdia or MediaType.Pippin or MediaType.VideoNow or MediaType.VideoNowColor
- or MediaType.VideoNowXp or MediaType.CVD && generateSubchannels)
+ or MediaType.CDI or MediaType.CDROM or MediaType.CDROMXA or MediaType.CDPLUS
+ or MediaType.CDMO
+ or MediaType.CDR or MediaType.CDRW or MediaType.CDMRW or MediaType.VCD
+ or MediaType.SVCD
+ or MediaType.PCD or MediaType.DTSCD or MediaType.CDMIDI or MediaType.CDV
+ or MediaType.CDIREADY
+ or MediaType.FMTOWNS or MediaType.PS1CD or MediaType.PS2CD
+ or MediaType.MEGACD or MediaType.SATURNCD
+ or MediaType.GDROM or MediaType.GDR or MediaType.MilCD
+ or MediaType.SuperCDROM2 or MediaType.JaguarCD
+ or MediaType.ThreeDO or MediaType.PCFX or MediaType.NeoGeoCD
+ or MediaType.CDTV or MediaType.CD32
+ or MediaType.Playdia or MediaType.Pippin or MediaType.VideoNow
+ or MediaType.VideoNowColor
+ or MediaType.VideoNowXp or MediaType.CVD && generateSubchannels)
+ {
Core.Spectre.ProgressSingleSpinner(ctx =>
- {
- ctx.AddTask(Localization.Core.Generating_subchannels).IsIndeterminate();
+ {
+ ctx.AddTask(Localization.Core.Generating_subchannels).
+ IsIndeterminate();
- CompactDisc.GenerateSubchannels(subchannelExtents, tracks, trackFlags, inputOptical.Info.Sectors,
- null, null, null, null, null, outputOptical);
- });
+ CompactDisc.GenerateSubchannels(subchannelExtents, tracks,
+ trackFlags, inputOptical.Info.Sectors,
+ null, null, null, null, null, outputOptical);
+ });
+ }
}
else
{
@@ -1380,8 +1459,10 @@ sealed class ConvertImageCommand : Command
chs.heads, chs.sectors);
if(!outputMedia.SetGeometry(chs.cylinders, chs.heads, chs.sectors))
+ {
AaruConsole.ErrorWriteLine(UI.Error_0_setting_geometry_image_may_be_incorrect_continuing,
outputMedia.ErrorMessage);
+ }
}
ErrorNumber errno = ErrorNumber.NoError;
@@ -1389,251 +1470,287 @@ sealed class ConvertImageCommand : Command
AnsiConsole.Progress().AutoClear(true).HideCompleted(true).
Columns(new TaskDescriptionColumn(), new ProgressBarColumn(), new PercentageColumn()).
Start(ctx =>
- {
- ProgressTask mediaTask = ctx.AddTask(UI.Converting_media);
- mediaTask.MaxValue = inputFormat.Info.Sectors;
+ {
+ ProgressTask mediaTask = ctx.AddTask(UI.Converting_media);
+ mediaTask.MaxValue = inputFormat.Info.Sectors;
- while(doneSectors < inputFormat.Info.Sectors)
- {
- byte[] sector;
+ while(doneSectors < inputFormat.Info.Sectors)
+ {
+ byte[] sector;
- uint sectorsToDo;
+ uint sectorsToDo;
- if(inputTape?.IsTape == true)
- sectorsToDo = 1;
- else if(inputFormat.Info.Sectors - doneSectors >= (ulong)count)
- sectorsToDo = (uint)count;
- else
- sectorsToDo = (uint)(inputFormat.Info.Sectors - doneSectors);
+ if(inputTape?.IsTape == true)
+ sectorsToDo = 1;
+ else if(inputFormat.Info.Sectors - doneSectors >= (ulong)count)
+ sectorsToDo = (uint)count;
+ else
+ sectorsToDo = (uint)(inputFormat.Info.Sectors - doneSectors);
- mediaTask.Description =
- string.Format(UI.Converting_sectors_0_to_1, doneSectors, doneSectors + sectorsToDo);
+ mediaTask.Description =
+ string.Format(UI.Converting_sectors_0_to_1, doneSectors,
+ doneSectors + sectorsToDo);
- bool result;
+ bool result;
- if(useLong)
- {
- errno = sectorsToDo == 1 ? inputFormat.ReadSectorLong(doneSectors, out sector)
- : inputFormat.ReadSectorsLong(doneSectors, sectorsToDo, out sector);
+ if(useLong)
+ {
+ errno = sectorsToDo == 1
+ ? inputFormat.ReadSectorLong(doneSectors, out sector)
+ : inputFormat.ReadSectorsLong(doneSectors, sectorsToDo,
+ out sector);
- if(errno == ErrorNumber.NoError)
- result = sectorsToDo == 1 ? outputMedia.WriteSectorLong(sector, doneSectors)
- : outputMedia.WriteSectorsLong(sector, doneSectors, sectorsToDo);
- else
- {
- result = true;
+ if(errno == ErrorNumber.NoError)
+ {
+ result = sectorsToDo == 1
+ ? outputMedia.WriteSectorLong(sector, doneSectors)
+ : outputMedia.WriteSectorsLong(sector, doneSectors,
+ sectorsToDo);
+ }
+ else
+ {
+ result = true;
- if(force)
- AaruConsole.ErrorWriteLine(UI.Error_0_reading_sector_1_continuing, errno,
- doneSectors);
- else
- {
- AaruConsole.ErrorWriteLine(UI.Error_0_reading_sector_1_not_continuing,
- errno, doneSectors);
+ if(force)
+ {
+ AaruConsole.ErrorWriteLine(UI.Error_0_reading_sector_1_continuing,
+ errno,
+ doneSectors);
+ }
+ else
+ {
+ AaruConsole.ErrorWriteLine(UI.Error_0_reading_sector_1_not_continuing,
+ errno, doneSectors);
- return;
- }
- }
- }
- else
- {
- errno = sectorsToDo == 1 ? inputFormat.ReadSector(doneSectors, out sector)
- : inputFormat.ReadSectors(doneSectors, sectorsToDo, out sector);
+ return;
+ }
+ }
+ }
+ else
+ {
+ errno = sectorsToDo == 1
+ ? inputFormat.ReadSector(doneSectors, out sector)
+ : inputFormat.ReadSectors(doneSectors, sectorsToDo, out sector);
- if(errno == ErrorNumber.NoError)
- result = sectorsToDo == 1 ? outputMedia.WriteSector(sector, doneSectors)
- : outputMedia.WriteSectors(sector, doneSectors, sectorsToDo);
- else
- {
- result = true;
+ if(errno == ErrorNumber.NoError)
+ {
+ result = sectorsToDo == 1
+ ? outputMedia.WriteSector(sector, doneSectors)
+ : outputMedia.WriteSectors(sector, doneSectors, sectorsToDo);
+ }
+ else
+ {
+ result = true;
- if(force)
- AaruConsole.ErrorWriteLine(UI.Error_0_reading_sector_1_continuing, errno,
- doneSectors);
- else
- {
- AaruConsole.ErrorWriteLine(UI.Error_0_reading_sector_1_not_continuing,
- errno, doneSectors);
+ if(force)
+ {
+ AaruConsole.ErrorWriteLine(UI.Error_0_reading_sector_1_continuing,
+ errno,
+ doneSectors);
+ }
+ else
+ {
+ AaruConsole.ErrorWriteLine(UI.Error_0_reading_sector_1_not_continuing,
+ errno, doneSectors);
- return;
- }
- }
- }
+ return;
+ }
+ }
+ }
- if(!result)
- if(force)
- AaruConsole.ErrorWriteLine(UI.Error_0_writing_sector_1_continuing,
- outputMedia.ErrorMessage, doneSectors);
- else
- {
- AaruConsole.ErrorWriteLine(UI.Error_0_writing_sector_1_not_continuing,
- outputMedia.ErrorMessage, doneSectors);
+ if(!result)
+ {
+ if(force)
+ {
+ AaruConsole.ErrorWriteLine(UI.Error_0_writing_sector_1_continuing,
+ outputMedia.ErrorMessage, doneSectors);
+ }
+ else
+ {
+ AaruConsole.ErrorWriteLine(UI.Error_0_writing_sector_1_not_continuing,
+ outputMedia.ErrorMessage, doneSectors);
- errno = ErrorNumber.WriteError;
+ errno = ErrorNumber.WriteError;
- return;
- }
+ return;
+ }
+ }
- doneSectors += sectorsToDo;
- mediaTask.Value += sectorsToDo;
- }
+ doneSectors += sectorsToDo;
+ mediaTask.Value += sectorsToDo;
+ }
- mediaTask.StopTask();
+ mediaTask.StopTask();
- foreach(SectorTagType tag in inputFormat.Info.ReadableSectorTags.TakeWhile(_ => useLong))
- {
- switch(tag)
- {
- case SectorTagType.AppleSectorTag:
- case SectorTagType.CdSectorSync:
- case SectorTagType.CdSectorHeader:
- case SectorTagType.CdSectorSubHeader:
- case SectorTagType.CdSectorEdc:
- case SectorTagType.CdSectorEccP:
- case SectorTagType.CdSectorEccQ:
- case SectorTagType.CdSectorEcc:
- // This tags are inline in long sector
- continue;
- }
+ foreach(SectorTagType tag in
+ inputFormat.Info.ReadableSectorTags.TakeWhile(_ => useLong))
+ {
+ switch(tag)
+ {
+ case SectorTagType.AppleSectorTag:
+ case SectorTagType.CdSectorSync:
+ case SectorTagType.CdSectorHeader:
+ case SectorTagType.CdSectorSubHeader:
+ case SectorTagType.CdSectorEdc:
+ case SectorTagType.CdSectorEccP:
+ case SectorTagType.CdSectorEccQ:
+ case SectorTagType.CdSectorEcc:
+ // This tags are inline in long sector
+ continue;
+ }
- if(force && !outputMedia.SupportedSectorTags.Contains(tag))
- continue;
+ if(force && !outputMedia.SupportedSectorTags.Contains(tag))
+ continue;
- doneSectors = 0;
+ doneSectors = 0;
- ProgressTask tagsTask = ctx.AddTask(UI.Converting_tags);
- tagsTask.MaxValue = inputFormat.Info.Sectors;
+ ProgressTask tagsTask = ctx.AddTask(UI.Converting_tags);
+ tagsTask.MaxValue = inputFormat.Info.Sectors;
- while(doneSectors < inputFormat.Info.Sectors)
- {
- uint sectorsToDo;
+ while(doneSectors < inputFormat.Info.Sectors)
+ {
+ uint sectorsToDo;
- if(inputFormat.Info.Sectors - doneSectors >= (ulong)count)
- sectorsToDo = (uint)count;
- else
- sectorsToDo = (uint)(inputFormat.Info.Sectors - doneSectors);
+ if(inputFormat.Info.Sectors - doneSectors >= (ulong)count)
+ sectorsToDo = (uint)count;
+ else
+ sectorsToDo = (uint)(inputFormat.Info.Sectors - doneSectors);
- tagsTask.Description =
- string.Format(UI.Converting_tag_2_for_sectors_0_to_1, doneSectors,
- doneSectors + sectorsToDo, tag);
+ tagsTask.Description =
+ string.Format(UI.Converting_tag_2_for_sectors_0_to_1, doneSectors,
+ doneSectors + sectorsToDo, tag);
- bool result;
+ bool result;
- errno = sectorsToDo == 1
- ? inputFormat.ReadSectorTag(doneSectors, tag, out byte[] sector)
- : inputFormat.ReadSectorsTag(doneSectors, sectorsToDo, tag, out sector);
+ errno = sectorsToDo == 1
+ ? inputFormat.ReadSectorTag(doneSectors, tag, out byte[] sector)
+ : inputFormat.ReadSectorsTag(doneSectors, sectorsToDo, tag,
+ out sector);
- if(errno == ErrorNumber.NoError)
- result = sectorsToDo == 1 ? outputMedia.WriteSectorTag(sector, doneSectors, tag)
- : outputMedia.WriteSectorsTag(sector, doneSectors, sectorsToDo,
- tag);
- else
- {
- result = true;
+ if(errno == ErrorNumber.NoError)
+ {
+ result = sectorsToDo == 1
+ ? outputMedia.WriteSectorTag(sector, doneSectors, tag)
+ : outputMedia.WriteSectorsTag(sector, doneSectors,
+ sectorsToDo,
+ tag);
+ }
+ else
+ {
+ result = true;
- if(force)
- AaruConsole.ErrorWriteLine(UI.Error_0_reading_sector_1_continuing, errno,
- doneSectors);
- else
- {
- AaruConsole.ErrorWriteLine(UI.Error_0_reading_sector_1_not_continuing,
- errno, doneSectors);
+ if(force)
+ {
+ AaruConsole.ErrorWriteLine(UI.Error_0_reading_sector_1_continuing,
+ errno,
+ doneSectors);
+ }
+ else
+ {
+ AaruConsole.ErrorWriteLine(UI.Error_0_reading_sector_1_not_continuing,
+ errno, doneSectors);
- return;
- }
- }
+ return;
+ }
+ }
- if(!result)
- if(force)
- AaruConsole.ErrorWriteLine(UI.Error_0_writing_sector_1_continuing,
- outputMedia.ErrorMessage, doneSectors);
- else
- {
- AaruConsole.ErrorWriteLine(UI.Error_0_writing_sector_1_not_continuing,
- outputMedia.ErrorMessage, doneSectors);
+ if(!result)
+ {
+ if(force)
+ {
+ AaruConsole.ErrorWriteLine(UI.Error_0_writing_sector_1_continuing,
+ outputMedia.ErrorMessage, doneSectors);
+ }
+ else
+ {
+ AaruConsole.ErrorWriteLine(UI.Error_0_writing_sector_1_not_continuing,
+ outputMedia.ErrorMessage, doneSectors);
- errno = ErrorNumber.WriteError;
+ errno = ErrorNumber.WriteError;
- return;
- }
+ return;
+ }
+ }
- doneSectors += sectorsToDo;
- tagsTask.Value += sectorsToDo;
- }
+ doneSectors += sectorsToDo;
+ tagsTask.Value += sectorsToDo;
+ }
- tagsTask.StopTask();
- }
+ tagsTask.StopTask();
+ }
- if(inputFormat is IFluxImage inputFlux &&
- outputFormat is IWritableFluxImage outputFlux)
- {
- for(ushort track = 0; track < inputFlux.Info.Cylinders; track++)
- {
- for(uint head = 0; head < inputFlux.Info.Heads; head++)
- {
- ErrorNumber error = inputFlux.SubTrackLength(head, track, out byte subTrackLen);
+ if(inputFormat is IFluxImage inputFlux &&
+ outputFormat is IWritableFluxImage outputFlux)
+ {
+ for(ushort track = 0; track < inputFlux.Info.Cylinders; track++)
+ {
+ for(uint head = 0; head < inputFlux.Info.Heads; head++)
+ {
+ ErrorNumber error =
+ inputFlux.SubTrackLength(head, track, out byte subTrackLen);
- if(error != ErrorNumber.NoError)
- continue;
+ if(error != ErrorNumber.NoError)
+ continue;
- for(byte subTrackIndex = 0; subTrackIndex < subTrackLen; subTrackIndex++)
- {
- error = inputFlux.CapturesLength(head, track, subTrackIndex,
- out uint capturesLen);
+ for(byte subTrackIndex = 0; subTrackIndex < subTrackLen; subTrackIndex++)
+ {
+ error = inputFlux.CapturesLength(head, track, subTrackIndex,
+ out uint capturesLen);
- if(error != ErrorNumber.NoError)
- continue;
+ if(error != ErrorNumber.NoError)
+ continue;
- for(uint captureIndex = 0; captureIndex < capturesLen; captureIndex++)
- {
- inputFlux.ReadFluxCapture(head, track, subTrackIndex, captureIndex,
- out ulong indexResolution,
- out ulong dataResolution,
- out byte[] indexBuffer,
- out byte[] dataBuffer);
+ for(uint captureIndex = 0; captureIndex < capturesLen; captureIndex++)
+ {
+ inputFlux.ReadFluxCapture(head, track, subTrackIndex,
+ captureIndex,
+ out ulong indexResolution,
+ out ulong dataResolution,
+ out byte[] indexBuffer,
+ out byte[] dataBuffer);
- outputFlux.WriteFluxCapture(indexResolution, dataResolution,
- indexBuffer, dataBuffer, head, track, subTrackIndex,
- captureIndex);
- }
- }
- }
- }
- }
+ outputFlux.WriteFluxCapture(indexResolution, dataResolution,
+ indexBuffer, dataBuffer, head, track, subTrackIndex,
+ captureIndex);
+ }
+ }
+ }
+ }
+ }
- if(inputTape == null ||
- outputTape == null ||
- !inputTape.IsTape)
- return;
+ if(inputTape == null ||
+ outputTape == null ||
+ !inputTape.IsTape)
+ return;
- ProgressTask filesTask = ctx.AddTask(UI.Converting_files);
- filesTask.MaxValue = inputTape.Files.Count;
+ ProgressTask filesTask = ctx.AddTask(UI.Converting_files);
+ filesTask.MaxValue = inputTape.Files.Count;
- foreach(TapeFile tapeFile in inputTape.Files)
- {
- filesTask.Description =
- string.Format(UI.Converting_file_0_of_partition_1, tapeFile.File,
- tapeFile.Partition);
+ foreach(TapeFile tapeFile in inputTape.Files)
+ {
+ filesTask.Description =
+ string.Format(UI.Converting_file_0_of_partition_1, tapeFile.File,
+ tapeFile.Partition);
- outputTape.AddFile(tapeFile);
- filesTask.Increment(1);
- }
+ outputTape.AddFile(tapeFile);
+ filesTask.Increment(1);
+ }
- filesTask.StopTask();
+ filesTask.StopTask();
- ProgressTask partitionTask = ctx.AddTask(UI.Converting_files);
- partitionTask.MaxValue = inputTape.TapePartitions.Count;
+ ProgressTask partitionTask = ctx.AddTask(UI.Converting_files);
+ partitionTask.MaxValue = inputTape.TapePartitions.Count;
- foreach(TapePartition tapePartition in inputTape.TapePartitions)
- {
- partitionTask.Description =
- string.Format(UI.Converting_tape_partition_0, tapePartition.Number);
+ foreach(TapePartition tapePartition in inputTape.TapePartitions)
+ {
+ partitionTask.Description =
+ string.Format(UI.Converting_tape_partition_0, tapePartition.Number);
- outputTape.AddPartition(tapePartition);
- }
+ outputTape.AddPartition(tapePartition);
+ }
- partitionTask.StopTask();
- });
+ partitionTask.StopTask();
+ });
if(errno != ErrorNumber.NoError)
return (int)errno;
@@ -1643,14 +1760,14 @@ sealed class ConvertImageCommand : Command
dumpHardware != null)
{
Core.Spectre.ProgressSingleSpinner(ctx =>
- {
- ctx.AddTask(UI.Writing_dump_hardware_list).IsIndeterminate();
+ {
+ ctx.AddTask(UI.Writing_dump_hardware_list).IsIndeterminate();
- if(resume != null)
- ret = outputFormat.SetDumpHardware(resume.Tries);
- else if(dumpHardware != null)
- ret = outputFormat.SetDumpHardware(dumpHardware);
- });
+ if(resume != null)
+ ret = outputFormat.SetDumpHardware(resume.Tries);
+ else if(dumpHardware != null)
+ ret = outputFormat.SetDumpHardware(dumpHardware);
+ });
if(ret)
AaruConsole.WriteLine(UI.Written_dump_hardware_list_to_output_image);
@@ -1662,26 +1779,26 @@ sealed class ConvertImageCommand : Command
metadata != null)
{
Core.Spectre.ProgressSingleSpinner(ctx =>
- {
- ctx.AddTask(UI.Writing_metadata).IsIndeterminate();
+ {
+ ctx.AddTask(UI.Writing_metadata).IsIndeterminate();
- if(sidecar != null)
- ret = outputFormat.SetMetadata(sidecar);
- else if(metadata != null)
- ret = outputFormat.SetMetadata(metadata);
- });
+ if(sidecar != null)
+ ret = outputFormat.SetMetadata(sidecar);
+ else if(metadata != null)
+ ret = outputFormat.SetMetadata(metadata);
+ });
if(ret)
AaruConsole.WriteLine(UI.Written_Aaru_Metadata_to_output_image);
}
- bool closed = false;
+ var closed = false;
Core.Spectre.ProgressSingleSpinner(ctx =>
- {
- ctx.AddTask(UI.Closing_output_image).IsIndeterminate();
- closed = outputFormat.Close();
- });
+ {
+ ctx.AddTask(UI.Closing_output_image).IsIndeterminate();
+ closed = outputFormat.Close();
+ });
if(!closed)
{
diff --git a/Aaru/Commands/Image/CreateSidecar.cs b/Aaru/Commands/Image/CreateSidecar.cs
index 279de9d71..7e834d926 100644
--- a/Aaru/Commands/Image/CreateSidecar.cs
+++ b/Aaru/Commands/Image/CreateSidecar.cs
@@ -31,7 +31,6 @@
// ****************************************************************************/
using System;
-using System.Collections.Generic;
using System.CommandLine;
using System.CommandLine.NamingConventionBinder;
using System.IO;
@@ -60,20 +59,11 @@ sealed class CreateSidecarCommand : Command
public CreateSidecarCommand() : base("create-sidecar", UI.Image_Create_Sidecar_Command_Description)
{
- Add(new Option(new[]
- {
- "--block-size", "-b"
- }, () => 512, UI.Tape_block_size_argument_help));
+ Add(new Option(new[] { "--block-size", "-b" }, () => 512, UI.Tape_block_size_argument_help));
- Add(new Option(new[]
- {
- "--encoding", "-e"
- }, () => null, UI.Name_of_character_encoding_to_use));
+ Add(new Option(new[] { "--encoding", "-e" }, () => null, UI.Name_of_character_encoding_to_use));
- Add(new Option(new[]
- {
- "--tape", "-t"
- }, () => false, UI.Tape_argument_input_help));
+ Add(new Option(new[] { "--tape", "-t" }, () => false, UI.Tape_argument_input_help));
AddArgument(new Argument
{
@@ -85,7 +75,7 @@ sealed class CreateSidecarCommand : Command
Handler = CommandHandler.Create(GetType().GetMethod(nameof(Invoke)));
}
- public static int Invoke(bool debug, bool verbose, uint blockSize, [CanBeNull] string encodingName,
+ public static int Invoke(bool debug, bool verbose, uint blockSize, [CanBeNull] string encodingName,
string imagePath, bool tape)
{
MainClass.PrintCopyright();
@@ -98,35 +88,38 @@ sealed class CreateSidecarCommand : Command
});
AaruConsole.DebugWriteLineEvent += (format, objects) =>
- {
- if(objects is null)
- stderrConsole.MarkupLine(format);
- else
- stderrConsole.MarkupLine(format, objects);
- };
+ {
+ if(objects is null)
+ stderrConsole.MarkupLine(format);
+ else
+ stderrConsole.MarkupLine(format, objects);
+ };
}
if(verbose)
+ {
AaruConsole.WriteEvent += (format, objects) =>
- {
- if(objects is null)
- AnsiConsole.Markup(format);
- else
- AnsiConsole.Markup(format, objects);
- };
+ {
+ if(objects is null)
+ AnsiConsole.Markup(format);
+ else
+ AnsiConsole.Markup(format, objects);
+ };
+ }
Statistics.AddCommand("create-sidecar");
AaruConsole.DebugWriteLine(MODULE_NAME, "--block-size={0}", blockSize);
- AaruConsole.DebugWriteLine(MODULE_NAME, "--debug={0}", debug);
- AaruConsole.DebugWriteLine(MODULE_NAME, "--encoding={0}", encodingName);
- AaruConsole.DebugWriteLine(MODULE_NAME, "--input={0}", imagePath);
- AaruConsole.DebugWriteLine(MODULE_NAME, "--tape={0}", tape);
- AaruConsole.DebugWriteLine(MODULE_NAME, "--verbose={0}", verbose);
+ AaruConsole.DebugWriteLine(MODULE_NAME, "--debug={0}", debug);
+ AaruConsole.DebugWriteLine(MODULE_NAME, "--encoding={0}", encodingName);
+ AaruConsole.DebugWriteLine(MODULE_NAME, "--input={0}", imagePath);
+ AaruConsole.DebugWriteLine(MODULE_NAME, "--tape={0}", tape);
+ AaruConsole.DebugWriteLine(MODULE_NAME, "--verbose={0}", verbose);
Encoding encodingClass = null;
if(encodingName != null)
+ {
try
{
encodingClass = Claunia.Encoding.Encoding.GetEncoding(encodingName);
@@ -140,6 +133,7 @@ sealed class CreateSidecarCommand : Command
return (int)ErrorNumber.EncodingUnknown;
}
+ }
if(File.Exists(imagePath))
{
@@ -154,10 +148,10 @@ sealed class CreateSidecarCommand : Command
IFilter inputFilter = null;
Core.Spectre.ProgressSingleSpinner(ctx =>
- {
- ctx.AddTask(UI.Identifying_file_filter).IsIndeterminate();
- inputFilter = filtersList.GetFilter(imagePath);
- });
+ {
+ ctx.AddTask(UI.Identifying_file_filter).IsIndeterminate();
+ inputFilter = filtersList.GetFilter(imagePath);
+ });
if(inputFilter == null)
{
@@ -171,10 +165,10 @@ sealed class CreateSidecarCommand : Command
IBaseImage imageFormat = null;
Core.Spectre.ProgressSingleSpinner(ctx =>
- {
- ctx.AddTask(UI.Identifying_image_format).IsIndeterminate();
- imageFormat = ImageFormat.Detect(inputFilter);
- });
+ {
+ ctx.AddTask(UI.Identifying_image_format).IsIndeterminate();
+ imageFormat = ImageFormat.Detect(inputFilter);
+ });
if(imageFormat == null)
{
@@ -193,10 +187,10 @@ sealed class CreateSidecarCommand : Command
ErrorNumber opened = ErrorNumber.NoData;
Core.Spectre.ProgressSingleSpinner(ctx =>
- {
- ctx.AddTask(UI.Invoke_Opening_image_file).IsIndeterminate();
- opened = imageFormat.Open(inputFilter);
- });
+ {
+ ctx.AddTask(UI.Invoke_Opening_image_file).IsIndeterminate();
+ opened = imageFormat.Open(inputFilter);
+ });
if(opened != ErrorNumber.NoError)
{
@@ -225,75 +219,80 @@ sealed class CreateSidecarCommand : Command
AnsiConsole.Progress().AutoClear(true).HideCompleted(true).
Columns(new TaskDescriptionColumn(), new ProgressBarColumn(), new PercentageColumn()).
Start(ctx =>
- {
- sidecarClass.InitProgressEvent += () =>
- {
- _progressTask1 = ctx.AddTask("Progress");
- };
+ {
+ sidecarClass.InitProgressEvent += () =>
+ {
+ _progressTask1 = ctx.AddTask("Progress");
+ };
- sidecarClass.InitProgressEvent2 += () =>
- {
- _progressTask2 = ctx.AddTask("Progress");
- };
+ sidecarClass.InitProgressEvent2 += () =>
+ {
+ _progressTask2 = ctx.AddTask("Progress");
+ };
- sidecarClass.UpdateProgressEvent += (text, current, maximum) =>
- {
- _progressTask1 ??= ctx.AddTask("Progress");
- _progressTask1.Description = Markup.Escape(text);
- _progressTask1.Value = current;
- _progressTask1.MaxValue = maximum;
- };
+ sidecarClass.UpdateProgressEvent += (text, current, maximum) =>
+ {
+ _progressTask1 ??=
+ ctx.AddTask("Progress");
+ _progressTask1.Description =
+ Markup.Escape(text);
+ _progressTask1.Value = current;
+ _progressTask1.MaxValue = maximum;
+ };
- sidecarClass.UpdateProgressEvent2 += (text, current, maximum) =>
- {
- _progressTask2 ??= ctx.AddTask("Progress");
- _progressTask2.Description = Markup.Escape(text);
- _progressTask2.Value = current;
- _progressTask2.MaxValue = maximum;
- };
+ sidecarClass.UpdateProgressEvent2 += (text, current, maximum) =>
+ {
+ _progressTask2 ??=
+ ctx.AddTask("Progress");
+ _progressTask2.Description =
+ Markup.Escape(text);
+ _progressTask2.Value = current;
+ _progressTask2.MaxValue = maximum;
+ };
- sidecarClass.EndProgressEvent += () =>
- {
- _progressTask1?.StopTask();
- _progressTask1 = null;
- };
+ sidecarClass.EndProgressEvent += () =>
+ {
+ _progressTask1?.StopTask();
+ _progressTask1 = null;
+ };
- sidecarClass.EndProgressEvent2 += () =>
- {
- _progressTask2?.StopTask();
- _progressTask2 = null;
- };
+ sidecarClass.EndProgressEvent2 += () =>
+ {
+ _progressTask2?.StopTask();
+ _progressTask2 = null;
+ };
- sidecarClass.UpdateStatusEvent += text =>
- {
- AaruConsole.WriteLine(Markup.Escape(text));
- };
+ sidecarClass.UpdateStatusEvent += text =>
+ {
+ AaruConsole.WriteLine(Markup.Escape(text));
+ };
- System.Console.CancelKeyPress += (_, e) =>
- {
- e.Cancel = true;
- sidecarClass.Abort();
- };
+ System.Console.CancelKeyPress += (_, e) =>
+ {
+ e.Cancel = true;
+ sidecarClass.Abort();
+ };
- sidecar = sidecarClass.Create();
- });
+ sidecar = sidecarClass.Create();
+ });
Core.Spectre.ProgressSingleSpinner(ctx =>
- {
- ctx.AddTask(Localization.Core.Writing_metadata_sidecar).IsIndeterminate();
+ {
+ ctx.AddTask(Localization.Core.Writing_metadata_sidecar).
+ IsIndeterminate();
- var jsonFs =
- new
- FileStream(Path.Combine(Path.GetDirectoryName(imagePath) ?? throw new InvalidOperationException(), Path.GetFileNameWithoutExtension(imagePath) + ".metadata.json"),
- FileMode.Create);
+ var jsonFs =
+ new
+ FileStream(Path.Combine(Path.GetDirectoryName(imagePath) ?? throw new InvalidOperationException(), Path.GetFileNameWithoutExtension(imagePath) + ".metadata.json"),
+ FileMode.Create);
- JsonSerializer.Serialize(jsonFs, new MetadataJson
- {
- AaruMetadata = sidecar
- }, typeof(MetadataJson), MetadataJsonContext.Default);
+ JsonSerializer.Serialize(jsonFs, new MetadataJson
+ {
+ AaruMetadata = sidecar
+ }, typeof(MetadataJson), MetadataJsonContext.Default);
- jsonFs.Close();
- });
+ jsonFs.Close();
+ });
}
catch(Exception ex)
{
@@ -312,8 +311,8 @@ sealed class CreateSidecarCommand : Command
return (int)ErrorNumber.IsDirectory;
}
- string[] contents = Directory.GetFiles(imagePath, "*", SearchOption.TopDirectoryOnly);
- List files = contents.Where(file => new FileInfo(file).Length % blockSize == 0).ToList();
+ string[] contents = Directory.GetFiles(imagePath, "*", SearchOption.TopDirectoryOnly);
+ var files = contents.Where(file => new FileInfo(file).Length % blockSize == 0).ToList();
files.Sort(StringComparer.CurrentCultureIgnoreCase);
@@ -323,75 +322,75 @@ sealed class CreateSidecarCommand : Command
AnsiConsole.Progress().AutoClear(true).HideCompleted(true).
Columns(new TaskDescriptionColumn(), new ProgressBarColumn(), new PercentageColumn()).
Start(ctx =>
- {
- sidecarClass.InitProgressEvent += () =>
- {
- _progressTask1 = ctx.AddTask("Progress");
- };
+ {
+ sidecarClass.InitProgressEvent += () => { _progressTask1 = ctx.AddTask("Progress"); };
- sidecarClass.InitProgressEvent2 += () =>
- {
- _progressTask2 = ctx.AddTask("Progress");
- };
+ sidecarClass.InitProgressEvent2 += () =>
+ {
+ _progressTask2 = ctx.AddTask("Progress");
+ };
- sidecarClass.UpdateProgressEvent += (text, current, maximum) =>
- {
- _progressTask1 ??= ctx.AddTask("Progress");
- _progressTask1.Description = Markup.Escape(text);
- _progressTask1.Value = current;
- _progressTask1.MaxValue = maximum;
- };
+ sidecarClass.UpdateProgressEvent += (text, current, maximum) =>
+ {
+ _progressTask1 ??= ctx.AddTask("Progress");
+ _progressTask1.Description =
+ Markup.Escape(text);
+ _progressTask1.Value = current;
+ _progressTask1.MaxValue = maximum;
+ };
- sidecarClass.UpdateProgressEvent2 += (text, current, maximum) =>
- {
- _progressTask2 ??= ctx.AddTask("Progress");
- _progressTask2.Description = Markup.Escape(text);
- _progressTask2.Value = current;
- _progressTask2.MaxValue = maximum;
- };
+ sidecarClass.UpdateProgressEvent2 += (text, current, maximum) =>
+ {
+ _progressTask2 ??= ctx.AddTask("Progress");
+ _progressTask2.Description =
+ Markup.Escape(text);
+ _progressTask2.Value = current;
+ _progressTask2.MaxValue = maximum;
+ };
- sidecarClass.EndProgressEvent += () =>
- {
- _progressTask1?.StopTask();
- _progressTask1 = null;
- };
+ sidecarClass.EndProgressEvent += () =>
+ {
+ _progressTask1?.StopTask();
+ _progressTask1 = null;
+ };
- sidecarClass.EndProgressEvent2 += () =>
- {
- _progressTask2?.StopTask();
- _progressTask2 = null;
- };
+ sidecarClass.EndProgressEvent2 += () =>
+ {
+ _progressTask2?.StopTask();
+ _progressTask2 = null;
+ };
- sidecarClass.UpdateStatusEvent += text =>
- {
- AaruConsole.WriteLine(Markup.Escape(text));
- };
+ sidecarClass.UpdateStatusEvent += text =>
+ {
+ AaruConsole.WriteLine(Markup.Escape(text));
+ };
- System.Console.CancelKeyPress += (_, e) =>
- {
- e.Cancel = true;
- sidecarClass.Abort();
- };
+ System.Console.CancelKeyPress += (_, e) =>
+ {
+ e.Cancel = true;
+ sidecarClass.Abort();
+ };
- sidecar = sidecarClass.BlockTape(Path.GetFileName(imagePath), files, blockSize);
- });
+ sidecar = sidecarClass.BlockTape(Path.GetFileName(imagePath), files, blockSize);
+ });
Core.Spectre.ProgressSingleSpinner(ctx =>
- {
- ctx.AddTask(Localization.Core.Writing_metadata_sidecar).IsIndeterminate();
+ {
+ ctx.AddTask(Localization.Core.Writing_metadata_sidecar).
+ IsIndeterminate();
- var jsonFs =
- new
- FileStream(Path.Combine(Path.GetDirectoryName(imagePath) ?? throw new InvalidOperationException(), Path.GetFileNameWithoutExtension(imagePath) + ".metadata.json"),
- FileMode.Create);
+ var jsonFs =
+ new
+ FileStream(Path.Combine(Path.GetDirectoryName(imagePath) ?? throw new InvalidOperationException(), Path.GetFileNameWithoutExtension(imagePath) + ".metadata.json"),
+ FileMode.Create);
- JsonSerializer.Serialize(jsonFs, new MetadataJson
- {
- AaruMetadata = sidecar
- }, typeof(MetadataJson), MetadataJsonContext.Default);
+ JsonSerializer.Serialize(jsonFs, new MetadataJson
+ {
+ AaruMetadata = sidecar
+ }, typeof(MetadataJson), MetadataJsonContext.Default);
- jsonFs.Close();
- });
+ jsonFs.Close();
+ });
}
else
AaruConsole.ErrorWriteLine(UI.The_specified_input_file_cannot_be_found);
diff --git a/Aaru/Commands/Image/Decode.cs b/Aaru/Commands/Image/Decode.cs
index 0c5af7e04..3b7624aff 100644
--- a/Aaru/Commands/Image/Decode.cs
+++ b/Aaru/Commands/Image/Decode.cs
@@ -52,25 +52,14 @@ sealed class DecodeCommand : Command
public DecodeCommand() : base("decode", UI.Image_Decode_Command_Description)
{
- Add(new Option(new[]
- {
- "--disk-tags", "-f"
- }, () => true, UI.Decode_media_tags));
+ Add(new Option(new[] { "--disk-tags", "-f" }, () => true, UI.Decode_media_tags));
- Add(new Option(new[]
- {
- "--length", "-l"
- }, () => UI.Parameter_response_all_sectors, UI.How_many_sectors_to_decode_or_all));
+ Add(new Option(new[] { "--length", "-l" }, () => UI.Parameter_response_all_sectors,
+ UI.How_many_sectors_to_decode_or_all));
- Add(new Option(new[]
- {
- "--sector-tags", "-p"
- }, () => true, UI.Decode_sector_tags));
+ Add(new Option(new[] { "--sector-tags", "-p" }, () => true, UI.Decode_sector_tags));
- Add(new Option(new[]
- {
- "--start", "-s"
- }, () => 0, UI.Sector_to_start_decoding_from));
+ Add(new Option(new[] { "--start", "-s" }, () => 0, UI.Sector_to_start_decoding_from));
AddArgument(new Argument
{
@@ -82,7 +71,7 @@ sealed class DecodeCommand : Command
Handler = CommandHandler.Create(GetType().GetMethod(nameof(Invoke)));
}
- public static int Invoke(bool verbose, bool debug, bool diskTags, string imagePath, string length, bool sectorTags,
+ public static int Invoke(bool verbose, bool debug, bool diskTags, string imagePath, string length, bool sectorTags,
ulong startSector)
{
MainClass.PrintCopyright();
@@ -95,41 +84,43 @@ sealed class DecodeCommand : Command
});
AaruConsole.DebugWriteLineEvent += (format, objects) =>
- {
- if(objects is null)
- stderrConsole.MarkupLine(format);
- else
- stderrConsole.MarkupLine(format, objects);
- };
+ {
+ if(objects is null)
+ stderrConsole.MarkupLine(format);
+ else
+ stderrConsole.MarkupLine(format, objects);
+ };
}
if(verbose)
+ {
AaruConsole.WriteEvent += (format, objects) =>
- {
- if(objects is null)
- AnsiConsole.Markup(format);
- else
- AnsiConsole.Markup(format, objects);
- };
+ {
+ if(objects is null)
+ AnsiConsole.Markup(format);
+ else
+ AnsiConsole.Markup(format, objects);
+ };
+ }
Statistics.AddCommand("decode");
- AaruConsole.DebugWriteLine(MODULE_NAME, "--debug={0}", debug);
- AaruConsole.DebugWriteLine(MODULE_NAME, "--disk-tags={0}", diskTags);
- AaruConsole.DebugWriteLine(MODULE_NAME, "--input={0}", imagePath);
- AaruConsole.DebugWriteLine(MODULE_NAME, "--length={0}", length);
+ AaruConsole.DebugWriteLine(MODULE_NAME, "--debug={0}", debug);
+ AaruConsole.DebugWriteLine(MODULE_NAME, "--disk-tags={0}", diskTags);
+ AaruConsole.DebugWriteLine(MODULE_NAME, "--input={0}", imagePath);
+ AaruConsole.DebugWriteLine(MODULE_NAME, "--length={0}", length);
AaruConsole.DebugWriteLine(MODULE_NAME, "--sector-tags={0}", sectorTags);
- AaruConsole.DebugWriteLine(MODULE_NAME, "--start={0}", startSector);
- AaruConsole.DebugWriteLine(MODULE_NAME, "--verbose={0}", verbose);
+ AaruConsole.DebugWriteLine(MODULE_NAME, "--start={0}", startSector);
+ AaruConsole.DebugWriteLine(MODULE_NAME, "--verbose={0}", verbose);
var filtersList = new FiltersList();
IFilter inputFilter = null;
Core.Spectre.ProgressSingleSpinner(ctx =>
- {
- ctx.AddTask(UI.Identifying_file_filter).IsIndeterminate();
- inputFilter = filtersList.GetFilter(imagePath);
- });
+ {
+ ctx.AddTask(UI.Identifying_file_filter).IsIndeterminate();
+ inputFilter = filtersList.GetFilter(imagePath);
+ });
if(inputFilter == null)
{
@@ -142,11 +133,11 @@ sealed class DecodeCommand : Command
IBaseImage baseImage = null;
Core.Spectre.ProgressSingleSpinner(ctx =>
- {
- ctx.AddTask(UI.Identifying_image_format).IsIndeterminate();
- baseImage = ImageFormat.Detect(inputFilter);
- inputFormat = baseImage as IMediaImage;
- });
+ {
+ ctx.AddTask(UI.Identifying_image_format).IsIndeterminate();
+ baseImage = ImageFormat.Detect(inputFilter);
+ inputFormat = baseImage as IMediaImage;
+ });
if(baseImage == null)
{
@@ -165,10 +156,10 @@ sealed class DecodeCommand : Command
ErrorNumber opened = ErrorNumber.NoData;
Core.Spectre.ProgressSingleSpinner(ctx =>
- {
- ctx.AddTask(UI.Invoke_Opening_image_file).IsIndeterminate();
- opened = inputFormat.Open(inputFilter);
- });
+ {
+ ctx.AddTask(UI.Invoke_Opening_image_file).IsIndeterminate();
+ opened = inputFormat.Open(inputFilter);
+ });
if(opened != ErrorNumber.NoError)
{
@@ -184,10 +175,13 @@ sealed class DecodeCommand : Command
ErrorNumber errno;
if(diskTags)
+ {
if(inputFormat.Info.ReadableMediaTags.Count == 0)
AaruConsole.WriteLine(UI.There_are_no_media_tags_in_chosen_disc_image);
else
+ {
foreach(MediaTagType tag in inputFormat.Info.ReadableMediaTags)
+ {
switch(tag)
{
case MediaTagType.SCSI_INQUIRY:
@@ -216,8 +210,10 @@ sealed class DecodeCommand : Command
errno = inputFormat.ReadMediaTag(MediaTagType.ATA_IDENTIFY, out byte[] identify);
if(errno != ErrorNumber.NoError)
+ {
AaruConsole.WriteLine(UI.Error_0_reading_ATA_IDENTIFY_DEVICE_response_from_disc_image,
errno);
+ }
else
{
AaruConsole.WriteLine($"[bold]{UI.ATA_IDENTIFY_DEVICE_command_response}[/]");
@@ -238,9 +234,11 @@ sealed class DecodeCommand : Command
errno = inputFormat.ReadMediaTag(MediaTagType.ATAPI_IDENTIFY, out byte[] identify);
if(identify == null)
+ {
AaruConsole.
WriteLine(UI.Error_0_reading_ATA_IDENTIFY_PACKET_DEVICE_response_from_disc_image,
errno);
+ }
else
{
AaruConsole.WriteLine($"[bold]{UI.ATA_IDENTIFY_PACKET_DEVICE_command_response}[/]");
@@ -388,6 +386,9 @@ sealed class DecodeCommand : Command
break;
}
+ }
+ }
+ }
if(!sectorTags)
return (int)ErrorNumber.NoError;
@@ -407,7 +408,9 @@ sealed class DecodeCommand : Command
if(inputFormat.Info.ReadableSectorTags.Count == 0)
AaruConsole.WriteLine(UI.There_are_no_sector_tags_in_chosen_disc_image);
else
+ {
foreach(SectorTagType tag in inputFormat.Info.ReadableSectorTags)
+ {
switch(tag)
{
default:
@@ -415,6 +418,8 @@ sealed class DecodeCommand : Command
break;
}
+ }
+ }
// TODO: Not implemented
diff --git a/Aaru/Commands/Image/Entropy.cs b/Aaru/Commands/Image/Entropy.cs
index 59ae456a0..c614680f7 100644
--- a/Aaru/Commands/Image/Entropy.cs
+++ b/Aaru/Commands/Image/Entropy.cs
@@ -50,20 +50,13 @@ sealed class EntropyCommand : Command
public EntropyCommand() : base("entropy", UI.Image_Entropy_Command_Description)
{
- Add(new Option(new[]
- {
- "--duplicated-sectors", "-p"
- }, () => true, UI.Calculates_how_many_sectors_are_duplicated));
+ Add(new Option(new[] { "--duplicated-sectors", "-p" }, () => true,
+ UI.Calculates_how_many_sectors_are_duplicated));
- Add(new Option(new[]
- {
- "--separated-tracks", "-t"
- }, () => true, UI.Calculates_entropy_for_each_track_separately));
+ Add(new Option(new[] { "--separated-tracks", "-t" }, () => true,
+ UI.Calculates_entropy_for_each_track_separately));
- Add(new Option(new[]
- {
- "--whole-disc", "-w"
- }, () => true, UI.Calculates_entropy_for_the_whole_disc));
+ Add(new Option(new[] { "--whole-disc", "-w" }, () => true, UI.Calculates_entropy_for_the_whole_disc));
AddArgument(new Argument
{
@@ -88,40 +81,42 @@ sealed class EntropyCommand : Command
});
AaruConsole.DebugWriteLineEvent += (format, objects) =>
- {
- if(objects is null)
- stderrConsole.MarkupLine(format);
- else
- stderrConsole.MarkupLine(format, objects);
- };
+ {
+ if(objects is null)
+ stderrConsole.MarkupLine(format);
+ else
+ stderrConsole.MarkupLine(format, objects);
+ };
}
if(verbose)
+ {
AaruConsole.WriteEvent += (format, objects) =>
- {
- if(objects is null)
- AnsiConsole.Markup(format);
- else
- AnsiConsole.Markup(format, objects);
- };
+ {
+ if(objects is null)
+ AnsiConsole.Markup(format);
+ else
+ AnsiConsole.Markup(format, objects);
+ };
+ }
Statistics.AddCommand("entropy");
- AaruConsole.DebugWriteLine(MODULE_NAME, "--debug={0}", debug);
+ AaruConsole.DebugWriteLine(MODULE_NAME, "--debug={0}", debug);
AaruConsole.DebugWriteLine(MODULE_NAME, "--duplicated-sectors={0}", duplicatedSectors);
- AaruConsole.DebugWriteLine(MODULE_NAME, "--input={0}", imagePath);
- AaruConsole.DebugWriteLine(MODULE_NAME, "--separated-tracks={0}", separatedTracks);
- AaruConsole.DebugWriteLine(MODULE_NAME, "--verbose={0}", verbose);
- AaruConsole.DebugWriteLine(MODULE_NAME, "--whole-disc={0}", wholeDisc);
+ AaruConsole.DebugWriteLine(MODULE_NAME, "--input={0}", imagePath);
+ AaruConsole.DebugWriteLine(MODULE_NAME, "--separated-tracks={0}", separatedTracks);
+ AaruConsole.DebugWriteLine(MODULE_NAME, "--verbose={0}", verbose);
+ AaruConsole.DebugWriteLine(MODULE_NAME, "--whole-disc={0}", wholeDisc);
var filtersList = new FiltersList();
IFilter inputFilter = null;
Core.Spectre.ProgressSingleSpinner(ctx =>
- {
- ctx.AddTask(UI.Identifying_file_filter).IsIndeterminate();
- inputFilter = filtersList.GetFilter(imagePath);
- });
+ {
+ ctx.AddTask(UI.Identifying_file_filter).IsIndeterminate();
+ inputFilter = filtersList.GetFilter(imagePath);
+ });
if(inputFilter == null)
{
@@ -133,10 +128,10 @@ sealed class EntropyCommand : Command
IBaseImage inputFormat = null;
Core.Spectre.ProgressSingleSpinner(ctx =>
- {
- ctx.AddTask(UI.Identifying_image_format).IsIndeterminate();
- inputFormat = ImageFormat.Detect(inputFilter);
- });
+ {
+ ctx.AddTask(UI.Identifying_image_format).IsIndeterminate();
+ inputFormat = ImageFormat.Detect(inputFilter);
+ });
if(inputFormat == null)
{
@@ -148,10 +143,10 @@ sealed class EntropyCommand : Command
ErrorNumber opened = ErrorNumber.NoData;
Core.Spectre.ProgressSingleSpinner(ctx =>
- {
- ctx.AddTask(UI.Invoke_Opening_image_file).IsIndeterminate();
- opened = inputFormat.Open(inputFilter);
- });
+ {
+ ctx.AddTask(UI.Invoke_Opening_image_file).IsIndeterminate();
+ opened = inputFormat.Open(inputFilter);
+ });
if(opened != ErrorNumber.NoError)
{
@@ -171,42 +166,48 @@ sealed class EntropyCommand : Command
Columns(new TaskDescriptionColumn(), new ProgressBarColumn(), new PercentageColumn()).Start(ctx =>
{
entropyCalculator.InitProgressEvent += () =>
- {
- _progressTask1 = ctx.AddTask("Progress");
- };
+ {
+ _progressTask1 =
+ ctx.AddTask("Progress");
+ };
entropyCalculator.InitProgress2Event += () =>
- {
- _progressTask2 = ctx.AddTask("Progress");
- };
+ {
+ _progressTask2 =
+ ctx.AddTask("Progress");
+ };
entropyCalculator.UpdateProgressEvent += (text, current, maximum) =>
- {
- _progressTask1 ??= ctx.AddTask("Progress");
- _progressTask1.Description = Markup.Escape(text);
- _progressTask1.Value = current;
- _progressTask1.MaxValue = maximum;
- };
+ {
+ _progressTask1 ??=
+ ctx.AddTask("Progress");
+ _progressTask1.Description =
+ Markup.Escape(text);
+ _progressTask1.Value = current;
+ _progressTask1.MaxValue = maximum;
+ };
entropyCalculator.UpdateProgress2Event += (text, current, maximum) =>
- {
- _progressTask2 ??= ctx.AddTask("Progress");
- _progressTask2.Description = Markup.Escape(text);
- _progressTask2.Value = current;
- _progressTask2.MaxValue = maximum;
- };
+ {
+ _progressTask2 ??=
+ ctx.AddTask("Progress");
+ _progressTask2.Description =
+ Markup.Escape(text);
+ _progressTask2.Value = current;
+ _progressTask2.MaxValue = maximum;
+ };
entropyCalculator.EndProgressEvent += () =>
- {
- _progressTask1?.StopTask();
- _progressTask1 = null;
- };
+ {
+ _progressTask1?.StopTask();
+ _progressTask1 = null;
+ };
entropyCalculator.EndProgress2Event += () =>
- {
- _progressTask2?.StopTask();
- _progressTask2 = null;
- };
+ {
+ _progressTask2?.StopTask();
+ _progressTask2 = null;
+ };
if(wholeDisc && inputFormat is IOpticalMediaImage opticalFormat)
{
@@ -233,24 +234,31 @@ sealed class EntropyCommand : Command
trackEntropy.Entropy);
if(trackEntropy.UniqueSectors != null)
- AaruConsole.WriteLine(UI.Track_0_has_1_unique_sectors_2, trackEntropy.Track,
+ {
+ AaruConsole.WriteLine(UI.Track_0_has_1_unique_sectors_2,
+ trackEntropy.Track,
trackEntropy.UniqueSectors,
- (double)trackEntropy.UniqueSectors / trackEntropy.Sectors);
+ (double)trackEntropy.UniqueSectors /
+ trackEntropy.Sectors);
+ }
}
}
if(!wholeDisc)
return;
- EntropyResults entropy = inputFormat.Info.MetadataMediaType == MetadataMediaType.LinearMedia
- ? entropyCalculator.CalculateLinearMediaEntropy()
- : entropyCalculator.CalculateMediaEntropy(duplicatedSectors);
+ EntropyResults entropy =
+ inputFormat.Info.MetadataMediaType == MetadataMediaType.LinearMedia
+ ? entropyCalculator.CalculateLinearMediaEntropy()
+ : entropyCalculator.CalculateMediaEntropy(duplicatedSectors);
AaruConsole.WriteLine(UI.Entropy_for_disk_is_0, entropy.Entropy);
if(entropy.UniqueSectors != null)
+ {
AaruConsole.WriteLine(UI.Disk_has_0_unique_sectors_1, entropy.UniqueSectors,
(double)entropy.UniqueSectors / entropy.Sectors);
+ }
});
return (int)ErrorNumber.NoError;
diff --git a/Aaru/Commands/Image/Info.cs b/Aaru/Commands/Image/Info.cs
index a198a9426..c96ac5ae4 100644
--- a/Aaru/Commands/Image/Info.cs
+++ b/Aaru/Commands/Image/Info.cs
@@ -71,37 +71,39 @@ sealed class ImageInfoCommand : Command
});
AaruConsole.DebugWriteLineEvent += (format, objects) =>
- {
- if(objects is null)
- stderrConsole.MarkupLine(format);
- else
- stderrConsole.MarkupLine(format, objects);
- };
+ {
+ if(objects is null)
+ stderrConsole.MarkupLine(format);
+ else
+ stderrConsole.MarkupLine(format, objects);
+ };
}
if(verbose)
+ {
AaruConsole.WriteEvent += (format, objects) =>
- {
- if(objects is null)
- AnsiConsole.Markup(format);
- else
- AnsiConsole.Markup(format, objects);
- };
+ {
+ if(objects is null)
+ AnsiConsole.Markup(format);
+ else
+ AnsiConsole.Markup(format, objects);
+ };
+ }
Statistics.AddCommand("image-info");
- AaruConsole.DebugWriteLine(MODULE_NAME, "--debug={0}", debug);
- AaruConsole.DebugWriteLine(MODULE_NAME, "--input={0}", imagePath);
+ AaruConsole.DebugWriteLine(MODULE_NAME, "--debug={0}", debug);
+ AaruConsole.DebugWriteLine(MODULE_NAME, "--input={0}", imagePath);
AaruConsole.DebugWriteLine(MODULE_NAME, "--verbose={0}", verbose);
var filtersList = new FiltersList();
IFilter inputFilter = null;
Core.Spectre.ProgressSingleSpinner(ctx =>
- {
- ctx.AddTask(UI.Identifying_file_filter).IsIndeterminate();
- inputFilter = filtersList.GetFilter(imagePath);
- });
+ {
+ ctx.AddTask(UI.Identifying_file_filter).IsIndeterminate();
+ inputFilter = filtersList.GetFilter(imagePath);
+ });
if(inputFilter == null)
{
@@ -115,10 +117,10 @@ sealed class ImageInfoCommand : Command
IBaseImage imageFormat = null;
Core.Spectre.ProgressSingleSpinner(ctx =>
- {
- ctx.AddTask(UI.Identifying_image_format).IsIndeterminate();
- imageFormat = ImageFormat.Detect(inputFilter);
- });
+ {
+ ctx.AddTask(UI.Identifying_image_format).IsIndeterminate();
+ imageFormat = ImageFormat.Detect(inputFilter);
+ });
if(imageFormat == null)
{
@@ -135,10 +137,10 @@ sealed class ImageInfoCommand : Command
ErrorNumber opened = ErrorNumber.NoData;
Core.Spectre.ProgressSingleSpinner(ctx =>
- {
- ctx.AddTask(UI.Invoke_Opening_image_file).IsIndeterminate();
- opened = imageFormat.Open(inputFilter);
- });
+ {
+ ctx.AddTask(UI.Invoke_Opening_image_file).IsIndeterminate();
+ opened = imageFormat.Open(inputFilter);
+ });
if(opened != ErrorNumber.NoError)
{
diff --git a/Aaru/Commands/Image/Options.cs b/Aaru/Commands/Image/Options.cs
index 347a29792..9fa04e101 100644
--- a/Aaru/Commands/Image/Options.cs
+++ b/Aaru/Commands/Image/Options.cs
@@ -64,24 +64,26 @@ sealed class ListOptionsCommand : Command
});
AaruConsole.DebugWriteLineEvent += (format, objects) =>
- {
- if(objects is null)
- stderrConsole.MarkupLine(format);
- else
- stderrConsole.MarkupLine(format, objects);
- };
+ {
+ if(objects is null)
+ stderrConsole.MarkupLine(format);
+ else
+ stderrConsole.MarkupLine(format, objects);
+ };
}
if(verbose)
+ {
AaruConsole.WriteEvent += (format, objects) =>
- {
- if(objects is null)
- AnsiConsole.Markup(format);
- else
- AnsiConsole.Markup(format, objects);
- };
+ {
+ if(objects is null)
+ AnsiConsole.Markup(format);
+ else
+ AnsiConsole.Markup(format, objects);
+ };
+ }
- AaruConsole.DebugWriteLine(MODULE_NAME, "--debug={0}", debug);
+ AaruConsole.DebugWriteLine(MODULE_NAME, "--debug={0}", debug);
AaruConsole.DebugWriteLine(MODULE_NAME, "--verbose={0}", verbose);
Statistics.AddCommand("list-options");
@@ -94,7 +96,7 @@ sealed class ListOptionsCommand : Command
if(Activator.CreateInstance(kvp.Value) is not IBaseWritableImage plugin)
continue;
- List<(string name, Type type, string description, object @default)> options =
+ var options =
plugin.SupportedOptions.ToList();
if(options.Count == 0)
@@ -112,8 +114,10 @@ sealed class ListOptionsCommand : Command
foreach((string name, Type type, string description, object @default) option in
options.OrderBy(t => t.name))
+ {
table.AddRow(Markup.Escape(option.name), TypeToString(option.type), option.@default?.ToString() ?? "",
Markup.Escape(option.description));
+ }
AnsiConsole.Write(table);
AaruConsole.WriteLine();
diff --git a/Aaru/Commands/Image/Print.cs b/Aaru/Commands/Image/Print.cs
index ea4e79972..759aada2b 100644
--- a/Aaru/Commands/Image/Print.cs
+++ b/Aaru/Commands/Image/Print.cs
@@ -50,25 +50,13 @@ sealed class PrintHexCommand : Command
public PrintHexCommand() : base("print", UI.Image_Print_Command_Description)
{
- Add(new Option(new[]
- {
- "--length", "-l"
- }, () => 1, UI.How_many_sectors_to_print));
+ Add(new Option(new[] { "--length", "-l" }, () => 1, UI.How_many_sectors_to_print));
- Add(new Option(new[]
- {
- "--long-sectors", "-r"
- }, () => false, UI.Print_sectors_with_tags_included));
+ Add(new Option(new[] { "--long-sectors", "-r" }, () => false, UI.Print_sectors_with_tags_included));
- Add(new Option(new[]
- {
- "--start", "-s"
- }, UI.Starting_sector));
+ Add(new Option(new[] { "--start", "-s" }, UI.Starting_sector));
- Add(new Option(new[]
- {
- "--width", "-w"
- }, () => 32, UI.How_many_bytes_to_print_per_line));
+ Add(new Option(new[] { "--width", "-w" }, () => 32, UI.How_many_bytes_to_print_per_line));
AddArgument(new Argument
{
@@ -80,7 +68,7 @@ sealed class PrintHexCommand : Command
Handler = CommandHandler.Create(GetType().GetMethod(nameof(Invoke)));
}
- public static int Invoke(bool debug, bool verbose, string imagePath, ulong length, bool longSectors, ulong start,
+ public static int Invoke(bool debug, bool verbose, string imagePath, ulong length, bool longSectors, ulong start,
ushort width)
{
MainClass.PrintCopyright();
@@ -93,41 +81,43 @@ sealed class PrintHexCommand : Command
});
AaruConsole.DebugWriteLineEvent += (format, objects) =>
- {
- if(objects is null)
- stderrConsole.MarkupLine(format);
- else
- stderrConsole.MarkupLine(format, objects);
- };
+ {
+ if(objects is null)
+ stderrConsole.MarkupLine(format);
+ else
+ stderrConsole.MarkupLine(format, objects);
+ };
}
if(verbose)
+ {
AaruConsole.WriteEvent += (format, objects) =>
- {
- if(objects is null)
- AnsiConsole.Markup(format);
- else
- AnsiConsole.Markup(format, objects);
- };
+ {
+ if(objects is null)
+ AnsiConsole.Markup(format);
+ else
+ AnsiConsole.Markup(format, objects);
+ };
+ }
Statistics.AddCommand("print-hex");
- AaruConsole.DebugWriteLine(MODULE_NAME, "--debug={0}", debug);
- AaruConsole.DebugWriteLine(MODULE_NAME, "--input={0}", imagePath);
- AaruConsole.DebugWriteLine(MODULE_NAME, "--length={0}", length);
+ AaruConsole.DebugWriteLine(MODULE_NAME, "--debug={0}", debug);
+ AaruConsole.DebugWriteLine(MODULE_NAME, "--input={0}", imagePath);
+ AaruConsole.DebugWriteLine(MODULE_NAME, "--length={0}", length);
AaruConsole.DebugWriteLine(MODULE_NAME, "--long-sectors={0}", longSectors);
- AaruConsole.DebugWriteLine(MODULE_NAME, "--start={0}", start);
- AaruConsole.DebugWriteLine(MODULE_NAME, "--verbose={0}", verbose);
- AaruConsole.DebugWriteLine(MODULE_NAME, "--width={0}", width);
+ AaruConsole.DebugWriteLine(MODULE_NAME, "--start={0}", start);
+ AaruConsole.DebugWriteLine(MODULE_NAME, "--verbose={0}", verbose);
+ AaruConsole.DebugWriteLine(MODULE_NAME, "--width={0}", width);
var filtersList = new FiltersList();
IFilter inputFilter = null;
Core.Spectre.ProgressSingleSpinner(ctx =>
- {
- ctx.AddTask(UI.Identifying_file_filter).IsIndeterminate();
- inputFilter = filtersList.GetFilter(imagePath);
- });
+ {
+ ctx.AddTask(UI.Identifying_file_filter).IsIndeterminate();
+ inputFilter = filtersList.GetFilter(imagePath);
+ });
if(inputFilter == null)
{
@@ -139,10 +129,10 @@ sealed class PrintHexCommand : Command
IBaseImage inputFormat = null;
Core.Spectre.ProgressSingleSpinner(ctx =>
- {
- ctx.AddTask(UI.Identifying_image_format).IsIndeterminate();
- inputFormat = ImageFormat.Detect(inputFilter);
- });
+ {
+ ctx.AddTask(UI.Identifying_image_format).IsIndeterminate();
+ inputFormat = ImageFormat.Detect(inputFilter);
+ });
if(inputFormat == null)
{
@@ -154,10 +144,10 @@ sealed class PrintHexCommand : Command
ErrorNumber opened = ErrorNumber.NoData;
Core.Spectre.ProgressSingleSpinner(ctx =>
- {
- ctx.AddTask(UI.Invoke_Opening_image_file).IsIndeterminate();
- opened = inputFormat.Open(inputFilter);
- });
+ {
+ ctx.AddTask(UI.Invoke_Opening_image_file).IsIndeterminate();
+ opened = inputFormat.Open(inputFilter);
+ });
if(opened != ErrorNumber.NoError)
{
@@ -173,22 +163,23 @@ sealed class PrintHexCommand : Command
AaruConsole.WriteLine($"[bold][italic]{string.Format(UI.Start_0_as_in_sector_start, start)}[/][/]");
- byte[] data = new byte[length];
+ var data = new byte[length];
ErrorNumber errno = ErrorNumber.NoError;
- int bytesRead = 0;
+ var bytesRead = 0;
Core.Spectre.ProgressSingleSpinner(ctx =>
- {
- ctx.AddTask(UI.Reading_data).IsIndeterminate();
+ {
+ ctx.AddTask(UI.Reading_data).IsIndeterminate();
- errno = byteAddressableImage?.ReadBytesAt((long)start, data, 0, (int)length, out bytesRead) ??
- ErrorNumber.InvalidArgument;
- });
+ errno = byteAddressableImage?.ReadBytesAt((long)start, data, 0,
+ (int)length, out bytesRead) ??
+ ErrorNumber.InvalidArgument;
+ });
// TODO: Span
if(bytesRead != (int)length)
{
- byte[] tmp = new byte[bytesRead];
+ var tmp = new byte[bytesRead];
Array.Copy(data, 0, tmp, 0, bytesRead);
data = tmp;
}
@@ -199,6 +190,7 @@ sealed class PrintHexCommand : Command
AaruConsole.ErrorWriteLine(string.Format(UI.Error_0_reading_data_from_1, errno, start));
}
else
+ {
for(ulong i = 0; i < length; i++)
{
if(inputFormat is not IMediaImage blockImage)
@@ -231,18 +223,20 @@ sealed class PrintHexCommand : Command
ErrorNumber errno = ErrorNumber.NoError;
Core.Spectre.ProgressSingleSpinner(ctx =>
- {
- ctx.AddTask(UI.Reading_sector).IsIndeterminate();
+ {
+ ctx.AddTask(UI.Reading_sector).IsIndeterminate();
- errno = longSectors ? blockImage.ReadSectorLong(start + i, out sector)
- : blockImage.ReadSector(start + i, out sector);
- });
+ errno = longSectors
+ ? blockImage.ReadSectorLong(start + i, out sector)
+ : blockImage.ReadSector(start + i, out sector);
+ });
if(errno == ErrorNumber.NoError)
AaruConsole.WriteLine(Markup.Escape(PrintHex.ByteArrayToHexArrayString(sector, width, true)));
else
AaruConsole.ErrorWriteLine(string.Format(UI.Error_0_reading_sector_1, errno, start + i));
}
+ }
return (int)ErrorNumber.NoError;
}
diff --git a/Aaru/Commands/Image/Verify.cs b/Aaru/Commands/Image/Verify.cs
index a5d2a9a91..d06a06abc 100644
--- a/Aaru/Commands/Image/Verify.cs
+++ b/Aaru/Commands/Image/Verify.cs
@@ -55,25 +55,13 @@ sealed class VerifyCommand : Command
public VerifyCommand() : base("verify", UI.Image_Verify_Command_Description)
{
- Add(new Option(new[]
- {
- "--verify-disc", "-w"
- }, () => true, UI.Verify_media_image_if_supported));
+ Add(new Option(new[] { "--verify-disc", "-w" }, () => true, UI.Verify_media_image_if_supported));
- Add(new Option(new[]
- {
- "--verify-sectors", "-s"
- }, () => true, UI.Verify_all_sectors_if_supported));
+ Add(new Option(new[] { "--verify-sectors", "-s" }, () => true, UI.Verify_all_sectors_if_supported));
- Add(new Option(new[]
- {
- "--create-graph", "-g"
- }, () => true, UI.Create_graph_of_verified_disc));
+ Add(new Option(new[] { "--create-graph", "-g" }, () => true, UI.Create_graph_of_verified_disc));
- Add(new Option(new[]
- {
- "--dimensions"
- }, () => 1080, UI.Verify_dimensions_paramater_help));
+ Add(new Option(new[] { "--dimensions" }, () => 1080, UI.Verify_dimensions_paramater_help));
AddArgument(new Argument
{
@@ -85,7 +73,7 @@ sealed class VerifyCommand : Command
Handler = CommandHandler.Create(GetType().GetMethod(nameof(Invoke)));
}
- public static int Invoke(bool debug, bool verbose, string imagePath, bool verifyDisc, bool verifySectors,
+ public static int Invoke(bool debug, bool verbose, string imagePath, bool verifyDisc, bool verifySectors,
bool createGraph, uint dimensions)
{
MainClass.PrintCopyright();
@@ -98,41 +86,43 @@ sealed class VerifyCommand : Command
});
AaruConsole.DebugWriteLineEvent += (format, objects) =>
- {
- if(objects is null)
- stderrConsole.MarkupLine(format);
- else
- stderrConsole.MarkupLine(format, objects);
- };
+ {
+ if(objects is null)
+ stderrConsole.MarkupLine(format);
+ else
+ stderrConsole.MarkupLine(format, objects);
+ };
}
if(verbose)
+ {
AaruConsole.WriteEvent += (format, objects) =>
- {
- if(objects is null)
- AnsiConsole.Markup(format);
- else
- AnsiConsole.Markup(format, objects);
- };
+ {
+ if(objects is null)
+ AnsiConsole.Markup(format);
+ else
+ AnsiConsole.Markup(format, objects);
+ };
+ }
Statistics.AddCommand("verify");
- AaruConsole.DebugWriteLine(MODULE_NAME, "--debug={0}", debug);
- AaruConsole.DebugWriteLine(MODULE_NAME, "--input={0}", imagePath);
- AaruConsole.DebugWriteLine(MODULE_NAME, "--verbose={0}", verbose);
- AaruConsole.DebugWriteLine(MODULE_NAME, "--verify-disc={0}", verifyDisc);
+ AaruConsole.DebugWriteLine(MODULE_NAME, "--debug={0}", debug);
+ AaruConsole.DebugWriteLine(MODULE_NAME, "--input={0}", imagePath);
+ AaruConsole.DebugWriteLine(MODULE_NAME, "--verbose={0}", verbose);
+ AaruConsole.DebugWriteLine(MODULE_NAME, "--verify-disc={0}", verifyDisc);
AaruConsole.DebugWriteLine(MODULE_NAME, "--verify-sectors={0}", verifySectors);
- AaruConsole.DebugWriteLine(MODULE_NAME, "--create-graph={0}", createGraph);
- AaruConsole.DebugWriteLine(MODULE_NAME, "--dimensions={0}", dimensions);
+ AaruConsole.DebugWriteLine(MODULE_NAME, "--create-graph={0}", createGraph);
+ AaruConsole.DebugWriteLine(MODULE_NAME, "--dimensions={0}", dimensions);
var filtersList = new FiltersList();
IFilter inputFilter = null;
Core.Spectre.ProgressSingleSpinner(ctx =>
- {
- ctx.AddTask(UI.Identifying_file_filter).IsIndeterminate();
- inputFilter = filtersList.GetFilter(imagePath);
- });
+ {
+ ctx.AddTask(UI.Identifying_file_filter).IsIndeterminate();
+ inputFilter = filtersList.GetFilter(imagePath);
+ });
if(inputFilter == null)
{
@@ -144,10 +134,10 @@ sealed class VerifyCommand : Command
IBaseImage inputFormat = null;
Core.Spectre.ProgressSingleSpinner(ctx =>
- {
- ctx.AddTask(UI.Identifying_image_format).IsIndeterminate();
- inputFormat = ImageFormat.Detect(inputFilter);
- });
+ {
+ ctx.AddTask(UI.Identifying_image_format).IsIndeterminate();
+ inputFormat = ImageFormat.Detect(inputFilter);
+ });
if(inputFormat == null)
{
@@ -159,10 +149,10 @@ sealed class VerifyCommand : Command
ErrorNumber opened = ErrorNumber.NoData;
Core.Spectre.ProgressSingleSpinner(ctx =>
- {
- ctx.AddTask(UI.Invoke_Opening_image_file).IsIndeterminate();
- opened = inputFormat.Open(inputFilter);
- });
+ {
+ ctx.AddTask(UI.Invoke_Opening_image_file).IsIndeterminate();
+ opened = inputFormat.Open(inputFilter);
+ });
if(opened != ErrorNumber.NoError)
{
@@ -197,13 +187,13 @@ sealed class VerifyCommand : Command
bool? discCheckStatus = null;
Core.Spectre.ProgressSingleSpinner(ctx =>
- {
- ctx.AddTask(UI.Verifying_image_checksums).IsIndeterminate();
+ {
+ ctx.AddTask(UI.Verifying_image_checksums).IsIndeterminate();
- chkWatch.Start();
- discCheckStatus = verifiableImage.VerifyMediaImage();
- chkWatch.Stop();
- });
+ chkWatch.Start();
+ discCheckStatus = verifiableImage.VerifyMediaImage();
+ chkWatch.Stop();
+ });
switch(discCheckStatus)
{
@@ -228,19 +218,21 @@ sealed class VerifyCommand : Command
}
if(!verifySectors)
+ {
return correctImage switch
- {
- null => (int)ErrorNumber.NotVerifiable,
- false => (int)ErrorNumber.BadImageSectorsNotVerified,
- true => (int)ErrorNumber.CorrectImageSectorsNotVerified
- };
+ {
+ null => (int)ErrorNumber.NotVerifiable,
+ false => (int)ErrorNumber.BadImageSectorsNotVerified,
+ true => (int)ErrorNumber.CorrectImageSectorsNotVerified
+ };
+ }
var stopwatch = new Stopwatch();
List failingLbas = new();
List unknownLbas = new();
IMediaGraph mediaGraph = null;
- if(verifiableSectorsImage is IOpticalMediaImage { Tracks: {} } opticalMediaImage)
+ if(verifiableSectorsImage is IOpticalMediaImage { Tracks: not null } opticalMediaImage)
{
Spiral.DiscParameters spiralParameters = null;
@@ -248,8 +240,10 @@ sealed class VerifyCommand : Command
spiralParameters = Spiral.DiscParametersFromMediaType(opticalMediaImage.Info.MediaType);
if(spiralParameters is not null)
+ {
mediaGraph = new Spiral((int)dimensions, (int)dimensions, spiralParameters,
opticalMediaImage.Info.Sectors);
+ }
else if(createGraph)
mediaGraph = new BlockMap((int)dimensions, (int)dimensions, opticalMediaImage.Info.Sectors);
@@ -261,88 +255,96 @@ sealed class VerifyCommand : Command
AnsiConsole.Progress().AutoClear(true).HideCompleted(true).
Columns(new TaskDescriptionColumn(), new ProgressBarColumn(), new PercentageColumn()).
Start(ctx =>
- {
- ProgressTask discTask = ctx.AddTask(UI.Checking_tracks);
- discTask.MaxValue = inputTracks.Count;
+ {
+ ProgressTask discTask = ctx.AddTask(UI.Checking_tracks);
+ discTask.MaxValue = inputTracks.Count;
- foreach(Track currentTrack in inputTracks)
- {
- discTask.Description =
- string.Format(UI.Checking_track_0_of_1, discTask.Value + 1, inputTracks.Count);
+ foreach(Track currentTrack in inputTracks)
+ {
+ discTask.Description =
+ string.Format(UI.Checking_track_0_of_1, discTask.Value + 1,
+ inputTracks.Count);
- ulong remainingSectors = currentTrack.EndSector - currentTrack.StartSector + 1;
+ ulong remainingSectors = currentTrack.EndSector - currentTrack.StartSector + 1;
- ulong currentSector = 0;
+ ulong currentSector = 0;
- ProgressTask trackTask = ctx.AddTask(UI.Checking_sector);
- trackTask.MaxValue = remainingSectors;
+ ProgressTask trackTask = ctx.AddTask(UI.Checking_sector);
+ trackTask.MaxValue = remainingSectors;
- while(remainingSectors > 0)
- {
- trackTask.Description =
- string.Format(UI.Checking_sector_0_of_1_on_track_2, currentSectorAll,
- inputFormat.Info.Sectors, currentTrack.Sequence);
+ while(remainingSectors > 0)
+ {
+ trackTask.Description =
+ string.Format(UI.Checking_sector_0_of_1_on_track_2, currentSectorAll,
+ inputFormat.Info.Sectors, currentTrack.Sequence);
- List tempFailingLbas;
- List tempUnknownLbas;
+ List tempFailingLbas;
+ List tempUnknownLbas;
- if(remainingSectors < 512)
- opticalMediaImage.VerifySectors(currentSector, (uint)remainingSectors,
- currentTrack.Sequence, out tempFailingLbas,
- out tempUnknownLbas);
- else
- opticalMediaImage.VerifySectors(currentSector, 512, currentTrack.Sequence,
- out tempFailingLbas, out tempUnknownLbas);
+ if(remainingSectors < 512)
+ {
+ opticalMediaImage.VerifySectors(currentSector, (uint)remainingSectors,
+ currentTrack.Sequence,
+ out tempFailingLbas,
+ out tempUnknownLbas);
+ }
+ else
+ {
+ opticalMediaImage.VerifySectors(currentSector, 512, currentTrack.Sequence,
+ out tempFailingLbas, out tempUnknownLbas);
+ }
- if(mediaGraph != null)
- {
- List tempCorrectLbas = new();
+ if(mediaGraph != null)
+ {
+ List tempCorrectLbas = new();
- for(ulong l = 0; l < (remainingSectors < 512 ? remainingSectors : 512); l++)
- tempCorrectLbas.Add(currentSector + l);
+ for(ulong l = 0;
+ l < (remainingSectors < 512 ? remainingSectors : 512);
+ l++)
+ tempCorrectLbas.Add(currentSector + l);
- foreach(ulong f in tempFailingLbas)
- tempCorrectLbas.Remove(f);
+ foreach(ulong f in tempFailingLbas)
+ tempCorrectLbas.Remove(f);
- foreach(ulong u in tempUnknownLbas)
- {
- tempCorrectLbas.Remove(u);
- mediaGraph.PaintSectorUnknown(currentTrack.StartSector + u);
- }
+ foreach(ulong u in tempUnknownLbas)
+ {
+ tempCorrectLbas.Remove(u);
+ mediaGraph.PaintSectorUnknown(currentTrack.StartSector + u);
+ }
- foreach(ulong lba in tempCorrectLbas)
- mediaGraph.PaintSectorGood(currentTrack.StartSector + lba);
+ foreach(ulong lba in tempCorrectLbas)
+ mediaGraph.PaintSectorGood(currentTrack.StartSector + lba);
- foreach(ulong f in tempFailingLbas)
- mediaGraph.PaintSectorBad(currentTrack.StartSector + f);
- }
+ foreach(ulong f in tempFailingLbas)
+ mediaGraph.PaintSectorBad(currentTrack.StartSector + f);
+ }
- failingLbas.AddRange(tempFailingLbas);
+ failingLbas.AddRange(tempFailingLbas);
- unknownLbas.AddRange(tempUnknownLbas);
+ unknownLbas.AddRange(tempUnknownLbas);
- if(remainingSectors < 512)
- {
- currentSector += remainingSectors;
- currentSectorAll += remainingSectors;
- trackTask.Value += remainingSectors;
- remainingSectors = 0;
- }
- else
- {
- currentSector += 512;
- currentSectorAll += 512;
- trackTask.Value += 512;
- remainingSectors -= 512;
- }
- }
+ if(remainingSectors < 512)
+ {
+ currentSector += remainingSectors;
+ currentSectorAll += remainingSectors;
+ trackTask.Value += remainingSectors;
+ remainingSectors = 0;
+ }
+ else
+ {
+ currentSector += 512;
+ currentSectorAll += 512;
+ trackTask.Value += 512;
+ remainingSectors -= 512;
+ }
+ }
- trackTask.StopTask();
- discTask.Increment(1);
- }
+ trackTask.StopTask();
+ discTask.Increment(1);
+ }
- stopwatch.Stop();
- });
+ stopwatch.Stop();
+ });
}
else if(verifiableSectorsImage != null)
{
@@ -352,65 +354,71 @@ sealed class VerifyCommand : Command
AnsiConsole.Progress().AutoClear(true).HideCompleted(true).
Columns(new TaskDescriptionColumn(), new ProgressBarColumn(), new PercentageColumn()).
Start(ctx =>
- {
- ProgressTask diskTask = ctx.AddTask(UI.Checking_sectors);
- diskTask.MaxValue = inputFormat.Info.Sectors;
+ {
+ ProgressTask diskTask = ctx.AddTask(UI.Checking_sectors);
+ diskTask.MaxValue = inputFormat.Info.Sectors;
- stopwatch.Restart();
+ stopwatch.Restart();
- while(remainingSectors > 0)
- {
- diskTask.Description =
- string.Format(UI.Checking_sector_0_of_1, currentSector, inputFormat.Info.Sectors);
+ while(remainingSectors > 0)
+ {
+ diskTask.Description =
+ string.Format(UI.Checking_sector_0_of_1, currentSector,
+ inputFormat.Info.Sectors);
- List tempFailingLbas;
- List tempUnknownLbas;
+ List tempFailingLbas;
+ List tempUnknownLbas;
- if(remainingSectors < 512)
- verifiableSectorsImage.VerifySectors(currentSector, (uint)remainingSectors,
- out tempFailingLbas, out tempUnknownLbas);
- else
- verifiableSectorsImage.VerifySectors(currentSector, 512, out tempFailingLbas,
- out tempUnknownLbas);
+ if(remainingSectors < 512)
+ {
+ verifiableSectorsImage.VerifySectors(currentSector, (uint)remainingSectors,
+ out tempFailingLbas,
+ out tempUnknownLbas);
+ }
+ else
+ {
+ verifiableSectorsImage.VerifySectors(currentSector, 512, out tempFailingLbas,
+ out tempUnknownLbas);
+ }
- failingLbas.AddRange(tempFailingLbas);
+ failingLbas.AddRange(tempFailingLbas);
- unknownLbas.AddRange(tempUnknownLbas);
+ unknownLbas.AddRange(tempUnknownLbas);
- if(mediaGraph != null)
- {
- List tempCorrectLbas = new();
+ if(mediaGraph != null)
+ {
+ List tempCorrectLbas = new();
- for(ulong l = 0; l < (remainingSectors < 512 ? remainingSectors : 512); l++)
- tempCorrectLbas.Add(currentSector + l);
+ for(ulong l = 0; l < (remainingSectors < 512 ? remainingSectors : 512); l++)
+ tempCorrectLbas.Add(currentSector + l);
- foreach(ulong f in tempFailingLbas)
- tempCorrectLbas.Remove(f);
+ foreach(ulong f in tempFailingLbas)
+ tempCorrectLbas.Remove(f);
- foreach(ulong u in tempUnknownLbas)
- tempCorrectLbas.Remove(u);
+ foreach(ulong u in tempUnknownLbas)
+ tempCorrectLbas.Remove(u);
- mediaGraph.PaintSectorsUnknown(tempUnknownLbas);
- mediaGraph.PaintSectorsGood(tempCorrectLbas);
- mediaGraph.PaintSectorsBad(tempFailingLbas);
- }
+ mediaGraph.PaintSectorsUnknown(tempUnknownLbas);
+ mediaGraph.PaintSectorsGood(tempCorrectLbas);
+ mediaGraph.PaintSectorsBad(tempFailingLbas);
+ }
- if(remainingSectors < 512)
- {
- currentSector += remainingSectors;
- diskTask.Value += remainingSectors;
- remainingSectors = 0;
- }
- else
- {
- currentSector += 512;
- diskTask.Value += 512;
- remainingSectors -= 512;
- }
- }
+ if(remainingSectors < 512)
+ {
+ currentSector += remainingSectors;
+ diskTask.Value += remainingSectors;
+ remainingSectors = 0;
+ }
+ else
+ {
+ currentSector += 512;
+ diskTask.Value += 512;
+ remainingSectors -= 512;
+ }
+ }
- stopwatch.Stop();
- });
+ stopwatch.Stop();
+ });
}
if(unknownLbas.Count > 0)
@@ -433,16 +441,20 @@ sealed class VerifyCommand : Command
if(failingLbas.Count == (int)inputFormat.Info.Sectors)
AaruConsole.VerboseWriteLine($"\t[red]{UI.all_sectors}[/]");
else
+ {
foreach(ulong t in failingLbas)
AaruConsole.VerboseWriteLine("\t{0}", t);
+ }
AaruConsole.WriteLine($"[yellow3_1]{UI.LBAs_without_checksum}[/]");
if(unknownLbas.Count == (int)inputFormat.Info.Sectors)
AaruConsole.VerboseWriteLine($"\t[yellow3_1]{UI.all_sectors}[/]");
else
+ {
foreach(ulong t in unknownLbas)
AaruConsole.VerboseWriteLine("\t{0}", t);
+ }
}
// TODO: Convert to table
@@ -459,16 +471,16 @@ sealed class VerifyCommand : Command
correctSectors = true;
return correctImage switch
- {
- null when correctSectors is null => (int)ErrorNumber.NotVerifiable,
- null when correctSectors == false => (int)ErrorNumber.BadSectorsImageNotVerified,
- null => (int)ErrorNumber.CorrectSectorsImageNotVerified,
- false when correctSectors is null => (int)ErrorNumber.BadImageSectorsNotVerified,
- false when correctSectors == false => (int)ErrorNumber.BadImageBadSectors,
- false => (int)ErrorNumber.CorrectSectorsBadImage,
- true when correctSectors is null => (int)ErrorNumber.CorrectImageSectorsNotVerified,
- true when correctSectors == false => (int)ErrorNumber.CorrectImageBadSectors,
- true => (int)ErrorNumber.NoError
- };
+ {
+ null when correctSectors is null => (int)ErrorNumber.NotVerifiable,
+ null when correctSectors == false => (int)ErrorNumber.BadSectorsImageNotVerified,
+ null => (int)ErrorNumber.CorrectSectorsImageNotVerified,
+ false when correctSectors is null => (int)ErrorNumber.BadImageSectorsNotVerified,
+ false when correctSectors == false => (int)ErrorNumber.BadImageBadSectors,
+ false => (int)ErrorNumber.CorrectSectorsBadImage,
+ true when correctSectors is null => (int)ErrorNumber.CorrectImageSectorsNotVerified,
+ true when correctSectors == false => (int)ErrorNumber.CorrectImageBadSectors,
+ true => (int)ErrorNumber.NoError
+ };
}
}
\ No newline at end of file
diff --git a/Aaru/Commands/ListEncodings.cs b/Aaru/Commands/ListEncodings.cs
index b29f7bf54..fabf57927 100644
--- a/Aaru/Commands/ListEncodings.cs
+++ b/Aaru/Commands/ListEncodings.cs
@@ -30,7 +30,6 @@
// Copyright © 2011-2023 Natalia Portillo
// ****************************************************************************/
-using System.Collections.Generic;
using System.CommandLine;
using System.CommandLine.NamingConventionBinder;
using System.Linq;
@@ -62,29 +61,31 @@ sealed class ListEncodingsCommand : Command
});
AaruConsole.DebugWriteLineEvent += (format, objects) =>
- {
- if(objects is null)
- stderrConsole.MarkupLine(format);
- else
- stderrConsole.MarkupLine(format, objects);
- };
+ {
+ if(objects is null)
+ stderrConsole.MarkupLine(format);
+ else
+ stderrConsole.MarkupLine(format, objects);
+ };
}
if(verbose)
+ {
AaruConsole.WriteEvent += (format, objects) =>
- {
- if(objects is null)
- AnsiConsole.Markup(format);
- else
- AnsiConsole.Markup(format, objects);
- };
+ {
+ if(objects is null)
+ AnsiConsole.Markup(format);
+ else
+ AnsiConsole.Markup(format, objects);
+ };
+ }
Statistics.AddCommand("list-encodings");
- AaruConsole.DebugWriteLine(MODULE_NAME, "--debug={0}", debug);
+ AaruConsole.DebugWriteLine(MODULE_NAME, "--debug={0}", debug);
AaruConsole.DebugWriteLine(MODULE_NAME, "--verbose={0}", verbose);
- List encodings = Encoding.GetEncodings().Select(info => new CommonEncodingInfo
+ var encodings = Encoding.GetEncodings().Select(info => new CommonEncodingInfo
{
Name = info.Name,
DisplayName = info.GetEncoding().EncodingName
@@ -108,9 +109,13 @@ sealed class ListEncodingsCommand : Command
return (int)ErrorNumber.NoError;
}
+#region Nested type: CommonEncodingInfo
+
struct CommonEncodingInfo
{
public string Name;
public string DisplayName;
}
+
+#endregion
}
\ No newline at end of file
diff --git a/Aaru/Commands/ListNamespaces.cs b/Aaru/Commands/ListNamespaces.cs
index be3e0375d..a5445e6a1 100644
--- a/Aaru/Commands/ListNamespaces.cs
+++ b/Aaru/Commands/ListNamespaces.cs
@@ -63,24 +63,26 @@ sealed class ListNamespacesCommand : Command
});
AaruConsole.DebugWriteLineEvent += (format, objects) =>
- {
- if(objects is null)
- stderrConsole.MarkupLine(format);
- else
- stderrConsole.MarkupLine(format, objects);
- };
+ {
+ if(objects is null)
+ stderrConsole.MarkupLine(format);
+ else
+ stderrConsole.MarkupLine(format, objects);
+ };
}
if(verbose)
+ {
AaruConsole.WriteEvent += (format, objects) =>
- {
- if(objects is null)
- AnsiConsole.Markup(format);
- else
- AnsiConsole.Markup(format, objects);
- };
+ {
+ if(objects is null)
+ AnsiConsole.Markup(format);
+ else
+ AnsiConsole.Markup(format, objects);
+ };
+ }
- AaruConsole.DebugWriteLine(MODULE_NAME, "--debug={0}", debug);
+ AaruConsole.DebugWriteLine(MODULE_NAME, "--debug={0}", debug);
AaruConsole.DebugWriteLine(MODULE_NAME, "--verbose={0}", verbose);
Statistics.AddCommand("list-namespaces");
diff --git a/Aaru/Commands/Media/Dump.cs b/Aaru/Commands/Media/Dump.cs
index e04a3171b..a0a802d46 100644
--- a/Aaru/Commands/Media/Dump.cs
+++ b/Aaru/Commands/Media/Dump.cs
@@ -71,60 +71,37 @@ sealed class DumpMediaCommand : Command
public DumpMediaCommand() : base("dump", UI.Media_Dump_Command_Description)
{
- Add(new Option(new[]
- {
- "--cicm-xml", "-x"
- }, () => null, UI.Take_metadata_from_existing_CICM_XML_sidecar));
+ Add(new Option(new[] { "--cicm-xml", "-x" }, () => null,
+ UI.Take_metadata_from_existing_CICM_XML_sidecar));
- Add(new Option(new[]
- {
- "--encoding", "-e"
- }, () => null, UI.Name_of_character_encoding_to_use));
+ Add(new Option(new[] { "--encoding", "-e" }, () => null, UI.Name_of_character_encoding_to_use));
Add(new Option("--first-pregap", () => false, UI.Try_to_read_first_track_pregap));
Add(new Option("--fix-offset", () => true, UI.Fix_audio_tracks_offset));
- Add(new Option(new[]
- {
- "--force", "-f"
- }, () => false, UI.Continue_dumping_whatever_happens));
+ Add(new Option(new[] { "--force", "-f" }, () => false, UI.Continue_dumping_whatever_happens));
- Add(new Option(new[]
- {
- "--format", "-t"
- }, () => null, UI.Format_of_the_output_image_as_plugin_name_or_plugin_id));
+ Add(new Option(new[] { "--format", "-t" }, () => null,
+ UI.Format_of_the_output_image_as_plugin_name_or_plugin_id));
Add(new Option("--metadata", () => true, UI.Enables_creating_Aaru_Metadata_sidecar));
Add(new Option("--trim", () => true, UI.Enables_trimming_errored_from_skipped_sectors));
- Add(new Option(new[]
- {
- "--options", "-O"
- }, () => null, UI.Comma_separated_name_value_pairs_of_image_options));
+ Add(new Option(new[] { "--options", "-O" }, () => null,
+ UI.Comma_separated_name_value_pairs_of_image_options));
Add(new Option("--persistent", () => false, UI.Try_to_recover_partial_or_incorrect_data));
- Add(new Option(new[]
- {
- "--resume", "-r"
- }, () => true, UI.Create_or_use_resume_mapfile));
+ Add(new Option(new[] { "--resume", "-r" }, () => true, UI.Create_or_use_resume_mapfile));
- Add(new Option(new[]
- {
- "--retry-passes", "-p"
- }, () => 5, UI.How_many_retry_passes_to_do));
+ Add(new Option(new[] { "--retry-passes", "-p" }, () => 5, UI.How_many_retry_passes_to_do));
- Add(new Option(new[]
- {
- "--skip", "-k"
- }, () => 512, UI.When_an_unreadable_sector_is_found_skip_this_many_sectors));
+ Add(new Option(new[] { "--skip", "-k" }, () => 512,
+ UI.When_an_unreadable_sector_is_found_skip_this_many_sectors));
- Add(new Option(new[]
- {
- "--stop-on-error", "-s"
- }, () => false, UI.Stop_media_dump_on_first_error));
+ Add(new Option(new[] { "--stop-on-error", "-s" }, () => false, UI.Stop_media_dump_on_first_error));
Add(new Option("--subchannel", () => UI.Subchannel_name_any, UI.Subchannel_to_dump_help));
@@ -144,85 +121,40 @@ sealed class DumpMediaCommand : Command
Name = "output-path"
});
- Add(new Option(new[]
- {
- "--private"
- }, () => false, UI.Do_not_store_paths_and_serial_numbers_in_log_or_metadata));
+ Add(new Option(new[] { "--private" }, () => false,
+ UI.Do_not_store_paths_and_serial_numbers_in_log_or_metadata));
- Add(new Option(new[]
- {
- "--fix-subchannel-position"
- }, () => true, UI.Fix_subchannel_position_help));
+ Add(new Option(new[] { "--fix-subchannel-position" }, () => true, UI.Fix_subchannel_position_help));
- Add(new Option(new[]
- {
- "--retry-subchannel"
- }, () => true, UI.Retry_subchannel_help));
+ Add(new Option(new[] { "--retry-subchannel" }, () => true, UI.Retry_subchannel_help));
- Add(new Option(new[]
- {
- "--fix-subchannel"
- }, () => false, UI.Fix_subchannel_help));
+ Add(new Option(new[] { "--fix-subchannel" }, () => false, UI.Fix_subchannel_help));
- Add(new Option(new[]
- {
- "--fix-subchannel-crc"
- }, () => false, UI.Fix_subchannel_crc_help));
+ Add(new Option(new[] { "--fix-subchannel-crc" }, () => false, UI.Fix_subchannel_crc_help));
- Add(new Option(new[]
- {
- "--generate-subchannels"
- }, () => false, UI.Generate_subchannels_dump_help));
+ Add(new Option(new[] { "--generate-subchannels" }, () => false, UI.Generate_subchannels_dump_help));
- Add(new Option(new[]
- {
- "--skip-cdiready-hole"
- }, () => true, UI.Skip_CDi_Ready_hole_help));
+ Add(new Option(new[] { "--skip-cdiready-hole" }, () => true, UI.Skip_CDi_Ready_hole_help));
- Add(new Option(new[]
- {
- "--eject"
- }, () => false, UI.Eject_media_after_dump_finishes));
+ Add(new Option(new[] { "--eject" }, () => false, UI.Eject_media_after_dump_finishes));
- Add(new Option(new[]
- {
- "--max-blocks"
- }, () => 64, UI.Maximum_number_of_blocks_to_read_at_once));
+ Add(new Option(new[] { "--max-blocks" }, () => 64, UI.Maximum_number_of_blocks_to_read_at_once));
- Add(new Option(new[]
- {
- "--use-buffered-reads"
- }, () => true, UI.OS_buffered_reads_help));
+ Add(new Option(new[] { "--use-buffered-reads" }, () => true, UI.OS_buffered_reads_help));
- Add(new Option(new[]
- {
- "--store-encrypted"
- }, () => true, UI.Store_encrypted_data_as_is));
+ Add(new Option(new[] { "--store-encrypted" }, () => true, UI.Store_encrypted_data_as_is));
- Add(new Option(new[]
- {
- "--title-keys"
- }, () => true, UI.Try_to_read_the_title_keys_from_CSS_DVDs));
+ Add(new Option(new[] { "--title-keys" }, () => true, UI.Try_to_read_the_title_keys_from_CSS_DVDs));
- Add(new Option(new[]
- {
- "--ignore-cdr-runouts"
- }, () => 10, UI.How_many_CDRW_run_out_sectors_to_ignore_and_regenerate));
+ Add(new Option(new[] { "--ignore-cdr-runouts" }, () => 10,
+ UI.How_many_CDRW_run_out_sectors_to_ignore_and_regenerate));
- Add(new Option(new[]
- {
- "--create-graph", "-g"
- }, () => true, UI.Create_graph_of_dumped_media));
+ Add(new Option(new[] { "--create-graph", "-g" }, () => true, UI.Create_graph_of_dumped_media));
- Add(new Option(new[]
- {
- "--dimensions"
- }, () => 1080, UI.Dump_graph_dimensions_argument_help));
+ Add(new Option(new[] { "--dimensions" }, () => 1080, UI.Dump_graph_dimensions_argument_help));
- Add(new Option(new[]
- {
- "--aaru-metadata", "-m"
- }, () => null, "Take metadata from existing Aaru Metadata sidecar."));
+ Add(new Option(new[] { "--aaru-metadata", "-m" }, () => null,
+ "Take metadata from existing Aaru Metadata sidecar."));
Handler = CommandHandler.Create(GetType().GetMethod(nameof(Invoke)));
}
@@ -246,22 +178,24 @@ sealed class DumpMediaCommand : Command
});
AaruConsole.DebugWriteLineEvent += (format, objects) =>
- {
- if(objects is null)
- stderrConsole.MarkupLine(format);
- else
- stderrConsole.MarkupLine(format, objects);
- };
+ {
+ if(objects is null)
+ stderrConsole.MarkupLine(format);
+ else
+ stderrConsole.MarkupLine(format, objects);
+ };
}
if(verbose)
+ {
AaruConsole.WriteEvent += (format, objects) =>
- {
- if(objects is null)
- AnsiConsole.Markup(format);
- else
- AnsiConsole.Markup(format, objects);
- };
+ {
+ if(objects is null)
+ AnsiConsole.Markup(format);
+ else
+ AnsiConsole.Markup(format, objects);
+ };
+ }
fixSubchannel |= fixSubchannelCrc;
fixSubchannelPosition |= retrySubchannel || fixSubchannel;
@@ -271,41 +205,41 @@ sealed class DumpMediaCommand : Command
Statistics.AddCommand("dump-media");
- AaruConsole.DebugWriteLine(MODULE_NAME, "--cicm-xml={0}", cicmXml);
- AaruConsole.DebugWriteLine(MODULE_NAME, "--debug={0}", debug);
- AaruConsole.DebugWriteLine(MODULE_NAME, "--device={0}", devicePath);
- AaruConsole.DebugWriteLine(MODULE_NAME, "--encoding={0}", encoding);
- AaruConsole.DebugWriteLine(MODULE_NAME, "--first-pregap={0}", firstPregap);
- AaruConsole.DebugWriteLine(MODULE_NAME, "--fix-offset={0}", fixOffset);
- AaruConsole.DebugWriteLine(MODULE_NAME, "--force={0}", force);
- AaruConsole.DebugWriteLine(MODULE_NAME, "--format={0}", format);
- AaruConsole.DebugWriteLine(MODULE_NAME, "--metadata={0}", metadata);
- AaruConsole.DebugWriteLine(MODULE_NAME, "--options={0}", options);
- AaruConsole.DebugWriteLine(MODULE_NAME, "--output={0}", outputPath);
- AaruConsole.DebugWriteLine(MODULE_NAME, "--persistent={0}", persistent);
- AaruConsole.DebugWriteLine(MODULE_NAME, "--resume={0}", resume);
- AaruConsole.DebugWriteLine(MODULE_NAME, "--retry-passes={0}", retryPasses);
- AaruConsole.DebugWriteLine(MODULE_NAME, "--skip={0}", skip);
- AaruConsole.DebugWriteLine(MODULE_NAME, "--stop-on-error={0}", stopOnError);
- AaruConsole.DebugWriteLine(MODULE_NAME, "--trim={0}", trim);
- AaruConsole.DebugWriteLine(MODULE_NAME, "--verbose={0}", verbose);
- AaruConsole.DebugWriteLine(MODULE_NAME, "--subchannel={0}", subchannel);
- AaruConsole.DebugWriteLine(MODULE_NAME, "--private={0}", @private);
+ AaruConsole.DebugWriteLine(MODULE_NAME, "--cicm-xml={0}", cicmXml);
+ AaruConsole.DebugWriteLine(MODULE_NAME, "--debug={0}", debug);
+ AaruConsole.DebugWriteLine(MODULE_NAME, "--device={0}", devicePath);
+ AaruConsole.DebugWriteLine(MODULE_NAME, "--encoding={0}", encoding);
+ AaruConsole.DebugWriteLine(MODULE_NAME, "--first-pregap={0}", firstPregap);
+ AaruConsole.DebugWriteLine(MODULE_NAME, "--fix-offset={0}", fixOffset);
+ AaruConsole.DebugWriteLine(MODULE_NAME, "--force={0}", force);
+ AaruConsole.DebugWriteLine(MODULE_NAME, "--format={0}", format);
+ AaruConsole.DebugWriteLine(MODULE_NAME, "--metadata={0}", metadata);
+ AaruConsole.DebugWriteLine(MODULE_NAME, "--options={0}", options);
+ AaruConsole.DebugWriteLine(MODULE_NAME, "--output={0}", outputPath);
+ AaruConsole.DebugWriteLine(MODULE_NAME, "--persistent={0}", persistent);
+ AaruConsole.DebugWriteLine(MODULE_NAME, "--resume={0}", resume);
+ AaruConsole.DebugWriteLine(MODULE_NAME, "--retry-passes={0}", retryPasses);
+ AaruConsole.DebugWriteLine(MODULE_NAME, "--skip={0}", skip);
+ AaruConsole.DebugWriteLine(MODULE_NAME, "--stop-on-error={0}", stopOnError);
+ AaruConsole.DebugWriteLine(MODULE_NAME, "--trim={0}", trim);
+ AaruConsole.DebugWriteLine(MODULE_NAME, "--verbose={0}", verbose);
+ AaruConsole.DebugWriteLine(MODULE_NAME, "--subchannel={0}", subchannel);
+ AaruConsole.DebugWriteLine(MODULE_NAME, "--private={0}", @private);
AaruConsole.DebugWriteLine(MODULE_NAME, "--fix-subchannel-position={0}", fixSubchannelPosition);
- AaruConsole.DebugWriteLine(MODULE_NAME, "--retry-subchannel={0}", retrySubchannel);
- AaruConsole.DebugWriteLine(MODULE_NAME, "--fix-subchannel={0}", fixSubchannel);
- AaruConsole.DebugWriteLine(MODULE_NAME, "--fix-subchannel-crc={0}", fixSubchannelCrc);
- AaruConsole.DebugWriteLine(MODULE_NAME, "--generate-subchannels={0}", generateSubchannels);
- AaruConsole.DebugWriteLine(MODULE_NAME, "--skip-cdiready-hole={0}", skipCdiReadyHole);
- AaruConsole.DebugWriteLine(MODULE_NAME, "--eject={0}", eject);
- AaruConsole.DebugWriteLine(MODULE_NAME, "--max-blocks={0}", maxBlocks);
- AaruConsole.DebugWriteLine(MODULE_NAME, "--use-buffered-reads={0}", useBufferedReads);
- AaruConsole.DebugWriteLine(MODULE_NAME, "--store-encrypted={0}", storeEncrypted);
- AaruConsole.DebugWriteLine(MODULE_NAME, "--title-keys={0}", titleKeys);
- AaruConsole.DebugWriteLine(MODULE_NAME, "--ignore-cdr-runouts={0}", ignoreCdrRunOuts);
- AaruConsole.DebugWriteLine(MODULE_NAME, "--create-graph={0}", createGraph);
- AaruConsole.DebugWriteLine(MODULE_NAME, "--dimensions={0}", dimensions);
- AaruConsole.DebugWriteLine(MODULE_NAME, "--aaru-metadata={0}", aaruMetadata);
+ AaruConsole.DebugWriteLine(MODULE_NAME, "--retry-subchannel={0}", retrySubchannel);
+ AaruConsole.DebugWriteLine(MODULE_NAME, "--fix-subchannel={0}", fixSubchannel);
+ AaruConsole.DebugWriteLine(MODULE_NAME, "--fix-subchannel-crc={0}", fixSubchannelCrc);
+ AaruConsole.DebugWriteLine(MODULE_NAME, "--generate-subchannels={0}", generateSubchannels);
+ AaruConsole.DebugWriteLine(MODULE_NAME, "--skip-cdiready-hole={0}", skipCdiReadyHole);
+ AaruConsole.DebugWriteLine(MODULE_NAME, "--eject={0}", eject);
+ AaruConsole.DebugWriteLine(MODULE_NAME, "--max-blocks={0}", maxBlocks);
+ AaruConsole.DebugWriteLine(MODULE_NAME, "--use-buffered-reads={0}", useBufferedReads);
+ AaruConsole.DebugWriteLine(MODULE_NAME, "--store-encrypted={0}", storeEncrypted);
+ AaruConsole.DebugWriteLine(MODULE_NAME, "--title-keys={0}", titleKeys);
+ AaruConsole.DebugWriteLine(MODULE_NAME, "--ignore-cdr-runouts={0}", ignoreCdrRunOuts);
+ AaruConsole.DebugWriteLine(MODULE_NAME, "--create-graph={0}", createGraph);
+ AaruConsole.DebugWriteLine(MODULE_NAME, "--dimensions={0}", dimensions);
+ AaruConsole.DebugWriteLine(MODULE_NAME, "--aaru-metadata={0}", aaruMetadata);
// TODO: Disabled temporarily
//AaruConsole.DebugWriteLine(MODULE_NAME, "--raw={0}", raw);
@@ -319,6 +253,7 @@ sealed class DumpMediaCommand : Command
Encoding encodingClass = null;
if(encoding != null)
+ {
try
{
encodingClass = Claunia.Encoding.Encoding.GetEncoding(encoding);
@@ -332,6 +267,7 @@ sealed class DumpMediaCommand : Command
return (int)ErrorNumber.EncodingUnknown;
}
+ }
DumpSubchannel wantedSubchannel = DumpSubchannel.Any;
@@ -358,8 +294,10 @@ sealed class DumpMediaCommand : Command
TextReader resReader;
if(isResponse)
+ {
resReader = new StreamReader(Path.Combine(Path.GetDirectoryName(outputPath),
Path.GetFileNameWithoutExtension(outputPath)));
+ }
else
resReader = new StringReader(Path.GetFileNameWithoutExtension(outputPath));
@@ -372,24 +310,36 @@ sealed class DumpMediaCommand : Command
// Try extension
if(string.IsNullOrEmpty(format))
+ {
candidates.AddRange(from pluginType in plugins.WritableImages.Values
- select Activator.CreateInstance(pluginType) as IBaseWritableImage into plugin
- where plugin is not null where plugin.KnownExtensions.Contains(extension)
+ select Activator.CreateInstance(pluginType) as IBaseWritableImage
+ into plugin
+ where plugin is not null
+ where plugin.KnownExtensions.Contains(extension)
select plugin);
+ }
// Try Id
else if(Guid.TryParse(format, out Guid outId))
+ {
candidates.AddRange(from pluginType in plugins.WritableImages.Values
- select Activator.CreateInstance(pluginType) as IBaseWritableImage into plugin
- where plugin is not null where plugin.Id.Equals(outId) select plugin);
+ select Activator.CreateInstance(pluginType) as IBaseWritableImage
+ into plugin
+ where plugin is not null
+ where plugin.Id.Equals(outId)
+ select plugin);
+ }
// Try name
else
+ {
candidates.AddRange(from pluginType in plugins.WritableImages.Values
- select Activator.CreateInstance(pluginType) as IBaseWritableImage into plugin
+ select Activator.CreateInstance(pluginType) as IBaseWritableImage
+ into plugin
where plugin is not null
where plugin.Name.Equals(format, StringComparison.InvariantCultureIgnoreCase)
select plugin);
+ }
switch(candidates.Count)
{
@@ -429,9 +379,11 @@ sealed class DumpMediaCommand : Command
// Replace Windows forbidden filename characters with Japanese equivalents that are visually the same, but bigger.
if(DetectOS.IsWindows)
+ {
responseLine = responseLine.Replace('<', '\uFF1C').Replace('>', '\uFF1E').Replace(':', '\uFF1A').
Replace('"', '\u2033').Replace('\\', '\').Replace('|', '|').
Replace('?', '?').Replace('*', '*');
+ }
if(devicePath.Length == 2 &&
devicePath[1] == ':' &&
@@ -443,10 +395,10 @@ sealed class DumpMediaCommand : Command
ErrorNumber devErrno = ErrorNumber.NoError;
Core.Spectre.ProgressSingleSpinner(ctx =>
- {
- ctx.AddTask(UI.Opening_device).IsIndeterminate();
- dev = Devices.Device.Create(devicePath, out devErrno);
- });
+ {
+ ctx.AddTask(UI.Opening_device).IsIndeterminate();
+ dev = Devices.Device.Create(devicePath, out devErrno);
+ });
switch(dev)
{
@@ -502,16 +454,16 @@ sealed class DumpMediaCommand : Command
else if(File.Exists(outputPrefix + ".resume.xml") && resume)
{
// Should be covered by virtue of being the same exact class as the JSON above
- #pragma warning disable IL2026
+ #pragma warning disable IL2026
var xs = new XmlSerializer(typeof(Resume));
- #pragma warning restore IL2026
+ #pragma warning restore IL2026
var sr = new StreamReader(outputPrefix + ".resume.xml");
// Should be covered by virtue of being the same exact class as the JSON above
- #pragma warning disable IL2026
+ #pragma warning disable IL2026
resumeClass = (Resume)xs.Deserialize(sr);
- #pragma warning restore IL2026
+ #pragma warning restore IL2026
sr.Close();
}
@@ -545,7 +497,9 @@ sealed class DumpMediaCommand : Command
Metadata sidecar = null;
if(aaruMetadata != null)
+ {
if(File.Exists(aaruMetadata))
+ {
try
{
var fs = new FileStream(aaruMetadata, FileMode.Open);
@@ -565,6 +519,7 @@ sealed class DumpMediaCommand : Command
return (int)ErrorNumber.InvalidSidecar;
}
+ }
else
{
AaruConsole.ErrorWriteLine(UI.Could_not_find_metadata_sidecar);
@@ -574,21 +529,24 @@ sealed class DumpMediaCommand : Command
return (int)ErrorNumber.NoSuchFile;
}
+ }
else if(cicmXml != null)
+ {
if(File.Exists(cicmXml))
+ {
try
{
var sr = new StreamReader(cicmXml);
// Bypassed by JSON source generator used above
- #pragma warning disable IL2026
+ #pragma warning disable IL2026
var sidecarXs = new XmlSerializer(typeof(CICMMetadataType));
- #pragma warning restore IL2026
+ #pragma warning restore IL2026
// Bypassed by JSON source generator used above
- #pragma warning disable IL2026
+ #pragma warning disable IL2026
sidecar = (CICMMetadataType)sidecarXs.Deserialize(sr);
- #pragma warning restore IL2026
+ #pragma warning restore IL2026
sr.Close();
}
@@ -601,6 +559,7 @@ sealed class DumpMediaCommand : Command
return (int)ErrorNumber.InvalidSidecar;
}
+ }
else
{
AaruConsole.ErrorWriteLine(UI.Could_not_find_metadata_sidecar);
@@ -610,30 +569,43 @@ sealed class DumpMediaCommand : Command
return (int)ErrorNumber.NoSuchFile;
}
+ }
plugins = PluginBase.Singleton;
candidates = new List();
// Try extension
if(string.IsNullOrEmpty(format))
+ {
candidates.AddRange(from pluginType in plugins.WritableImages.Values
- select Activator.CreateInstance(pluginType) as IBaseWritableImage into plugin
+ select Activator.CreateInstance(pluginType) as IBaseWritableImage
+ into plugin
where plugin is not null
- where plugin.KnownExtensions.Contains(Path.GetExtension(outputPath)) select plugin);
+ where plugin.KnownExtensions.Contains(Path.GetExtension(outputPath))
+ select plugin);
+ }
// Try Id
else if(Guid.TryParse(format, out Guid outId))
+ {
candidates.AddRange(from pluginType in plugins.WritableImages.Values
- select Activator.CreateInstance(pluginType) as IBaseWritableImage into plugin
- where plugin is not null where plugin.Id.Equals(outId) select plugin);
+ select Activator.CreateInstance(pluginType) as IBaseWritableImage
+ into plugin
+ where plugin is not null
+ where plugin.Id.Equals(outId)
+ select plugin);
+ }
// Try name
else
+ {
candidates.AddRange(from pluginType in plugins.WritableImages.Values
- select Activator.CreateInstance(pluginType) as IBaseWritableImage into plugin
+ select Activator.CreateInstance(pluginType) as IBaseWritableImage
+ into plugin
where plugin is not null
where plugin.Name.Equals(format, StringComparison.InvariantCultureIgnoreCase)
select plugin);
+ }
IBaseWritableImage outputFormat = candidates[0];
@@ -663,121 +635,120 @@ sealed class DumpMediaCommand : Command
AnsiConsole.Progress().AutoClear(true).HideCompleted(true).
Columns(new TaskDescriptionColumn(), new ProgressBarColumn(), new PercentageColumn()).
Start(ctx =>
- {
- dumper.UpdateStatus += text =>
- {
- AaruConsole.WriteLine(Markup.Escape(text));
- };
+ {
+ dumper.UpdateStatus += text => { AaruConsole.WriteLine(Markup.Escape(text)); };
- dumper.ErrorMessage += text =>
- {
- AaruConsole.ErrorWriteLine($"[red]{Markup.Escape(text)}[/]");
- };
+ dumper.ErrorMessage += text =>
+ {
+ AaruConsole.
+ ErrorWriteLine($"[red]{Markup.Escape(text)}[/]");
+ };
- dumper.StoppingErrorMessage += text =>
- {
- AaruConsole.ErrorWriteLine($"[red]{Markup.Escape(text)}[/]");
- };
+ dumper.StoppingErrorMessage += text =>
+ {
+ AaruConsole.
+ ErrorWriteLine($"[red]{Markup.Escape(text)}[/]");
+ };
- dumper.UpdateProgress += (text, current, maximum) =>
- {
- _progressTask1 ??= ctx.AddTask("Progress");
- _progressTask1.Description = Markup.Escape(text);
- _progressTask1.Value = current;
- _progressTask1.MaxValue = maximum;
- };
+ dumper.UpdateProgress += (text, current, maximum) =>
+ {
+ _progressTask1 ??= ctx.AddTask("Progress");
+ _progressTask1.Description = Markup.Escape(text);
+ _progressTask1.Value = current;
+ _progressTask1.MaxValue = maximum;
+ };
- dumper.PulseProgress += text =>
- {
- if(_progressTask1 is null)
- ctx.AddTask(Markup.Escape(text)).IsIndeterminate();
- else
- {
- _progressTask1.Description = Markup.Escape(text);
- _progressTask1.IsIndeterminate = true;
- }
- };
+ dumper.PulseProgress += text =>
+ {
+ if(_progressTask1 is null)
+ ctx.AddTask(Markup.Escape(text)).IsIndeterminate();
+ else
+ {
+ _progressTask1.Description = Markup.Escape(text);
+ _progressTask1.IsIndeterminate = true;
+ }
+ };
- dumper.InitProgress += () =>
- {
- _progressTask1 = ctx.AddTask("Progress");
- };
+ dumper.InitProgress += () => { _progressTask1 = ctx.AddTask("Progress"); };
- dumper.EndProgress += () =>
- {
- _progressTask1?.StopTask();
- _progressTask1 = null;
- };
+ dumper.EndProgress += () =>
+ {
+ _progressTask1?.StopTask();
+ _progressTask1 = null;
+ };
- dumper.InitProgress2 += () =>
- {
- _progressTask2 = ctx.AddTask("Progress");
- };
+ dumper.InitProgress2 += () => { _progressTask2 = ctx.AddTask("Progress"); };
- dumper.EndProgress2 += () =>
- {
- _progressTask2?.StopTask();
- _progressTask2 = null;
- };
+ dumper.EndProgress2 += () =>
+ {
+ _progressTask2?.StopTask();
+ _progressTask2 = null;
+ };
- dumper.UpdateProgress2 += (text, current, maximum) =>
- {
- _progressTask2 ??= ctx.AddTask("Progress");
- _progressTask2.Description = Markup.Escape(text);
- _progressTask2.Value = current;
- _progressTask2.MaxValue = maximum;
- };
+ dumper.UpdateProgress2 += (text, current, maximum) =>
+ {
+ _progressTask2 ??= ctx.AddTask("Progress");
+ _progressTask2.Description = Markup.Escape(text);
+ _progressTask2.Value = current;
+ _progressTask2.MaxValue = maximum;
+ };
- System.Console.CancelKeyPress += (_, e) =>
- {
- e.Cancel = true;
- dumper.Abort();
- };
+ System.Console.CancelKeyPress += (_, e) =>
+ {
+ e.Cancel = true;
+ dumper.Abort();
+ };
- dumper.Start();
- });
+ dumper.Start();
+ });
if(eject && dev.IsRemovable)
+ {
Core.Spectre.ProgressSingleSpinner(ctx =>
- {
- ctx.AddTask(UI.Ejecting_media).IsIndeterminate();
+ {
+ ctx.AddTask(UI.Ejecting_media).IsIndeterminate();
- switch(dev.Type)
- {
- case DeviceType.ATA:
- dev.DoorUnlock(out _, dev.Timeout, out _);
- dev.MediaEject(out _, dev.Timeout, out _);
+ switch(dev.Type)
+ {
+ case DeviceType.ATA:
+ dev.DoorUnlock(out _, dev.Timeout, out _);
+ dev.MediaEject(out _, dev.Timeout, out _);
- break;
- case DeviceType.ATAPI:
- case DeviceType.SCSI:
- switch(dev.ScsiType)
- {
- case PeripheralDeviceTypes.DirectAccess:
- case PeripheralDeviceTypes.SimplifiedDevice:
- case PeripheralDeviceTypes.SCSIZonedBlockDevice:
- case PeripheralDeviceTypes.WriteOnceDevice:
- case PeripheralDeviceTypes.OpticalDevice:
- case PeripheralDeviceTypes.OCRWDevice:
- dev.SpcAllowMediumRemoval(out _, dev.Timeout, out _);
- dev.EjectTray(out _, dev.Timeout, out _);
+ break;
+ case DeviceType.ATAPI:
+ case DeviceType.SCSI:
+ switch(dev.ScsiType)
+ {
+ case PeripheralDeviceTypes.DirectAccess:
+ case PeripheralDeviceTypes.SimplifiedDevice:
+ case PeripheralDeviceTypes.SCSIZonedBlockDevice:
+ case PeripheralDeviceTypes.WriteOnceDevice:
+ case PeripheralDeviceTypes.OpticalDevice:
+ case PeripheralDeviceTypes.OCRWDevice:
+ dev.SpcAllowMediumRemoval(out _, dev.Timeout,
+ out _);
+ dev.EjectTray(out _, dev.Timeout, out _);
- break;
- case PeripheralDeviceTypes.MultiMediaDevice:
- dev.AllowMediumRemoval(out _, dev.Timeout, out _);
- dev.EjectTray(out _, dev.Timeout, out _);
+ break;
+ case PeripheralDeviceTypes.MultiMediaDevice:
+ dev.AllowMediumRemoval(out _, dev.Timeout,
+ out _);
+ dev.EjectTray(out _, dev.Timeout, out _);
- break;
- case PeripheralDeviceTypes.SequentialAccess:
- dev.SpcAllowMediumRemoval(out _, dev.Timeout, out _);
- dev.LoadUnload(out _, true, false, false, false, false, dev.Timeout, out _);
+ break;
+ case PeripheralDeviceTypes.SequentialAccess:
+ dev.SpcAllowMediumRemoval(out _, dev.Timeout,
+ out _);
+ dev.LoadUnload(out _, true, false, false, false,
+ false, dev.Timeout, out _);
- break;
- }
+ break;
+ }
- break;
- }
- });
+ break;
+ }
+ });
+ }
dev.Close();
}
diff --git a/Aaru/Commands/Media/Info.cs b/Aaru/Commands/Media/Info.cs
index 6b15fe9f9..5e281c58c 100644
--- a/Aaru/Commands/Media/Info.cs
+++ b/Aaru/Commands/Media/Info.cs
@@ -69,10 +69,7 @@ sealed class MediaInfoCommand : Command
public MediaInfoCommand() : base("info", UI.Media_Info_Command_Description)
{
- Add(new Option(new[]
- {
- "--output-prefix", "-w"
- }, () => null, UI.Prefix_for_saving_binary_information));
+ Add(new Option(new[] { "--output-prefix", "-w" }, () => null, UI.Prefix_for_saving_binary_information));
AddArgument(new Argument
{
@@ -96,29 +93,31 @@ sealed class MediaInfoCommand : Command
});
AaruConsole.DebugWriteLineEvent += (format, objects) =>
- {
- if(objects is null)
- stderrConsole.MarkupLine(format);
- else
- stderrConsole.MarkupLine(format, objects);
- };
+ {
+ if(objects is null)
+ stderrConsole.MarkupLine(format);
+ else
+ stderrConsole.MarkupLine(format, objects);
+ };
}
if(verbose)
+ {
AaruConsole.WriteEvent += (format, objects) =>
- {
- if(objects is null)
- AnsiConsole.Markup(format);
- else
- AnsiConsole.Markup(format, objects);
- };
+ {
+ if(objects is null)
+ AnsiConsole.Markup(format);
+ else
+ AnsiConsole.Markup(format, objects);
+ };
+ }
Statistics.AddCommand("media-info");
- AaruConsole.DebugWriteLine(MODULE_NAME, "--debug={0}", debug);
- AaruConsole.DebugWriteLine(MODULE_NAME, "--device={0}", devicePath);
+ AaruConsole.DebugWriteLine(MODULE_NAME, "--debug={0}", debug);
+ AaruConsole.DebugWriteLine(MODULE_NAME, "--device={0}", devicePath);
AaruConsole.DebugWriteLine(MODULE_NAME, "--output-prefix={0}", outputPrefix);
- AaruConsole.DebugWriteLine(MODULE_NAME, "--verbose={0}", verbose);
+ AaruConsole.DebugWriteLine(MODULE_NAME, "--verbose={0}", verbose);
if(devicePath.Length == 2 &&
devicePath[1] == ':' &&
@@ -130,10 +129,10 @@ sealed class MediaInfoCommand : Command
ErrorNumber devErrno = ErrorNumber.NoError;
Core.Spectre.ProgressSingleSpinner(ctx =>
- {
- ctx.AddTask(UI.Opening_device).IsIndeterminate();
- dev = Devices.Device.Create(devicePath, out devErrno);
- });
+ {
+ ctx.AddTask(UI.Opening_device).IsIndeterminate();
+ dev = Devices.Device.Create(devicePath, out devErrno);
+ });
switch(dev)
{
@@ -178,7 +177,8 @@ sealed class MediaInfoCommand : Command
DoScsiMediaInfo(debug, outputPrefix, dev);
break;
- default: throw new NotSupportedException(Localization.Core.Unknown_device_type);
+ default:
+ throw new NotSupportedException(Localization.Core.Unknown_device_type);
}
return (int)ErrorNumber.NoError;
@@ -196,21 +196,25 @@ sealed class MediaInfoCommand : Command
ScsiInfo scsiInfo = null;
Core.Spectre.ProgressSingleSpinner(ctx =>
- {
- ctx.AddTask(UI.Retrieving_SCSI_information).IsIndeterminate();
- scsiInfo = new ScsiInfo(dev);
- });
+ {
+ ctx.AddTask(UI.Retrieving_SCSI_information).IsIndeterminate();
+ scsiInfo = new ScsiInfo(dev);
+ });
if(!scsiInfo.MediaInserted)
return;
if(scsiInfo.DeviceInfo.ScsiModeSense6 != null)
+ {
DataFile.WriteTo(MODULE_NAME, outputPrefix, "_scsi_modesense6.bin", "SCSI MODE SENSE (6)",
scsiInfo.DeviceInfo.ScsiModeSense6);
+ }
if(scsiInfo.DeviceInfo.ScsiModeSense10 != null)
+ {
DataFile.WriteTo(MODULE_NAME, outputPrefix, "_scsi_modesense10.bin", "SCSI MODE SENSE (10)",
scsiInfo.DeviceInfo.ScsiModeSense10);
+ }
switch(dev.ScsiType)
{
@@ -223,18 +227,24 @@ sealed class MediaInfoCommand : Command
case PeripheralDeviceTypes.BridgingExpander when dev.Model.StartsWith("MDM", StringComparison.Ordinal) ||
dev.Model.StartsWith("MDH", StringComparison.Ordinal):
if(scsiInfo.ReadCapacity != null)
+ {
DataFile.WriteTo(MODULE_NAME, outputPrefix, "_readcapacity.bin", "SCSI READ CAPACITY",
scsiInfo.ReadCapacity);
+ }
if(scsiInfo.ReadCapacity16 != null)
+ {
DataFile.WriteTo(MODULE_NAME, outputPrefix, "_readcapacity16.bin",
"SCSI READ CAPACITY(16)", scsiInfo.ReadCapacity16);
+ }
if(scsiInfo.Blocks != 0 &&
scsiInfo.BlockSize != 0)
+ {
AaruConsole.WriteLine(Localization.Core.Media_has_0_blocks_of_1_bytes_each_for_a_total_of_2,
scsiInfo.Blocks, scsiInfo.BlockSize,
ByteSize.FromBytes(scsiInfo.Blocks * scsiInfo.BlockSize).ToString("0.000"));
+ }
break;
case PeripheralDeviceTypes.SequentialAccess:
@@ -270,16 +280,22 @@ sealed class MediaInfoCommand : Command
if(dev.ScsiType == PeripheralDeviceTypes.MultiMediaDevice)
{
if(scsiInfo.MmcConfiguration != null)
+ {
DataFile.WriteTo(MODULE_NAME, outputPrefix, "_getconfiguration_current.bin",
"SCSI GET CONFIGURATION", scsiInfo.MmcConfiguration);
+ }
if(scsiInfo.RecognizedFormatLayers != null)
+ {
DataFile.WriteTo(MODULE_NAME, outputPrefix, "_readdiscstructure_formatlayers.bin",
"SCSI READ DISC STRUCTURE", scsiInfo.RecognizedFormatLayers);
+ }
if(scsiInfo.WriteProtectionStatus != null)
+ {
DataFile.WriteTo(MODULE_NAME, outputPrefix, "_readdiscstructure_writeprotection.bin",
"SCSI READ DISC STRUCTURE", scsiInfo.WriteProtectionStatus);
+ }
if(scsiInfo.DvdPfi != null)
{
@@ -296,11 +312,15 @@ sealed class MediaInfoCommand : Command
"SCSI READ DISC STRUCTURE", scsiInfo.DvdDmi);
if(DMI.IsXbox(scsiInfo.DvdDmi))
+ {
AaruConsole.WriteLine($"[bold]{Localization.Core.Xbox_DMI}:[/]",
$"\n{Markup.Escape(DMI.PrettifyXbox(scsiInfo.DvdDmi))}");
+ }
else if(DMI.IsXbox360(scsiInfo.DvdDmi))
+ {
AaruConsole.WriteLine($"[bold]{Localization.Core.Xbox_360_DMI}:[/]",
$"\n{Markup.Escape(DMI.PrettifyXbox360(scsiInfo.DvdDmi))}");
+ }
}
if(scsiInfo.DvdCmi != null)
@@ -313,20 +333,28 @@ sealed class MediaInfoCommand : Command
}
if(scsiInfo.DvdDiscKey != null)
+ {
DataFile.WriteTo(MODULE_NAME, outputPrefix, "_readdiscstructure_dvd_disckey.bin",
"SCSI READ DISC STRUCTURE", scsiInfo.DvdDiscKey);
+ }
if(scsiInfo.DvdSectorCmi != null)
+ {
DataFile.WriteTo(MODULE_NAME, outputPrefix, "_readdiscstructure_dvd_sectorcmi.bin",
"SCSI READ DISC STRUCTURE", scsiInfo.DvdSectorCmi);
+ }
if(scsiInfo.DvdBca != null)
+ {
DataFile.WriteTo(MODULE_NAME, outputPrefix, "_readdiscstructure_dvd_bca.bin",
"SCSI READ DISC STRUCTURE", scsiInfo.DvdBca);
+ }
if(scsiInfo.DvdAacs != null)
+ {
DataFile.WriteTo(MODULE_NAME, outputPrefix, "_readdiscstructure_dvd_aacs.bin",
"SCSI READ DISC STRUCTURE", scsiInfo.DvdAacs);
+ }
if(scsiInfo.DvdRamDds != null)
{
@@ -356,8 +384,10 @@ sealed class MediaInfoCommand : Command
}
if(scsiInfo.LastBorderOutRmd != null)
+ {
DataFile.WriteTo(MODULE_NAME, outputPrefix, "_readdiscstructure_dvd_lastrmd.bin",
"SCSI READ DISC STRUCTURE", scsiInfo.LastBorderOutRmd);
+ }
if(scsiInfo.DvdPreRecordedInfo != null)
{
@@ -365,13 +395,17 @@ sealed class MediaInfoCommand : Command
"SCSI READ DISC STRUCTURE", scsiInfo.DvdPreRecordedInfo);
if(scsiInfo.DecodedDvdPrePitInformation.HasValue)
+ {
AaruConsole.WriteLine($"[bold]{Localization.Core.DVD_RW_Pre_Recorded_Information}:[/]",
$"\n{Markup.Escape(PRI.Prettify(scsiInfo.DecodedDvdPrePitInformation))}");
+ }
}
if(scsiInfo.DvdrMediaIdentifier != null)
+ {
DataFile.WriteTo(MODULE_NAME, outputPrefix, "_readdiscstructure_dvdr_mediaid.bin",
"SCSI READ DISC STRUCTURE", scsiInfo.DvdrMediaIdentifier);
+ }
if(scsiInfo.DvdrPhysicalInformation != null)
{
@@ -379,49 +413,71 @@ sealed class MediaInfoCommand : Command
"SCSI READ DISC STRUCTURE", scsiInfo.DvdrPhysicalInformation);
if(scsiInfo.DecodedDvdrPfi.HasValue)
+ {
AaruConsole.WriteLine($"[bold]{Localization.Core.DVD_RW_PFI}:[/]",
$"\n{Markup.Escape(PFI.Prettify(scsiInfo.DecodedDvdrPfi))}");
+ }
}
if(scsiInfo.DvdPlusAdip != null)
+ {
DataFile.WriteTo(MODULE_NAME, outputPrefix, "_readdiscstructure_dvd+_adip.bin",
"SCSI READ DISC STRUCTURE", scsiInfo.DvdPlusAdip);
+ }
if(scsiInfo.DvdPlusDcb != null)
+ {
DataFile.WriteTo(MODULE_NAME, outputPrefix, "_readdiscstructure_dvd+_dcb.bin",
"SCSI READ DISC STRUCTURE", scsiInfo.DvdPlusDcb);
+ }
if(scsiInfo.HddvdCopyrightInformation != null)
+ {
DataFile.WriteTo(MODULE_NAME, outputPrefix, "_readdiscstructure_hddvd_cmi.bin",
"SCSI READ DISC STRUCTURE", scsiInfo.HddvdCopyrightInformation);
+ }
if(scsiInfo.HddvdrMediumStatus != null)
+ {
DataFile.WriteTo(MODULE_NAME, outputPrefix, "_readdiscstructure_hddvdr_status.bin",
"SCSI READ DISC STRUCTURE", scsiInfo.HddvdrMediumStatus);
+ }
if(scsiInfo.HddvdrLastRmd != null)
+ {
DataFile.WriteTo(MODULE_NAME, outputPrefix, "_readdiscstructure_hddvdr_lastrmd.bin",
"SCSI READ DISC STRUCTURE", scsiInfo.HddvdrLastRmd);
+ }
if(scsiInfo.DvdrLayerCapacity != null)
+ {
DataFile.WriteTo(MODULE_NAME, outputPrefix, "_readdiscstructure_dvdr_layercap.bin",
"SCSI READ DISC STRUCTURE", scsiInfo.DvdrLayerCapacity);
+ }
if(scsiInfo.DvdrDlMiddleZoneStart != null)
+ {
DataFile.WriteTo(MODULE_NAME, outputPrefix, "_readdiscstructure_dvd_mzs.bin",
"SCSI READ DISC STRUCTURE", scsiInfo.DvdrDlMiddleZoneStart);
+ }
if(scsiInfo.DvdrDlJumpIntervalSize != null)
+ {
DataFile.WriteTo(MODULE_NAME, outputPrefix, "_readdiscstructure_dvd_jis.bin",
"SCSI READ DISC STRUCTURE", scsiInfo.DvdrDlJumpIntervalSize);
+ }
if(scsiInfo.DvdrDlManualLayerJumpStartLba != null)
+ {
DataFile.WriteTo(MODULE_NAME, outputPrefix, "_readdiscstructure_dvd_manuallj.bin",
"SCSI READ DISC STRUCTURE", scsiInfo.DvdrDlManualLayerJumpStartLba);
+ }
if(scsiInfo.DvdrDlRemapAnchorPoint != null)
+ {
DataFile.WriteTo(MODULE_NAME, outputPrefix, "_readdiscstructure_dvd_remapanchor.bin",
"SCSI READ DISC STRUCTURE", scsiInfo.DvdrDlRemapAnchorPoint);
+ }
if(scsiInfo.BlurayDiscInformation != null)
{
@@ -433,8 +489,10 @@ sealed class MediaInfoCommand : Command
}
if(scsiInfo.BlurayPac != null)
+ {
DataFile.WriteTo(MODULE_NAME, outputPrefix, "_readdiscstructure_bd_pac.bin",
"SCSI READ DISC STRUCTURE", scsiInfo.BlurayPac);
+ }
if(scsiInfo.BlurayBurstCuttingArea != null)
{
@@ -461,7 +519,7 @@ sealed class MediaInfoCommand : Command
AaruConsole.WriteLine($"[bold]{Localization.Core.Bluray_Cartridge_Status}:[/]",
$"\n{Markup.Escape(Decoders.Bluray.Cartridge.Prettify(scsiInfo.
- BlurayCartridgeStatus))}");
+ BlurayCartridgeStatus))}");
}
if(scsiInfo.BluraySpareAreaInformation != null)
@@ -471,12 +529,14 @@ sealed class MediaInfoCommand : Command
AaruConsole.WriteLine($"[bold]{Localization.Core.Bluray_Spare_Area_Information}:[/]",
$"\n{Markup.Escape(Decoders.Bluray.Spare.Prettify(scsiInfo.
- BluraySpareAreaInformation))}");
+ BluraySpareAreaInformation))}");
}
if(scsiInfo.BlurayRawDfl != null)
+ {
DataFile.WriteTo(MODULE_NAME, outputPrefix, "_readdiscstructure_bd_dfl.bin",
"SCSI READ DISC STRUCTURE", scsiInfo.BlurayRawDfl);
+ }
if(scsiInfo.BlurayTrackResources != null)
{
@@ -502,8 +562,10 @@ sealed class MediaInfoCommand : Command
scsiInfo.Toc);
if(scsiInfo.DecodedToc.HasValue)
+ {
AaruConsole.WriteLine($"[bold]{UI.Title_TOC}:[/]",
$"\n{Markup.Escape(TOC.Prettify(scsiInfo.DecodedToc))}");
+ }
}
if(scsiInfo.Atip != null)
@@ -512,8 +574,10 @@ sealed class MediaInfoCommand : Command
scsiInfo.Atip);
if(scsiInfo.DecodedAtip != null)
+ {
AaruConsole.WriteLine($"[bold]{UI.Title_ATIP}:[/]",
$"\n{Markup.Escape(ATIP.Prettify(scsiInfo.DecodedAtip))}");
+ }
}
if(scsiInfo.DiscInformation != null)
@@ -522,9 +586,11 @@ sealed class MediaInfoCommand : Command
"SCSI READ DISC INFORMATION", scsiInfo.DiscInformation);
if(scsiInfo.DecodedDiscInformation.HasValue)
+ {
AaruConsole.WriteLine($"[bold]{Localization.Core.Standard_Disc_Information}:[/]",
$"\n{Markup.Escape(DiscInformation.Prettify000b(scsiInfo.
- DecodedDiscInformation))}");
+ DecodedDiscInformation))}");
+ }
}
if(scsiInfo.Session != null)
@@ -533,8 +599,10 @@ sealed class MediaInfoCommand : Command
scsiInfo.Session);
if(scsiInfo.DecodedSession.HasValue)
+ {
AaruConsole.WriteLine($"[bold]{Localization.Core.Session_information}:[/]",
$"\n{Markup.Escape(Session.Prettify(scsiInfo.DecodedSession))}");
+ }
}
if(scsiInfo.RawToc != null)
@@ -543,8 +611,10 @@ sealed class MediaInfoCommand : Command
scsiInfo.RawToc);
if(scsiInfo.FullToc.HasValue)
+ {
AaruConsole.WriteLine($"[bold]{Localization.Core.Raw_TOC}:[/]",
$"\n{Markup.Escape(FullTOC.Prettify(scsiInfo.RawToc))}");
+ }
}
if(scsiInfo.Pma != null)
@@ -562,25 +632,35 @@ sealed class MediaInfoCommand : Command
scsiInfo.CdTextLeadIn);
if(scsiInfo.DecodedCdTextLeadIn.HasValue)
+ {
AaruConsole.WriteLine($"[bold]{Localization.Core.CD_TEXT_on_Lead_In}:[/]",
$"\n{Markup.Escape(CDTextOnLeadIn.Prettify(scsiInfo.DecodedCdTextLeadIn))}");
+ }
}
if(!string.IsNullOrEmpty(scsiInfo.Mcn))
AaruConsole.WriteLine($"[bold]{Localization.Core.MCN}:[/]", $" {Markup.Escape(scsiInfo.Mcn)}");
if(scsiInfo.Isrcs != null)
+ {
foreach(KeyValuePair isrc in scsiInfo.Isrcs)
+ {
AaruConsole.WriteLine($"[bold]{string.Format(Localization.Core.Tracks_0_ISRC, isrc.Key)}:[/] {
Markup.Escape(isrc.Value)}");
+ }
+ }
if(scsiInfo.XboxSecuritySector != null)
+ {
DataFile.WriteTo(MODULE_NAME, outputPrefix, "_xbox_ss.bin", "KREON EXTRACT SS",
scsiInfo.XboxSecuritySector);
+ }
if(scsiInfo.DecodedXboxSecuritySector.HasValue)
+ {
AaruConsole.WriteLine($"[bold]{Localization.Core.Xbox_Security_Sector}:[/]",
$"\n{Markup.Escape(SS.Prettify(scsiInfo.DecodedXboxSecuritySector))}");
+ }
if(scsiInfo.XgdInfo != null)
{
@@ -612,7 +692,7 @@ sealed class MediaInfoCommand : Command
AaruConsole.Write($"[bold]{Localization.Core.Media_Serial_Number}:[/] ");
- for(int i = 4; i < scsiInfo.MediaSerialNumber.Length; i++)
+ for(var i = 4; i < scsiInfo.MediaSerialNumber.Length; i++)
AaruConsole.Write("{0:X2}", scsiInfo.MediaSerialNumber[i]);
AaruConsole.WriteLine();
@@ -629,7 +709,7 @@ sealed class MediaInfoCommand : Command
if(tracks != null)
{
- uint firstLba = (uint)tracks.Min(t => t.StartSector);
+ var firstLba = (uint)tracks.Min(t => t.StartSector);
bool supportsPqSubchannel = Dump.SupportsPqSubchannel(dev, null, null, firstLba);
bool supportsRwSubchannel = Dump.SupportsRwSubchannel(dev, null, null, firstLba);
@@ -645,7 +725,7 @@ sealed class MediaInfoCommand : Command
Dump.SolveTrackPregaps(dev, null, null, tracks, supportsPqSubchannel, supportsRwSubchannel, dbDev,
out bool inexactPositioning, false);
- for(int t = 1; t < tracks.Length; t++)
+ for(var t = 1; t < tracks.Length; t++)
tracks[t - 1].EndSector = tracks[t].StartSector - 1;
tracks[^1].EndSector = (ulong)lastSector;
@@ -654,17 +734,21 @@ sealed class MediaInfoCommand : Command
AaruConsole.WriteLine($"[bold]{Localization.Core.Track_calculations}:[/]");
if(inexactPositioning)
+ {
AaruConsole.WriteLine($"[yellow]{Localization.Core.
The_drive_has_returned_incorrect_Q_positioning_calculating_pregaps
}[/]");
+ }
if(firstLba > 0)
AaruConsole.WriteLine(UI.Hidden_track_starts_at_LBA_0_ends_at_LBA_1, 0, firstLba - 1);
foreach(Track track in tracks)
+ {
AaruConsole.
WriteLine(UI.Track_0_starts_at_LBA_1_ends_at_LBA_2_has_a_pregap_of_3_sectors_and_is_of_type_4,
track.Sequence, track.StartSector, track.EndSector, track.Pregap, track.Type);
+ }
AaruConsole.WriteLine();
AaruConsole.WriteLine($"[bold]{Localization.Core.Offsets}:[/]");
@@ -728,4 +812,4 @@ sealed class MediaInfoCommand : Command
dev.Close();
}
-}
+}
\ No newline at end of file
diff --git a/Aaru/Commands/Media/Scan.cs b/Aaru/Commands/Media/Scan.cs
index c127ecf27..7c784bd05 100644
--- a/Aaru/Commands/Media/Scan.cs
+++ b/Aaru/Commands/Media/Scan.cs
@@ -51,20 +51,13 @@ sealed class MediaScanCommand : Command
public MediaScanCommand() : base("scan", UI.Media_Scan_Command_Description)
{
- Add(new Option(new[]
- {
- "--mhdd-log", "-m"
- }, () => null, UI.Write_a_log_of_the_scan_in_the_format_used_by_MHDD));
+ Add(new Option(new[] { "--mhdd-log", "-m" }, () => null,
+ UI.Write_a_log_of_the_scan_in_the_format_used_by_MHDD));
- Add(new Option(new[]
- {
- "--ibg-log", "-b"
- }, () => null, UI.Write_a_log_of_the_scan_in_the_format_used_by_ImgBurn));
+ Add(new Option(new[] { "--ibg-log", "-b" }, () => null,
+ UI.Write_a_log_of_the_scan_in_the_format_used_by_ImgBurn));
- Add(new Option(new[]
- {
- "--use-buffered-reads"
- }, () => true, UI.OS_buffered_reads_help));
+ Add(new Option(new[] { "--use-buffered-reads" }, () => true, UI.OS_buffered_reads_help));
AddArgument(new Argument