[Aaru] Reformat and cleanup.

This commit is contained in:
2023-10-03 22:04:36 +01:00
parent 29512a0a5f
commit ec9f5808e4
33 changed files with 3846 additions and 3279 deletions

View File

@@ -1,211 +1,211 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<Project Sdk="Microsoft.NET.Sdk"> <Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup> <PropertyGroup>
<SchemaVersion>2.0</SchemaVersion> <SchemaVersion>2.0</SchemaVersion>
<ProjectGuid>{7A4B05BE-73C9-4F34-87FE-E80CCF1F732D}</ProjectGuid> <ProjectGuid>{7A4B05BE-73C9-4F34-87FE-E80CCF1F732D}</ProjectGuid>
<OutputType>Exe</OutputType> <OutputType>Exe</OutputType>
<RootNamespace>Aaru</RootNamespace> <RootNamespace>Aaru</RootNamespace>
<AssemblyName>aaru</AssemblyName> <AssemblyName>aaru</AssemblyName>
<ReleaseVersion>$(Version)</ReleaseVersion> <ReleaseVersion>$(Version)</ReleaseVersion>
<TargetFramework>net8.0</TargetFramework> <TargetFramework>net8.0</TargetFramework>
<GenerateAssemblyInfo>true</GenerateAssemblyInfo> <GenerateAssemblyInfo>true</GenerateAssemblyInfo>
<Version>6.0.0~alpha9</Version> <Version>6.0.0~alpha9</Version>
<Company>Claunia.com</Company> <Company>Claunia.com</Company>
<Copyright>Copyright © 2011-2023 Natalia Portillo</Copyright> <Copyright>Copyright © 2011-2023 Natalia Portillo</Copyright>
<Product>Aaru Data Preservation Suite</Product> <Product>Aaru Data Preservation Suite</Product>
<Title>Aaru</Title> <Title>Aaru</Title>
<ApplicationVersion>$(Version)</ApplicationVersion> <ApplicationVersion>$(Version)</ApplicationVersion>
<!-- TODO win-arm doesn't seem to work in RC1, try again in final --> <!-- TODO win-arm doesn't seem to work in RC1, try again in final -->
<RuntimeIdentifiers>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</RuntimeIdentifiers> <RuntimeIdentifiers>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</RuntimeIdentifiers>
<TargetLatestRuntimePatch>true</TargetLatestRuntimePatch> <TargetLatestRuntimePatch>true</TargetLatestRuntimePatch>
<LangVersion>12</LangVersion> <LangVersion>12</LangVersion>
<DisableImplicitNamespaceImports>true</DisableImplicitNamespaceImports> <DisableImplicitNamespaceImports>true</DisableImplicitNamespaceImports>
<EnableTrimAnalyzer>true</EnableTrimAnalyzer> <EnableTrimAnalyzer>true</EnableTrimAnalyzer>
<IsPackable>false</IsPackable> <IsPackable>false</IsPackable>
</PropertyGroup> </PropertyGroup>
<PropertyGroup> <PropertyGroup>
<NrtRevisionFormat>$(Version)+{chash:8}</NrtRevisionFormat> <NrtRevisionFormat>$(Version)+{chash:8}</NrtRevisionFormat>
<NrtResolveSimpleAttributes>true</NrtResolveSimpleAttributes> <NrtResolveSimpleAttributes>true</NrtResolveSimpleAttributes>
<NrtShowRevision>false</NrtShowRevision> <NrtShowRevision>false</NrtShowRevision>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)' == 'Debug' "> <PropertyGroup Condition=" '$(Configuration)' == 'Debug' ">
<DebugPackage>-dbg</DebugPackage> <DebugPackage>-dbg</DebugPackage>
<NoWarn>CS1591;CS1574</NoWarn> <NoWarn>CS1591;CS1574</NoWarn>
</PropertyGroup> </PropertyGroup>
<ItemGroup Condition=" '$(Configuration)' == 'Debug' "> <ItemGroup Condition=" '$(Configuration)' == 'Debug' ">
<InternalsVisibleTo Include="Aaru.Tests" /> <InternalsVisibleTo Include="Aaru.Tests"/>
<InternalsVisibleTo Include="Aaru.Tests.Devices" /> <InternalsVisibleTo Include="Aaru.Tests.Devices"/>
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<None Remove="Packaging.Targets" /> <None Remove="Packaging.Targets"/>
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<None Include="..\README.md"> <None Include="..\README.md">
<Link>README.md</Link> <Link>README.md</Link>
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None> </None>
<None Include="..\.travis.yml"> <None Include="..\.travis.yml">
<Link>.travis.yml</Link> <Link>.travis.yml</Link>
</None> </None>
<None Include="..\CONTRIBUTING.md"> <None Include="..\CONTRIBUTING.md">
<Link>CONTRIBUTING.md</Link> <Link>CONTRIBUTING.md</Link>
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None> </None>
<None Include="..\NEEDED.md"> <None Include="..\NEEDED.md">
<Link>NEEDED.md</Link> <Link>NEEDED.md</Link>
</None> </None>
<None Include="..\Changelog.md"> <None Include="..\Changelog.md">
<Link>Changelog.md</Link> <Link>Changelog.md</Link>
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None> </None>
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<ProjectReference Include="..\Aaru.Checksums\Aaru.Checksums.csproj" /> <ProjectReference Include="..\Aaru.Checksums\Aaru.Checksums.csproj"/>
<ProjectReference Include="..\Aaru.Database\Aaru.Database.csproj" /> <ProjectReference Include="..\Aaru.Database\Aaru.Database.csproj"/>
<ProjectReference Include="..\Aaru.Gui\Aaru.Gui.csproj" /> <ProjectReference Include="..\Aaru.Gui\Aaru.Gui.csproj"/>
<ProjectReference Include="..\Aaru.Helpers\Aaru.Helpers.csproj" /> <ProjectReference Include="..\Aaru.Helpers\Aaru.Helpers.csproj"/>
<ProjectReference Include="..\Aaru.Images\Aaru.Images.csproj" /> <ProjectReference Include="..\Aaru.Images\Aaru.Images.csproj"/>
<ProjectReference Include="..\Aaru.CommonTypes\Aaru.CommonTypes.csproj" /> <ProjectReference Include="..\Aaru.CommonTypes\Aaru.CommonTypes.csproj"/>
<ProjectReference Include="..\Aaru.Localization\Aaru.Localization.csproj" /> <ProjectReference Include="..\Aaru.Localization\Aaru.Localization.csproj"/>
<ProjectReference Include="..\Aaru.Partitions\Aaru.Partitions.csproj" /> <ProjectReference Include="..\Aaru.Partitions\Aaru.Partitions.csproj"/>
<ProjectReference Include="..\Aaru.Filesystems\Aaru.Filesystems.csproj" /> <ProjectReference Include="..\Aaru.Filesystems\Aaru.Filesystems.csproj"/>
<ProjectReference Include="..\Aaru.Decoders\Aaru.Decoders.csproj" /> <ProjectReference Include="..\Aaru.Decoders\Aaru.Decoders.csproj"/>
<ProjectReference Include="..\Aaru.Devices\Aaru.Devices.csproj" /> <ProjectReference Include="..\Aaru.Devices\Aaru.Devices.csproj"/>
<ProjectReference Include="..\Aaru.Console\Aaru.Console.csproj" /> <ProjectReference Include="..\Aaru.Console\Aaru.Console.csproj"/>
<ProjectReference Include="..\Aaru.Settings\Aaru.Settings.csproj" /> <ProjectReference Include="..\Aaru.Settings\Aaru.Settings.csproj"/>
<ProjectReference Include="..\Aaru.Filters\Aaru.Filters.csproj" /> <ProjectReference Include="..\Aaru.Filters\Aaru.Filters.csproj"/>
<ProjectReference Include="..\Aaru.Core\Aaru.Core.csproj" /> <ProjectReference Include="..\Aaru.Core\Aaru.Core.csproj"/>
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<EmbeddedResource Include="..\LICENSE.MIT"> <EmbeddedResource Include="..\LICENSE.MIT">
<Link>LICENSE.MIT</Link> <Link>LICENSE.MIT</Link>
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</EmbeddedResource> </EmbeddedResource>
<EmbeddedResource Include="..\LICENSE.LGPL"> <EmbeddedResource Include="..\LICENSE.LGPL">
<Link>LICENSE.LGPL</Link> <Link>LICENSE.LGPL</Link>
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</EmbeddedResource> </EmbeddedResource>
<Folder Include="..\LICENSE" /> <Folder Include="..\LICENSE"/>
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<None Include="..\.github\CODE_OF_CONDUCT.md" /> <None Include="..\.github\CODE_OF_CONDUCT.md"/>
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<Content Include="..\.github\PULL_REQUEST_TEMPLATE.md" /> <Content Include="..\.github\PULL_REQUEST_TEMPLATE.md"/>
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<PackageReference Include="Humanizer" Version="2.14.1" /> <PackageReference Include="Humanizer" Version="2.14.1"/>
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="8.0.0-rc.1.23419.6" /> <PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="8.0.0-rc.1.23419.6"/>
<PackageReference Include="Spectre.Console" Version="0.47.0" /> <PackageReference Include="Spectre.Console" Version="0.47.0"/>
<PackageReference Include="Spectre.Console.Analyzer" Version="0.47.0"> <PackageReference Include="Spectre.Console.Analyzer" Version="0.47.0">
<PrivateAssets>all</PrivateAssets> <PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets> <IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference> </PackageReference>
<PackageReference Include="System.CommandLine" Version="2.0.0-beta4.22272.1" /> <PackageReference Include="System.CommandLine" Version="2.0.0-beta4.22272.1"/>
<PackageReference Include="System.CommandLine.NamingConventionBinder" Version="2.0.0-beta4.22272.1" /> <PackageReference Include="System.CommandLine.NamingConventionBinder" Version="2.0.0-beta4.22272.1"/>
<PackageReference Include="System.Text.Encoding.CodePages" Version="8.0.0-rc.1.23419.4" /> <PackageReference Include="System.Text.Encoding.CodePages" Version="8.0.0-rc.1.23419.4"/>
<PackageReference Include="System.Text.Json" Version="8.0.0-rc.1.23419.4" /> <PackageReference Include="System.Text.Json" Version="8.0.0-rc.1.23419.4"/>
<PackageReference Include="System.ValueTuple" Version="4.5.0" /> <PackageReference Include="System.ValueTuple" Version="4.5.0"/>
<PackageReference Include="Unclassified.NetRevisionTask" Version="0.4.3"> <PackageReference Include="Unclassified.NetRevisionTask" Version="0.4.3">
<PrivateAssets>all</PrivateAssets> <PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets> <IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference> </PackageReference>
<PackageReference Include="System.Collections" Version="4.3.0" /> <PackageReference Include="System.Collections" Version="4.3.0"/>
<PackageReference Include="System.Diagnostics.Debug" Version="4.3.0" /> <PackageReference Include="System.Diagnostics.Debug" Version="4.3.0"/>
<PackageReference Include="System.IO.FileSystem.Primitives" Version="4.3.0" /> <PackageReference Include="System.IO.FileSystem.Primitives" Version="4.3.0"/>
<PackageReference Include="System.Runtime.Extensions" Version="4.3.1" /> <PackageReference Include="System.Runtime.Extensions" Version="4.3.1"/>
<PackageReference Include="System.Runtime.Handles" Version="4.3.0" /> <PackageReference Include="System.Runtime.Handles" Version="4.3.0"/>
<PackageReference Include="System.Runtime.InteropServices" Version="4.3.0" /> <PackageReference Include="System.Runtime.InteropServices" Version="4.3.0"/>
<PackageReference Include="System.Net.Primitives" Version="4.3.1" /> <PackageReference Include="System.Net.Primitives" Version="4.3.1"/>
<PackageReference Include="System.IO.FileSystem" Version="4.3.0" /> <PackageReference Include="System.IO.FileSystem" Version="4.3.0"/>
<PackageReference Update="Packaging.Targets" Version="0.1.220" /> <PackageReference Update="Packaging.Targets" Version="0.1.220"/>
<PackageReference Include="Packaging.Targets" Version="0.1.220" /> <PackageReference Include="Packaging.Targets" Version="0.1.220"/>
</ItemGroup> </ItemGroup>
<PropertyGroup> <PropertyGroup>
<PackageVersion>6.0.0-alpha9</PackageVersion> <PackageVersion>6.0.0-alpha9</PackageVersion>
<PackagePrefix>aaru</PackagePrefix> <PackagePrefix>aaru</PackagePrefix>
<Authors>Natalia Portillo &lt;claunia@claunia.com&gt;</Authors> <Authors>Natalia Portillo &lt;claunia@claunia.com&gt;</Authors>
<Section>net</Section> <Section>net</Section>
<PackageDescription>Disc image management and creation tool for disks, tapes, optical and solid state media</PackageDescription> <PackageDescription>Disc image management and creation tool for disks, tapes, optical and solid state media</PackageDescription>
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<Content Include="aaruformat.xml" CopyToPublishDirectory="PreserveNewest" LinuxFileMode="0644"> <Content Include="aaruformat.xml" CopyToPublishDirectory="PreserveNewest" LinuxFileMode="0644">
<LinuxPath>/usr/share/mime/packages/aaruformat.xml</LinuxPath> <LinuxPath>/usr/share/mime/packages/aaruformat.xml</LinuxPath>
</Content> </Content>
</ItemGroup> </ItemGroup>
<PropertyGroup Condition="'$(RuntimeIdentifier)' == 'linux-musl-arm64'"> <PropertyGroup Condition="'$(RuntimeIdentifier)' == 'linux-musl-arm64'">
<PackageName>$(PackagePrefix)-$(PackageVersion)_alpine_aarch64$(DebugPackage)</PackageName> <PackageName>$(PackagePrefix)-$(PackageVersion)_alpine_aarch64$(DebugPackage)</PackageName>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition="'$(RuntimeIdentifier)' == 'linux-musl-arm'"> <PropertyGroup Condition="'$(RuntimeIdentifier)' == 'linux-musl-arm'">
<PackageName>$(PackagePrefix)-$(PackageVersion)_alpine_armhf$(DebugPackage)</PackageName> <PackageName>$(PackagePrefix)-$(PackageVersion)_alpine_armhf$(DebugPackage)</PackageName>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition="'$(RuntimeIdentifier)' == 'linux-musl-x64'"> <PropertyGroup Condition="'$(RuntimeIdentifier)' == 'linux-musl-x64'">
<PackageName>$(PackagePrefix)-$(PackageVersion)_alpine_x86_64$(DebugPackage)</PackageName> <PackageName>$(PackagePrefix)-$(PackageVersion)_alpine_x86_64$(DebugPackage)</PackageName>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition="'$(RuntimeIdentifier)' == 'linux-arm64'"> <PropertyGroup Condition="'$(RuntimeIdentifier)' == 'linux-arm64'">
<PackageName>$(PackagePrefix)-$(PackageVersion)_linux_arm64$(DebugPackage)</PackageName> <PackageName>$(PackagePrefix)-$(PackageVersion)_linux_arm64$(DebugPackage)</PackageName>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition="'$(RuntimeIdentifier)' == 'linux-arm'"> <PropertyGroup Condition="'$(RuntimeIdentifier)' == 'linux-arm'">
<PackageName>$(PackagePrefix)-$(PackageVersion)_linux_armhf$(DebugPackage)</PackageName> <PackageName>$(PackagePrefix)-$(PackageVersion)_linux_armhf$(DebugPackage)</PackageName>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition="'$(RuntimeIdentifier)' == 'linux-x64'"> <PropertyGroup Condition="'$(RuntimeIdentifier)' == 'linux-x64'">
<PackageName>$(PackagePrefix)-$(PackageVersion)_linux_amd64$(DebugPackage)</PackageName> <PackageName>$(PackagePrefix)-$(PackageVersion)_linux_amd64$(DebugPackage)</PackageName>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition="'$(RuntimeIdentifier)' == 'osx-x64'"> <PropertyGroup Condition="'$(RuntimeIdentifier)' == 'osx-x64'">
<PackageName>$(PackagePrefix)-$(PackageVersion)_macos$(DebugPackage)</PackageName> <PackageName>$(PackagePrefix)-$(PackageVersion)_macos$(DebugPackage)</PackageName>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition="'$(RuntimeIdentifier)' == 'osx-arm64'"> <PropertyGroup Condition="'$(RuntimeIdentifier)' == 'osx-arm64'">
<PackageName>$(PackagePrefix)-$(PackageVersion)_macos_applesilicon$(DebugPackage)</PackageName> <PackageName>$(PackagePrefix)-$(PackageVersion)_macos_applesilicon$(DebugPackage)</PackageName>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition="'$(RuntimeIdentifier)' == 'win-arm64'"> <PropertyGroup Condition="'$(RuntimeIdentifier)' == 'win-arm64'">
<PackageName>$(PackagePrefix)-$(PackageVersion)_windows_aarch64$(DebugPackage)</PackageName> <PackageName>$(PackagePrefix)-$(PackageVersion)_windows_aarch64$(DebugPackage)</PackageName>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition="'$(RuntimeIdentifier)' == 'win-arm'"> <PropertyGroup Condition="'$(RuntimeIdentifier)' == 'win-arm'">
<PackageName>$(PackagePrefix)-$(PackageVersion)_windows_arm$(DebugPackage)</PackageName> <PackageName>$(PackagePrefix)-$(PackageVersion)_windows_arm$(DebugPackage)</PackageName>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition="'$(RuntimeIdentifier)' == 'win-x64'"> <PropertyGroup Condition="'$(RuntimeIdentifier)' == 'win-x64'">
<PackageName>$(PackagePrefix)-$(PackageVersion)_windows_x64$(DebugPackage)</PackageName> <PackageName>$(PackagePrefix)-$(PackageVersion)_windows_x64$(DebugPackage)</PackageName>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition="'$(RuntimeIdentifier)' == 'win-x86'"> <PropertyGroup Condition="'$(RuntimeIdentifier)' == 'win-x86'">
<PackageName>$(PackagePrefix)-$(PackageVersion)_windows_x86$(DebugPackage)</PackageName> <PackageName>$(PackagePrefix)-$(PackageVersion)_windows_x86$(DebugPackage)</PackageName>
</PropertyGroup> </PropertyGroup>
<!-- TODO: Distribution specific RIDs where removed in .NET 8.0. We need to detect packaging in another way <!-- TODO: Distribution specific RIDs where removed in .NET 8.0. We need to detect packaging in another way
<PropertyGroup Condition="'$(RuntimeIdentifier)' == 'debian-arm64'"> <PropertyGroup Condition="'$(RuntimeIdentifier)' == 'debian-arm64'">
<PackageName>$(PackagePrefix)_$(PackageVersion)_arm64$(DebugPackage)</PackageName> <PackageName>$(PackagePrefix)_$(PackageVersion)_arm64$(DebugPackage)</PackageName>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition="'$(RuntimeIdentifier)' == 'debian-arm'"> <PropertyGroup Condition="'$(RuntimeIdentifier)' == 'debian-arm'">
<PackageName>$(PackagePrefix)_$(PackageVersion)_armhf$(DebugPackage)</PackageName> <PackageName>$(PackagePrefix)_$(PackageVersion)_armhf$(DebugPackage)</PackageName>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition="'$(RuntimeIdentifier)' == 'debian-x64'"> <PropertyGroup Condition="'$(RuntimeIdentifier)' == 'debian-x64'">
<PackageName>$(PackagePrefix)_$(PackageVersion)_amd64$(DebugPackage)</PackageName> <PackageName>$(PackagePrefix)_$(PackageVersion)_amd64$(DebugPackage)</PackageName>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition="'$(RuntimeIdentifier)' == 'rhel-arm64'"> <PropertyGroup Condition="'$(RuntimeIdentifier)' == 'rhel-arm64'">
<PackageName>$(PackagePrefix)-$(PackageVersion).el.aarch64$(DebugPackage)</PackageName> <PackageName>$(PackagePrefix)-$(PackageVersion).el.aarch64$(DebugPackage)</PackageName>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition="'$(RuntimeIdentifier)' == 'rhel-x64'"> <PropertyGroup Condition="'$(RuntimeIdentifier)' == 'rhel-x64'">
<PackageName>$(PackagePrefix)-$(PackageVersion).el.x86_64$(DebugPackage)</PackageName> <PackageName>$(PackagePrefix)-$(PackageVersion).el.x86_64$(DebugPackage)</PackageName>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition="'$(RuntimeIdentifier)' == 'sles-x64'"> <PropertyGroup Condition="'$(RuntimeIdentifier)' == 'sles-x64'">
<PackageName>$(PackagePrefix)-$(PackageVersion).sles.x86_64$(DebugPackage)</PackageName> <PackageName>$(PackagePrefix)-$(PackageVersion).sles.x86_64$(DebugPackage)</PackageName>
</PropertyGroup> </PropertyGroup>
--> -->
</Project> </Project>

View File

@@ -69,27 +69,29 @@ sealed class ArchiveInfoCommand : Command
}); });
AaruConsole.DebugWriteLineEvent += (format, objects) => AaruConsole.DebugWriteLineEvent += (format, objects) =>
{ {
if(objects is null) if(objects is null)
stderrConsole.MarkupLine(format); stderrConsole.MarkupLine(format);
else else
stderrConsole.MarkupLine(format, objects); stderrConsole.MarkupLine(format, objects);
}; };
} }
if(verbose) if(verbose)
{
AaruConsole.WriteEvent += (format, objects) => AaruConsole.WriteEvent += (format, objects) =>
{ {
if(objects is null) if(objects is null)
AnsiConsole.Markup(format); AnsiConsole.Markup(format);
else else
AnsiConsole.Markup(format, objects); AnsiConsole.Markup(format, objects);
}; };
}
Statistics.AddCommand("archive-info"); Statistics.AddCommand("archive-info");
AaruConsole.DebugWriteLine(MODULE_NAME, "--debug={0}", debug); AaruConsole.DebugWriteLine(MODULE_NAME, "--debug={0}", debug);
AaruConsole.DebugWriteLine(MODULE_NAME, "--input={0}", imagePath); AaruConsole.DebugWriteLine(MODULE_NAME, "--input={0}", imagePath);
AaruConsole.DebugWriteLine(MODULE_NAME, "--verbose={0}", verbose); AaruConsole.DebugWriteLine(MODULE_NAME, "--verbose={0}", verbose);
/* TODO: This is just a stub for now */ /* TODO: This is just a stub for now */

View File

@@ -58,22 +58,24 @@ sealed class ConfigureCommand : Command
}); });
AaruConsole.DebugWriteLineEvent += (format, objects) => AaruConsole.DebugWriteLineEvent += (format, objects) =>
{ {
if(objects is null) if(objects is null)
stderrConsole.MarkupLine(format); stderrConsole.MarkupLine(format);
else else
stderrConsole.MarkupLine(format, objects); stderrConsole.MarkupLine(format, objects);
}; };
} }
if(verbose) if(verbose)
{
AaruConsole.WriteEvent += (format, objects) => AaruConsole.WriteEvent += (format, objects) =>
{ {
if(objects is null) if(objects is null)
AnsiConsole.Markup(format); AnsiConsole.Markup(format);
else else
AnsiConsole.Markup(format, objects); AnsiConsole.Markup(format, objects);
}; };
}
return DoConfigure(false); return DoConfigure(false);
} }
@@ -100,7 +102,8 @@ sealed class ConfigureCommand : Command
Settings.Settings.Current.EnableDecryption = Settings.Settings.Current.EnableDecryption =
AnsiConsole.Confirm($"[italic]{UI.Do_you_want_to_enable_decryption_of_copy_protected_media_Q}[/]"); 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();
AaruConsole.WriteLine(UI.Configure_Device_Report_information_disclaimer); AaruConsole.WriteLine(UI.Configure_Device_Report_information_disclaimer);
@@ -114,9 +117,11 @@ sealed class ConfigureCommand : Command
Settings.Settings.Current.ShareReports = Settings.Settings.Current.ShareReports =
AnsiConsole.Confirm($"[italic]{UI.Do_you_want_to_share_your_device_reports_with_us_Q}[/]"); 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();
AaruConsole.WriteLine(UI.Statistics_disclaimer); AaruConsole.WriteLine(UI.Statistics_disclaimer);
@@ -151,7 +156,8 @@ sealed class ConfigureCommand : Command
} }
else else
Settings.Settings.Current.Stats = null; Settings.Settings.Current.Stats = null;
#endregion Statistics
#endregion Statistics
Settings.Settings.Current.GdprCompliance = DicSettings.GDPR_LEVEL; Settings.Settings.Current.GdprCompliance = DicSettings.GDPR_LEVEL;
Settings.Settings.SaveSettings(); Settings.Settings.SaveSettings();

View File

@@ -59,22 +59,24 @@ sealed class StatisticsCommand : Command
}); });
AaruConsole.DebugWriteLineEvent += (format, objects) => AaruConsole.DebugWriteLineEvent += (format, objects) =>
{ {
if(objects is null) if(objects is null)
stderrConsole.MarkupLine(format); stderrConsole.MarkupLine(format);
else else
stderrConsole.MarkupLine(format, objects); stderrConsole.MarkupLine(format, objects);
}; };
} }
if(verbose) if(verbose)
{
AaruConsole.WriteEvent += (format, objects) => AaruConsole.WriteEvent += (format, objects) =>
{ {
if(objects is null) if(objects is null)
AnsiConsole.Markup(format); AnsiConsole.Markup(format);
else else
AnsiConsole.Markup(format, objects); AnsiConsole.Markup(format, objects);
}; };
}
var ctx = AaruContext.Create(Settings.Settings.LocalDbPath); var ctx = AaruContext.Create(Settings.Settings.LocalDbPath);
@@ -91,7 +93,7 @@ sealed class StatisticsCommand : Command
return (int)ErrorNumber.NothingFound; return (int)ErrorNumber.NothingFound;
} }
bool thereAreStats = false; var thereAreStats = false;
Table table; Table table;
if(ctx.Commands.Any()) if(ctx.Commands.Any())
@@ -116,19 +118,21 @@ sealed class StatisticsCommand : Command
ulong count = 0; ulong count = 0;
foreach(Aaru.Database.Models.Command fsInfo in ctx.Commands.Where(c => c.Name == "fs-info" && foreach(Aaru.Database.Models.Command fsInfo in ctx.Commands.Where(c => c.Name == "fs-info" &&
c.Synchronized)) c.Synchronized))
{ {
count += fsInfo.Count; count += fsInfo.Count;
ctx.Remove(fsInfo); ctx.Remove(fsInfo);
} }
if(count > 0) if(count > 0)
{
ctx.Commands.Add(new Aaru.Database.Models.Command ctx.Commands.Add(new Aaru.Database.Models.Command
{ {
Count = count, Count = count,
Name = "fs-info", Name = "fs-info",
Synchronized = true Synchronized = true
}); });
}
ctx.SaveChanges(); ctx.SaveChanges();
} }
@@ -281,8 +285,10 @@ sealed class StatisticsCommand : Command
foreach(DeviceStat ds in ctx.SeenDevices.OrderBy(ds => ds.Manufacturer).ThenBy(ds => ds.Model). foreach(DeviceStat ds in ctx.SeenDevices.OrderBy(ds => ds.Manufacturer).ThenBy(ds => ds.Model).
ThenBy(ds => ds.Revision).ThenBy(ds => ds.Bus)) ThenBy(ds => ds.Revision).ThenBy(ds => ds.Bus))
{
table.AddRow(Markup.Escape(ds.Manufacturer ?? ""), Markup.Escape(ds.Model ?? ""), table.AddRow(Markup.Escape(ds.Manufacturer ?? ""), Markup.Escape(ds.Model ?? ""),
Markup.Escape(ds.Revision ?? ""), Markup.Escape(ds.Bus ?? "")); Markup.Escape(ds.Revision ?? ""), Markup.Escape(ds.Bus ?? ""));
}
AnsiConsole.Write(table); AnsiConsole.Write(table);
AaruConsole.WriteLine(); AaruConsole.WriteLine();

View File

@@ -54,7 +54,7 @@ sealed class UpdateCommand : Command
{ {
_mainDbUpdate = mainDbUpdate; _mainDbUpdate = mainDbUpdate;
Add(new Option<bool>("--clear", () => false, UI.Clear_existing_main_database)); Add(new Option<bool>("--clear", () => false, UI.Clear_existing_main_database));
Add(new Option<bool>("--clear-all", () => false, UI.Clear_existing_main_and_local_database)); Add(new Option<bool>("--clear-all", () => false, UI.Clear_existing_main_and_local_database));
Handler = CommandHandler.Create((Func<bool, bool, bool, bool, int>)Invoke); Handler = CommandHandler.Create((Func<bool, bool, bool, bool, int>)Invoke);
@@ -75,27 +75,30 @@ sealed class UpdateCommand : Command
}); });
AaruConsole.DebugWriteLineEvent += (format, objects) => AaruConsole.DebugWriteLineEvent += (format, objects) =>
{ {
if(objects is null) if(objects is null)
stderrConsole.MarkupLine(format); stderrConsole.MarkupLine(format);
else else
stderrConsole.MarkupLine(format, objects); stderrConsole.MarkupLine(format, objects);
}; };
} }
if(verbose) if(verbose)
{
AaruConsole.WriteEvent += (format, objects) => AaruConsole.WriteEvent += (format, objects) =>
{ {
if(objects is null) if(objects is null)
AnsiConsole.Markup(format); AnsiConsole.Markup(format);
else else
AnsiConsole.Markup(format, objects); 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); AaruConsole.DebugWriteLine(MODULE_NAME, "--verbose={0}", verbose);
if(clearAll) if(clearAll)
{
try try
{ {
File.Delete(Settings.Settings.LocalDbPath); File.Delete(Settings.Settings.LocalDbPath);
@@ -113,8 +116,10 @@ sealed class UpdateCommand : Command
return (int)ErrorNumber.CannotRemoveDatabase; return (int)ErrorNumber.CannotRemoveDatabase;
} }
}
if(clear || clearAll) if(clear || clearAll)
{
try try
{ {
File.Delete(Settings.Settings.MainDbPath); File.Delete(Settings.Settings.MainDbPath);
@@ -128,6 +133,7 @@ sealed class UpdateCommand : Command
return (int)ErrorNumber.CannotRemoveDatabase; return (int)ErrorNumber.CannotRemoveDatabase;
} }
}
DoUpdate(clear || clearAll); DoUpdate(clear || clearAll);

File diff suppressed because it is too large Load Diff

View File

@@ -68,10 +68,7 @@ sealed class DeviceInfoCommand : Command
public DeviceInfoCommand() : base("info", UI.Device_Info_Command_Description) public DeviceInfoCommand() : base("info", UI.Device_Info_Command_Description)
{ {
Add(new Option<string>(new[] Add(new Option<string>(new[] { "--output-prefix", "-w" }, () => null, UI.Prefix_for_saving_binary_information));
{
"--output-prefix", "-w"
}, () => null, UI.Prefix_for_saving_binary_information));
AddArgument(new Argument<string> AddArgument(new Argument<string>
{ {
@@ -95,29 +92,31 @@ sealed class DeviceInfoCommand : Command
}); });
AaruConsole.DebugWriteLineEvent += (format, objects) => AaruConsole.DebugWriteLineEvent += (format, objects) =>
{ {
if(objects is null) if(objects is null)
stderrConsole.MarkupLine(format); stderrConsole.MarkupLine(format);
else else
stderrConsole.MarkupLine(format, objects); stderrConsole.MarkupLine(format, objects);
}; };
} }
if(verbose) if(verbose)
{
AaruConsole.WriteEvent += (format, objects) => AaruConsole.WriteEvent += (format, objects) =>
{ {
if(objects is null) if(objects is null)
AnsiConsole.Markup(format); AnsiConsole.Markup(format);
else else
AnsiConsole.Markup(format, objects); AnsiConsole.Markup(format, objects);
}; };
}
Statistics.AddCommand("device-info"); Statistics.AddCommand("device-info");
AaruConsole.DebugWriteLine(MODULE_NAME, "--debug={0}", debug); AaruConsole.DebugWriteLine(MODULE_NAME, "--debug={0}", debug);
AaruConsole.DebugWriteLine(MODULE_NAME, "--device={0}", devicePath); AaruConsole.DebugWriteLine(MODULE_NAME, "--device={0}", devicePath);
AaruConsole.DebugWriteLine(MODULE_NAME, "--output-prefix={0}", outputPrefix); 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 && if(devicePath.Length == 2 &&
devicePath[1] == ':' && devicePath[1] == ':' &&
@@ -167,11 +166,11 @@ sealed class DeviceInfoCommand : Command
if(dev.UsbDescriptors != null) if(dev.UsbDescriptors != null)
table.AddRow(UI.Title_Descriptor_size, $"{dev.UsbDescriptors.Length}"); table.AddRow(UI.Title_Descriptor_size, $"{dev.UsbDescriptors.Length}");
table.AddRow(UI.Title_Vendor_ID, $"{dev.UsbVendorId:X4}"); table.AddRow(UI.Title_Vendor_ID, $"{dev.UsbVendorId:X4}");
table.AddRow(UI.Title_Product_ID, $"{dev.UsbProductId:X4}"); table.AddRow(UI.Title_Product_ID, $"{dev.UsbProductId:X4}");
table.AddRow(UI.Title_Manufacturer, Markup.Escape(dev.UsbManufacturerString ?? "")); table.AddRow(UI.Title_Manufacturer, Markup.Escape(dev.UsbManufacturerString ?? ""));
table.AddRow(UI.Title_Product, Markup.Escape(dev.UsbProductString ?? "")); table.AddRow(UI.Title_Product, Markup.Escape(dev.UsbProductString ?? ""));
table.AddRow(UI.Title_Serial_number, Markup.Escape(dev.UsbSerialString ?? "")); table.AddRow(UI.Title_Serial_number, Markup.Escape(dev.UsbSerialString ?? ""));
AnsiConsole.Write(table); AnsiConsole.Write(table);
AaruConsole.WriteLine(); AaruConsole.WriteLine();
@@ -190,10 +189,10 @@ sealed class DeviceInfoCommand : Command
table.Columns[0].RightAligned(); table.Columns[0].RightAligned();
table.AddRow(UI.Title_Vendor_ID, $"{dev.FireWireVendor:X6}"); table.AddRow(UI.Title_Vendor_ID, $"{dev.FireWireVendor:X6}");
table.AddRow(UI.Title_Model_ID, $"{dev.FireWireModel:X6}"); table.AddRow(UI.Title_Model_ID, $"{dev.FireWireModel:X6}");
table.AddRow(UI.Title_Vendor, $"{Markup.Escape(dev.FireWireVendorName ?? "")}"); table.AddRow(UI.Title_Vendor, $"{Markup.Escape(dev.FireWireVendorName ?? "")}");
table.AddRow(UI.Title_Model, $"{Markup.Escape(dev.FireWireModelName ?? "")}"); table.AddRow(UI.Title_Model, $"{Markup.Escape(dev.FireWireModelName ?? "")}");
table.AddRow(UI.Title_GUID, $"{dev.FireWireGuid:X16}"); table.AddRow(UI.Title_GUID, $"{dev.FireWireGuid:X16}");
AnsiConsole.Write(table); AnsiConsole.Write(table);
AaruConsole.WriteLine(); AaruConsole.WriteLine();
@@ -206,11 +205,14 @@ sealed class DeviceInfoCommand : Command
Tuple[] tuples = CIS.GetTuples(dev.Cis); Tuple[] tuples = CIS.GetTuples(dev.Cis);
if(tuples != null) if(tuples != null)
{
foreach(Tuple tuple in tuples) foreach(Tuple tuple in tuples)
{
switch(tuple.Code) switch(tuple.Code)
{ {
case TupleCodes.CISTPL_NULL: case TupleCodes.CISTPL_NULL:
case TupleCodes.CISTPL_END: break; case TupleCodes.CISTPL_END:
break;
case TupleCodes.CISTPL_DEVICEGEO: case TupleCodes.CISTPL_DEVICEGEO:
case TupleCodes.CISTPL_DEVICEGEO_A: case TupleCodes.CISTPL_DEVICEGEO_A:
AaruConsole.WriteLine("{0}", CIS.PrettifyDeviceGeometryTuple(tuple)); AaruConsole.WriteLine("{0}", CIS.PrettifyDeviceGeometryTuple(tuple));
@@ -268,6 +270,8 @@ sealed class DeviceInfoCommand : Command
break; break;
} }
}
}
else else
AaruConsole.DebugWriteLine(MODULE_NAME, Localization.Core.Could_not_get_tuples); 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) if((devInfo.AtaMcptError.Value.DeviceHead & 0x08) == 0x08)
AaruConsole.WriteLine(Localization.Core.Media_card_is_write_protected); AaruConsole.WriteLine(Localization.Core.Media_card_is_write_protected);
ushort specificData = (ushort)((devInfo.AtaMcptError.Value.CylinderHigh * 0x100) + var specificData = (ushort)(devInfo.AtaMcptError.Value.CylinderHigh * 0x100 +
devInfo.AtaMcptError.Value.CylinderLow); devInfo.AtaMcptError.Value.CylinderLow);
if(specificData != 0) if(specificData != 0)
AaruConsole.WriteLine(Localization.Core.Card_specific_data_0, specificData); AaruConsole.WriteLine(Localization.Core.Card_specific_data_0, specificData);
@@ -332,8 +336,10 @@ sealed class DeviceInfoCommand : Command
ulong blocks; ulong blocks;
if(ataid is { CurrentCylinders: > 0, CurrentHeads: > 0, CurrentSectorsPerTrack: > 0 }) if(ataid is { CurrentCylinders: > 0, CurrentHeads: > 0, CurrentSectorsPerTrack: > 0 })
{
blocks = (ulong)Math.Max(ataid.CurrentCylinders * ataid.CurrentHeads * ataid.CurrentSectorsPerTrack, blocks = (ulong)Math.Max(ataid.CurrentCylinders * ataid.CurrentHeads * ataid.CurrentSectorsPerTrack,
ataid.CurrentSectors); ataid.CurrentSectors);
}
else else
blocks = (ulong)(ataid.Cylinders * ataid.Heads * ataid.SectorsPerTrack); blocks = (ulong)(ataid.Cylinders * ataid.Heads * ataid.SectorsPerTrack);
@@ -375,7 +381,9 @@ sealed class DeviceInfoCommand : Command
AaruConsole.WriteLine(Inquiry.Prettify(devInfo.ScsiInquiry)); AaruConsole.WriteLine(Inquiry.Prettify(devInfo.ScsiInquiry));
if(devInfo.ScsiEvpdPages != null) if(devInfo.ScsiEvpdPages != null)
{
foreach(KeyValuePair<byte, byte[]> page in devInfo.ScsiEvpdPages) foreach(KeyValuePair<byte, byte[]> page in devInfo.ScsiEvpdPages)
{
switch(page.Key) switch(page.Key)
{ {
case >= 0x01 and <= 0x7F: case >= 0x01 and <= 0x7F:
@@ -563,19 +571,27 @@ sealed class DeviceInfoCommand : Command
break; break;
} }
} }
}
}
if(devInfo.ScsiModeSense6 != null) if(devInfo.ScsiModeSense6 != null)
{
DataFile.WriteTo(MODULE_NAME, outputPrefix, "_scsi_modesense6.bin", "SCSI MODE SENSE", DataFile.WriteTo(MODULE_NAME, outputPrefix, "_scsi_modesense6.bin", "SCSI MODE SENSE",
devInfo.ScsiModeSense6); devInfo.ScsiModeSense6);
}
if(devInfo.ScsiModeSense10 != null) if(devInfo.ScsiModeSense10 != null)
{
DataFile.WriteTo(MODULE_NAME, outputPrefix, "_scsi_modesense10.bin", "SCSI MODE SENSE", DataFile.WriteTo(MODULE_NAME, outputPrefix, "_scsi_modesense10.bin", "SCSI MODE SENSE",
devInfo.ScsiModeSense10); devInfo.ScsiModeSense10);
}
if(devInfo.ScsiMode.HasValue) if(devInfo.ScsiMode.HasValue)
{
PrintScsiModePages.Print(devInfo.ScsiMode.Value, PrintScsiModePages.Print(devInfo.ScsiMode.Value,
(PeripheralDeviceTypes)devInfo.ScsiInquiry.Value.PeripheralDeviceType, (PeripheralDeviceTypes)devInfo.ScsiInquiry.Value.PeripheralDeviceType,
devInfo.ScsiInquiry.Value.VendorIdentification); devInfo.ScsiInquiry.Value.VendorIdentification);
}
if(devInfo.MmcConfiguration != null) if(devInfo.MmcConfiguration != null)
{ {
@@ -841,8 +857,10 @@ sealed class DeviceInfoCommand : Command
} }
} }
else else
{
AaruConsole.DebugWriteLine(MODULE_NAME, AaruConsole.DebugWriteLine(MODULE_NAME,
Localization.Core.GET_CONFIGURATION_returned_no_feature_descriptors); Localization.Core.GET_CONFIGURATION_returned_no_feature_descriptors);
}
} }
if(devInfo.RPC != null) if(devInfo.RPC != null)
@@ -879,26 +897,34 @@ sealed class DeviceInfoCommand : Command
if(devInfo.PlextorFeatures.PoweRecEnabled) if(devInfo.PlextorFeatures.PoweRecEnabled)
{ {
if(devInfo.PlextorFeatures.PoweRecRecommendedSpeed > 0) if(devInfo.PlextorFeatures.PoweRecRecommendedSpeed > 0)
{
AaruConsole.WriteLine(Localization.Core.Drive_supports_PoweRec_is_enabled_and_recommends_0, AaruConsole.WriteLine(Localization.Core.Drive_supports_PoweRec_is_enabled_and_recommends_0,
devInfo.PlextorFeatures.PoweRecRecommendedSpeed); devInfo.PlextorFeatures.PoweRecRecommendedSpeed);
}
else else
AaruConsole.WriteLine(Localization.Core.Drive_supports_PoweRec_and_has_it_enabled); AaruConsole.WriteLine(Localization.Core.Drive_supports_PoweRec_and_has_it_enabled);
if(devInfo.PlextorFeatures.PoweRecSelected > 0) if(devInfo.PlextorFeatures.PoweRecSelected > 0)
{
AaruConsole. AaruConsole.
WriteLine(Localization.Core.Selected_PoweRec_speed_for_currently_inserted_media_is_0_1, WriteLine(Localization.Core.Selected_PoweRec_speed_for_currently_inserted_media_is_0_1,
devInfo.PlextorFeatures.PoweRecSelected, devInfo.PlextorFeatures.PoweRecSelected,
devInfo.PlextorFeatures.PoweRecSelected / 177); devInfo.PlextorFeatures.PoweRecSelected / 177);
}
if(devInfo.PlextorFeatures.PoweRecMax > 0) if(devInfo.PlextorFeatures.PoweRecMax > 0)
{
AaruConsole. AaruConsole.
WriteLine(Localization.Core.Maximum_PoweRec_speed_for_currently_inserted_media_is_0_1, WriteLine(Localization.Core.Maximum_PoweRec_speed_for_currently_inserted_media_is_0_1,
devInfo.PlextorFeatures.PoweRecMax, devInfo.PlextorFeatures.PoweRecMax / 177); devInfo.PlextorFeatures.PoweRecMax, devInfo.PlextorFeatures.PoweRecMax / 177);
}
if(devInfo.PlextorFeatures.PoweRecLast > 0) if(devInfo.PlextorFeatures.PoweRecLast > 0)
{
AaruConsole.WriteLine(Localization.Core.Last_used_PoweRec_was_0_1, AaruConsole.WriteLine(Localization.Core.Last_used_PoweRec_was_0_1,
devInfo.PlextorFeatures.PoweRecLast, devInfo.PlextorFeatures.PoweRecLast,
devInfo.PlextorFeatures.PoweRecLast / 177); devInfo.PlextorFeatures.PoweRecLast / 177);
}
} }
else else
AaruConsole.WriteLine(Localization.Core.Drive_supports_PoweRec_and_has_it_disabled); 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)); : Localization.Core.Access_time_is_fast));
if(devInfo.PlextorFeatures.CdReadSpeedLimit > 0) if(devInfo.PlextorFeatures.CdReadSpeedLimit > 0)
{
AaruConsole.WriteLine("\t" + Localization.Core.CD_read_speed_limited_to_0, AaruConsole.WriteLine("\t" + Localization.Core.CD_read_speed_limited_to_0,
devInfo.PlextorFeatures.CdReadSpeedLimit); devInfo.PlextorFeatures.CdReadSpeedLimit);
}
if(devInfo.PlextorFeatures.DvdReadSpeedLimit > 0 && if(devInfo.PlextorFeatures.DvdReadSpeedLimit > 0 &&
devInfo.PlextorFeatures.IsDvd) devInfo.PlextorFeatures.IsDvd)
{
AaruConsole.WriteLine("\t" + Localization.Core.DVD_read_speed_limited_to_0, AaruConsole.WriteLine("\t" + Localization.Core.DVD_read_speed_limited_to_0,
devInfo.PlextorFeatures.DvdReadSpeedLimit); devInfo.PlextorFeatures.DvdReadSpeedLimit);
}
if(devInfo.PlextorFeatures.CdWriteSpeedLimit > 0) if(devInfo.PlextorFeatures.CdWriteSpeedLimit > 0)
{
AaruConsole.WriteLine("\t" + Localization.Core.CD_write_speed_limited_to_0, AaruConsole.WriteLine("\t" + Localization.Core.CD_write_speed_limited_to_0,
devInfo.PlextorFeatures.CdWriteSpeedLimit); devInfo.PlextorFeatures.CdWriteSpeedLimit);
}
} }
} }
@@ -938,9 +970,11 @@ sealed class DeviceInfoCommand : Command
AaruConsole.WriteLine(Localization.Core.Drive_supports_Plextor_SecuRec); AaruConsole.WriteLine(Localization.Core.Drive_supports_Plextor_SecuRec);
if(devInfo.PlextorFeatures?.SpeedRead == true) if(devInfo.PlextorFeatures?.SpeedRead == true)
{
AaruConsole.WriteLine(devInfo.PlextorFeatures.SpeedReadEnabled AaruConsole.WriteLine(devInfo.PlextorFeatures.SpeedReadEnabled
? Localization.Core.Drive_supports_Plextor_SpeedRead_and_has_it_enabled ? Localization.Core.Drive_supports_Plextor_SpeedRead_and_has_it_enabled
: Localization.Core.Drive_supports_Plextor_SpeedRead); : Localization.Core.Drive_supports_Plextor_SpeedRead);
}
if(devInfo.PlextorFeatures?.Hiding == true) if(devInfo.PlextorFeatures?.Hiding == true)
{ {
@@ -1046,7 +1080,7 @@ sealed class DeviceInfoCommand : Command
{ {
case DeviceType.MMC: case DeviceType.MMC:
{ {
bool noInfo = true; var noInfo = true;
if(devInfo.CID != null) if(devInfo.CID != null)
{ {
@@ -1086,7 +1120,7 @@ sealed class DeviceInfoCommand : Command
break; break;
case DeviceType.SecureDigital: case DeviceType.SecureDigital:
{ {
bool noInfo = true; var noInfo = true;
if(devInfo.CID != null) if(devInfo.CID != null)
{ {
@@ -1166,7 +1200,8 @@ sealed class DeviceInfoCommand : Command
d.Manufacturer == dev.Manufacturer.Replace('/', '-')) && d.Manufacturer == dev.Manufacturer.Replace('/', '-')) &&
(d.Model == dev.Model || d.Model == dev.Model.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)."); : $"CD reading offset is {cdOffset.Offset} samples ({cdOffset.Offset * 4} bytes).");
return (int)ErrorNumber.NoError; return (int)ErrorNumber.NoError;

View File

@@ -71,26 +71,28 @@ sealed class ListDevicesCommand : Command
}); });
AaruConsole.DebugWriteLineEvent += (format, objects) => AaruConsole.DebugWriteLineEvent += (format, objects) =>
{ {
if(objects is null) if(objects is null)
stderrConsole.MarkupLine(format); stderrConsole.MarkupLine(format);
else else
stderrConsole.MarkupLine(format, objects); stderrConsole.MarkupLine(format, objects);
}; };
} }
if(verbose) if(verbose)
{
AaruConsole.WriteEvent += (format, objects) => AaruConsole.WriteEvent += (format, objects) =>
{ {
if(objects is null) if(objects is null)
AnsiConsole.Markup(format); AnsiConsole.Markup(format);
else else
AnsiConsole.Markup(format, objects); AnsiConsole.Markup(format, objects);
}; };
}
Statistics.AddCommand("list-devices"); 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); AaruConsole.DebugWriteLine(MODULE_NAME, "--verbose={0}", verbose);
DeviceInfo[] devices = Devices.Device.ListDevices(out bool isRemote, out string serverApplication, DeviceInfo[] devices = Devices.Device.ListDevices(out bool isRemote, out string serverApplication,
@@ -99,8 +101,10 @@ sealed class ListDevicesCommand : Command
out string serverArchitecture, aaruRemoteHost); out string serverArchitecture, aaruRemoteHost);
if(isRemote) if(isRemote)
{
Statistics.AddRemote(serverApplication, serverVersion, serverOperatingSystem, serverOperatingSystemVersion, Statistics.AddRemote(serverApplication, serverVersion, serverOperatingSystem, serverOperatingSystemVersion,
serverArchitecture); serverArchitecture);
}
if(devices == null || if(devices == null ||
devices.Length == 0) devices.Length == 0)
@@ -116,9 +120,11 @@ sealed class ListDevicesCommand : Command
table.AddColumn(UI.Supported_Question); table.AddColumn(UI.Supported_Question);
foreach(DeviceInfo dev in devices.OrderBy(d => d.Path)) foreach(DeviceInfo dev in devices.OrderBy(d => d.Path))
{
table.AddRow(Markup.Escape(dev.Path ?? ""), Markup.Escape(dev.Vendor ?? ""), table.AddRow(Markup.Escape(dev.Path ?? ""), Markup.Escape(dev.Vendor ?? ""),
Markup.Escape(dev.Model ?? ""), Markup.Escape(dev.Serial ?? ""), Markup.Escape(dev.Model ?? ""), Markup.Escape(dev.Serial ?? ""),
Markup.Escape(dev.Bus ?? ""), dev.Supported ? "[green]✓[/]" : "[red]✗[/]"); Markup.Escape(dev.Bus ?? ""), dev.Supported ? "[green]✓[/]" : "[red]✗[/]");
}
AnsiConsole.Write(table); AnsiConsole.Write(table);
} }

View File

@@ -57,25 +57,14 @@ sealed class ExtractFilesCommand : Command
public ExtractFilesCommand() : base("extract", UI.Filesystem_Extract_Command_Description) public ExtractFilesCommand() : base("extract", UI.Filesystem_Extract_Command_Description)
{ {
Add(new Option<string>(new[] Add(new Option<string>(new[] { "--encoding", "-e" }, () => null, UI.Name_of_character_encoding_to_use));
{
"--encoding", "-e"
}, () => null, UI.Name_of_character_encoding_to_use));
Add(new Option<string>(new[] Add(new Option<string>(new[] { "--options", "-O" }, () => null,
{ UI.Comma_separated_name_value_pairs_of_filesystem_options));
"--options", "-O"
}, () => null, UI.Comma_separated_name_value_pairs_of_filesystem_options));
Add(new Option<bool>(new[] Add(new Option<bool>(new[] { "--xattrs", "-x" }, () => false, UI.Extract_extended_attributes_if_present));
{
"--xattrs", "-x"
}, () => false, UI.Extract_extended_attributes_if_present));
Add(new Option<string>(new[] Add(new Option<string>(new[] { "--namespace", "-n" }, () => null, UI.Namespace_to_use_for_filenames));
{
"--namespace", "-n"
}, () => null, UI.Namespace_to_use_for_filenames));
AddArgument(new Argument<string> AddArgument(new Argument<string>
{ {
@@ -94,7 +83,7 @@ sealed class ExtractFilesCommand : Command
Handler = CommandHandler.Create(GetType().GetMethod(nameof(Invoke))); 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) string @namespace, string outputDir, string options)
{ {
MainClass.PrintCopyright(); MainClass.PrintCopyright();
@@ -107,41 +96,43 @@ sealed class ExtractFilesCommand : Command
}); });
AaruConsole.DebugWriteLineEvent += (format, objects) => AaruConsole.DebugWriteLineEvent += (format, objects) =>
{ {
if(objects is null) if(objects is null)
stderrConsole.MarkupLine(format); stderrConsole.MarkupLine(format);
else else
stderrConsole.MarkupLine(format, objects); stderrConsole.MarkupLine(format, objects);
}; };
} }
if(verbose) if(verbose)
{
AaruConsole.WriteEvent += (format, objects) => AaruConsole.WriteEvent += (format, objects) =>
{ {
if(objects is null) if(objects is null)
AnsiConsole.Markup(format); AnsiConsole.Markup(format);
else else
AnsiConsole.Markup(format, objects); AnsiConsole.Markup(format, objects);
}; };
}
Statistics.AddCommand("extract-files"); 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, "--encoding={0}", encoding);
AaruConsole.DebugWriteLine(MODULE_NAME, "--input={0}", imagePath); AaruConsole.DebugWriteLine(MODULE_NAME, "--input={0}", imagePath);
AaruConsole.DebugWriteLine(MODULE_NAME, "--options={0}", options); AaruConsole.DebugWriteLine(MODULE_NAME, "--options={0}", options);
AaruConsole.DebugWriteLine(MODULE_NAME, "--output={0}", outputDir); AaruConsole.DebugWriteLine(MODULE_NAME, "--output={0}", outputDir);
AaruConsole.DebugWriteLine(MODULE_NAME, "--verbose={0}", verbose); AaruConsole.DebugWriteLine(MODULE_NAME, "--verbose={0}", verbose);
AaruConsole.DebugWriteLine(MODULE_NAME, "--xattrs={0}", xattrs); AaruConsole.DebugWriteLine(MODULE_NAME, "--xattrs={0}", xattrs);
var filtersList = new FiltersList(); var filtersList = new FiltersList();
IFilter inputFilter = null; IFilter inputFilter = null;
Core.Spectre.ProgressSingleSpinner(ctx => Core.Spectre.ProgressSingleSpinner(ctx =>
{ {
ctx.AddTask(UI.Identifying_file_filter).IsIndeterminate(); ctx.AddTask(UI.Identifying_file_filter).IsIndeterminate();
inputFilter = filtersList.GetFilter(imagePath); inputFilter = filtersList.GetFilter(imagePath);
}); });
Dictionary<string, string> parsedOptions = Core.Options.Parse(options); Dictionary<string, string> parsedOptions = Core.Options.Parse(options);
AaruConsole.DebugWriteLine(MODULE_NAME, UI.Parsed_options); AaruConsole.DebugWriteLine(MODULE_NAME, UI.Parsed_options);
@@ -161,6 +152,7 @@ sealed class ExtractFilesCommand : Command
Encoding encodingClass = null; Encoding encodingClass = null;
if(encoding != null) if(encoding != null)
{
try try
{ {
encodingClass = Claunia.Encoding.Encoding.GetEncoding(encoding); encodingClass = Claunia.Encoding.Encoding.GetEncoding(encoding);
@@ -174,6 +166,7 @@ sealed class ExtractFilesCommand : Command
return (int)ErrorNumber.EncodingUnknown; return (int)ErrorNumber.EncodingUnknown;
} }
}
PluginBase plugins = PluginBase.Singleton; PluginBase plugins = PluginBase.Singleton;
@@ -183,11 +176,11 @@ sealed class ExtractFilesCommand : Command
IBaseImage baseImage = null; IBaseImage baseImage = null;
Core.Spectre.ProgressSingleSpinner(ctx => Core.Spectre.ProgressSingleSpinner(ctx =>
{ {
ctx.AddTask(UI.Identifying_image_format).IsIndeterminate(); ctx.AddTask(UI.Identifying_image_format).IsIndeterminate();
baseImage = ImageFormat.Detect(inputFilter); baseImage = ImageFormat.Detect(inputFilter);
imageFormat = baseImage as IMediaImage; imageFormat = baseImage as IMediaImage;
}); });
if(baseImage == null) if(baseImage == null)
{ {
@@ -230,10 +223,10 @@ sealed class ExtractFilesCommand : Command
ErrorNumber opened = ErrorNumber.NoData; ErrorNumber opened = ErrorNumber.NoData;
Core.Spectre.ProgressSingleSpinner(ctx => Core.Spectre.ProgressSingleSpinner(ctx =>
{ {
ctx.AddTask(UI.Invoke_Opening_image_file).IsIndeterminate(); ctx.AddTask(UI.Invoke_Opening_image_file).IsIndeterminate();
opened = imageFormat.Open(inputFilter); opened = imageFormat.Open(inputFilter);
}); });
if(opened != ErrorNumber.NoError) if(opened != ErrorNumber.NoError)
{ {
@@ -268,10 +261,10 @@ sealed class ExtractFilesCommand : Command
List<Partition> partitions = null; List<Partition> partitions = null;
Core.Spectre.ProgressSingleSpinner(ctx => Core.Spectre.ProgressSingleSpinner(ctx =>
{ {
ctx.AddTask(UI.Enumerating_partitions).IsIndeterminate(); ctx.AddTask(UI.Enumerating_partitions).IsIndeterminate();
partitions = Core.Partitions.GetAll(imageFormat); partitions = Core.Partitions.GetAll(imageFormat);
}); });
Core.Partitions.AddSchemesToStats(partitions); Core.Partitions.AddSchemesToStats(partitions);
@@ -292,7 +285,7 @@ sealed class ExtractFilesCommand : Command
AaruConsole.WriteLine(UI._0_partitions_found, partitions.Count); 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();
AaruConsole.WriteLine($"[bold]{string.Format(UI.Partition_0, partitions[i].Sequence)}[/]"); AaruConsole.WriteLine($"[bold]{string.Format(UI.Partition_0, partitions[i].Sequence)}[/]");
@@ -300,10 +293,12 @@ sealed class ExtractFilesCommand : Command
List<string> idPlugins = null; List<string> idPlugins = null;
Core.Spectre.ProgressSingleSpinner(ctx => Core.Spectre.ProgressSingleSpinner(ctx =>
{ {
ctx.AddTask(UI.Identifying_filesystems_on_partition).IsIndeterminate(); ctx.AddTask(UI.Identifying_filesystems_on_partition).
Core.Filesystems.Identify(imageFormat, out idPlugins, partitions[i]); IsIndeterminate();
}); Core.Filesystems.Identify(imageFormat, out idPlugins,
partitions[i]);
});
if(idPlugins.Count == 0) if(idPlugins.Count == 0)
AaruConsole.WriteLine(UI.Filesystem_not_identified); AaruConsole.WriteLine(UI.Filesystem_not_identified);
@@ -318,6 +313,7 @@ sealed class ExtractFilesCommand : Command
}[/]"); }[/]");
foreach(string pluginName in idPlugins) foreach(string pluginName in idPlugins)
{
if(plugins.ReadOnlyFilesystems.TryGetValue(pluginName, out pluginType)) if(plugins.ReadOnlyFilesystems.TryGetValue(pluginName, out pluginType))
{ {
AaruConsole.WriteLine($"[bold]{string.Format(UI.As_identified_by_0, pluginType.Name) AaruConsole.WriteLine($"[bold]{string.Format(UI.As_identified_by_0, pluginType.Name)
@@ -327,16 +323,19 @@ sealed class ExtractFilesCommand : Command
continue; continue;
Core.Spectre.ProgressSingleSpinner(ctx => Core.Spectre.ProgressSingleSpinner(ctx =>
{ {
ctx.AddTask(UI.Mounting_filesystem).IsIndeterminate(); ctx.AddTask(UI.Mounting_filesystem).
IsIndeterminate();
error = fs.Mount(imageFormat, partitions[i], encodingClass, parsedOptions, error = fs.Mount(imageFormat, partitions[i],
@namespace); encodingClass, parsedOptions,
}); @namespace);
});
if(error == ErrorNumber.NoError) 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; : fs.Metadata.VolumeName;
ExtractFilesInDir("/", fs, volumeName, outputDir, xattrs); ExtractFilesInDir("/", fs, volumeName, outputDir, xattrs);
@@ -346,6 +345,7 @@ sealed class ExtractFilesCommand : Command
else else
AaruConsole.ErrorWriteLine(UI.Unable_to_mount_volume_error_0, error.ToString()); AaruConsole.ErrorWriteLine(UI.Unable_to_mount_volume_error_0, error.ToString());
} }
}
} }
else else
{ {
@@ -358,14 +358,17 @@ sealed class ExtractFilesCommand : Command
AaruConsole.WriteLine($"[bold]{string.Format(UI.Identified_by_0, pluginType.Name)}[/]"); AaruConsole.WriteLine($"[bold]{string.Format(UI.Identified_by_0, pluginType.Name)}[/]");
Core.Spectre.ProgressSingleSpinner(ctx => 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) 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; : fs.Metadata.VolumeName;
ExtractFilesInDir("/", fs, volumeName, outputDir, xattrs); 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, static void ExtractFilesInDir(string path, [NotNull] IReadOnlyFilesystem fs, string volumeName, string outputDir,
bool doXattrs) bool doXattrs)
{ {
if(path.StartsWith('/')) if(path.StartsWith('/'))
path = path[1..]; path = path[1..];
@@ -410,10 +413,10 @@ sealed class ExtractFilesCommand : Command
FileEntryInfo stat = new(); FileEntryInfo stat = new();
Core.Spectre.ProgressSingleSpinner(ctx => Core.Spectre.ProgressSingleSpinner(ctx =>
{ {
ctx.AddTask(UI.Retrieving_file_information).IsIndeterminate(); ctx.AddTask(UI.Retrieving_file_information).IsIndeterminate();
error = fs.Stat(path + "/" + entry, out stat); error = fs.Stat(path + "/" + entry, out stat);
}); });
if(error == ErrorNumber.NoError) if(error == ErrorNumber.NoError)
{ {
@@ -424,9 +427,11 @@ sealed class ExtractFilesCommand : Command
outputPath = Path.Combine(outputDir, fs.Metadata.Type, volumeName, path, entry); outputPath = Path.Combine(outputDir, fs.Metadata.Type, volumeName, path, entry);
if(RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) if(RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
{
outputPath = outputPath.Replace('<', '\uFF1C').Replace('>', '\uFF1E').Replace(':', '\uFF1A'). outputPath = outputPath.Replace('<', '\uFF1C').Replace('>', '\uFF1E').Replace(':', '\uFF1A').
Replace('\"', '\uFF02').Replace('|', '\uFF5C').Replace('?', '\uFF1F'). Replace('\"', '\uFF02').Replace('|', '\uFF5C').Replace('?', '\uFF1F').
Replace('*', '\uFF0A').Replace('/', '\\'); Replace('*', '\uFF0A').Replace('/', '\\');
}
Directory.CreateDirectory(outputPath); Directory.CreateDirectory(outputPath);
@@ -436,7 +441,7 @@ sealed class ExtractFilesCommand : Command
var di = new DirectoryInfo(outputPath); 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 try
{ {
if(stat.CreationTimeUtc.HasValue) if(stat.CreationTimeUtc.HasValue)
@@ -466,7 +471,7 @@ sealed class ExtractFilesCommand : Command
{ {
// ignored // 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; continue;
} }
@@ -478,21 +483,25 @@ sealed class ExtractFilesCommand : Command
List<string> xattrs = null; List<string> xattrs = null;
Core.Spectre.ProgressSingleSpinner(ctx => Core.Spectre.ProgressSingleSpinner(ctx =>
{ {
ctx.AddTask(UI.Listing_extended_attributes).IsIndeterminate(); ctx.AddTask(UI.Listing_extended_attributes).
error = fs.ListXAttr(path + "/" + entry, out xattrs); IsIndeterminate();
}); error = fs.ListXAttr(path + "/" + entry, out xattrs);
});
if(error == ErrorNumber.NoError) if(error == ErrorNumber.NoError)
{
foreach(string xattr in xattrs) foreach(string xattr in xattrs)
{ {
byte[] xattrBuf = Array.Empty<byte>(); byte[] xattrBuf = Array.Empty<byte>();
Core.Spectre.ProgressSingleSpinner(ctx => Core.Spectre.ProgressSingleSpinner(ctx =>
{ {
ctx.AddTask(UI.Reading_extended_attribute).IsIndeterminate(); ctx.AddTask(UI.Reading_extended_attribute).
error = fs.GetXattr(path + "/" + entry, xattr, ref xattrBuf); IsIndeterminate();
}); error = fs.GetXattr(path + "/" + entry, xattr,
ref xattrBuf);
});
if(error != ErrorNumber.NoError) if(error != ErrorNumber.NoError)
continue; continue;
@@ -500,10 +509,12 @@ sealed class ExtractFilesCommand : Command
outputPath = Path.Combine(outputDir, fs.Metadata.Type, volumeName, ".xattrs", path, xattr); outputPath = Path.Combine(outputDir, fs.Metadata.Type, volumeName, ".xattrs", path, xattr);
if(RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) if(RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
{
outputPath = outputPath.Replace('<', '\uFF1C').Replace('>', '\uFF1E'). outputPath = outputPath.Replace('<', '\uFF1C').Replace('>', '\uFF1E').
Replace(':', '\uFF1A').Replace('\"', '\uFF02'). Replace(':', '\uFF1A').Replace('\"', '\uFF02').
Replace('|', '\uFF5C').Replace('?', '\uFF1F'). Replace('|', '\uFF5C').Replace('?', '\uFF1F').
Replace('*', '\uFF0A').Replace('/', '\\'); Replace('*', '\uFF0A').Replace('/', '\\');
}
Directory.CreateDirectory(outputPath); Directory.CreateDirectory(outputPath);
@@ -513,26 +524,32 @@ sealed class ExtractFilesCommand : Command
: Path.Combine(outputPath, entry); : Path.Combine(outputPath, entry);
if(RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) if(RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
{
outputPath = outputPath.Replace('<', '\uFF1C').Replace('>', '\uFF1E'). outputPath = outputPath.Replace('<', '\uFF1C').Replace('>', '\uFF1E').
Replace(':', '\uFF1A').Replace('\"', '\uFF02'). Replace(':', '\uFF1A').Replace('\"', '\uFF02').
Replace('|', '\uFF5C').Replace('?', '\uFF1F'). Replace('|', '\uFF5C').Replace('?', '\uFF1F').
Replace('*', '\uFF0A').Replace('/', '\\'); Replace('*', '\uFF0A').Replace('/', '\\');
}
if(!File.Exists(outputPath)) if(!File.Exists(outputPath))
{ {
Core.Spectre.ProgressSingleSpinner(ctx => 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, outputFile =
FileShare.None); new FileStream(outputPath,
FileMode.CreateNew,
FileAccess.ReadWrite,
FileShare.None);
outputFile.Write(xattrBuf, 0, xattrBuf.Length); outputFile.Write(xattrBuf, 0, xattrBuf.Length);
outputFile.Close(); outputFile.Close();
}); });
var fi = new FileInfo(outputPath); 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 try
{ {
if(stat.CreationTimeUtc.HasValue) if(stat.CreationTimeUtc.HasValue)
@@ -562,21 +579,24 @@ sealed class ExtractFilesCommand : Command
{ {
// ignored // 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, AaruConsole.WriteLine(UI.Written_0_bytes_of_xattr_1_from_file_2_to_3, xattrBuf.Length,
xattr, entry, outputPath); xattr, entry, outputPath);
} }
else else
AaruConsole.ErrorWriteLine(UI.Cannot_write_xattr_0_for_1_output_exists, xattr, entry); AaruConsole.ErrorWriteLine(UI.Cannot_write_xattr_0_for_1_output_exists, xattr, entry);
} }
}
} }
outputPath = Path.Combine(outputDir, fs.Metadata.Type, volumeName, path); outputPath = Path.Combine(outputDir, fs.Metadata.Type, volumeName, path);
if(RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) if(RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
{
outputPath = outputPath.Replace('<', '\uFF1C').Replace('>', '\uFF1E').Replace(':', '\uFF1A'). outputPath = outputPath.Replace('<', '\uFF1C').Replace('>', '\uFF1E').Replace(':', '\uFF1A').
Replace('\"', '\uFF02').Replace('|', '\uFF5C').Replace('?', '\uFF1F'). Replace('\"', '\uFF02').Replace('|', '\uFF5C').Replace('?', '\uFF1F').
Replace('*', '\uFF0A').Replace('/', '\\'); Replace('*', '\uFF0A').Replace('/', '\\');
}
Directory.CreateDirectory(outputPath); Directory.CreateDirectory(outputPath);
@@ -585,9 +605,11 @@ sealed class ExtractFilesCommand : Command
: Path.Combine(outputPath, entry); : Path.Combine(outputPath, entry);
if(RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) if(RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
{
outputPath = outputPath.Replace('<', '\uFF1C').Replace('>', '\uFF1E').Replace(':', '\uFF1A'). outputPath = outputPath.Replace('<', '\uFF1C').Replace('>', '\uFF1E').Replace(':', '\uFF1A').
Replace('\"', '\uFF02').Replace('|', '\uFF5C').Replace('?', '\uFF1F'). Replace('\"', '\uFF02').Replace('|', '\uFF5C').Replace('?', '\uFF1F').
Replace('*', '\uFF0A').Replace('/', '\\'); Replace('*', '\uFF0A').Replace('/', '\\');
}
if(!File.Exists(outputPath)) if(!File.Exists(outputPath))
{ {
@@ -598,50 +620,52 @@ sealed class ExtractFilesCommand : Command
AnsiConsole.Progress().AutoClear(true).HideCompleted(true). AnsiConsole.Progress().AutoClear(true).HideCompleted(true).
Columns(new TaskDescriptionColumn(), new ProgressBarColumn(), new PercentageColumn()). Columns(new TaskDescriptionColumn(), new ProgressBarColumn(), new PercentageColumn()).
Start(ctx => Start(ctx =>
{ {
ProgressTask task = ProgressTask task =
ctx.AddTask(string.Format(UI.Reading_file_0, Markup.Escape(entry))); ctx.AddTask(string.Format(UI.Reading_file_0, Markup.Escape(entry)));
task.MaxValue = stat.Length; task.MaxValue = stat.Length;
byte[] outBuf = new byte[BUFFER_SIZE]; var outBuf = new byte[BUFFER_SIZE];
error = fs.OpenFile(path + "/" + entry, out IFileNode fileNode); error = fs.OpenFile(path + "/" + entry, out IFileNode fileNode);
if(error == ErrorNumber.NoError) if(error == ErrorNumber.NoError)
{ {
while(position < stat.Length) while(position < stat.Length)
{ {
long bytesToRead; long bytesToRead;
if(stat.Length - position > BUFFER_SIZE) if(stat.Length - position > BUFFER_SIZE)
bytesToRead = BUFFER_SIZE; bytesToRead = BUFFER_SIZE;
else else
bytesToRead = stat.Length - position; 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) if(error == ErrorNumber.NoError)
outputFile.Write(outBuf, 0, (int)bytesRead); outputFile.Write(outBuf, 0, (int)bytesRead);
else else
{ {
AaruConsole.ErrorWriteLine(UI.Error_0_reading_file_1, error, entry); AaruConsole.ErrorWriteLine(UI.Error_0_reading_file_1, error,
entry);
break; break;
} }
position += bytesToRead; position += bytesToRead;
task.Increment(bytesToRead); task.Increment(bytesToRead);
} }
fs.CloseFile(fileNode); fs.CloseFile(fileNode);
} }
else else
AaruConsole.ErrorWriteLine(UI.Error_0_reading_file_1, error, entry); AaruConsole.ErrorWriteLine(UI.Error_0_reading_file_1, error, entry);
}); });
outputFile.Close(); outputFile.Close();
var fi = new FileInfo(outputPath); 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 try
{ {
if(stat.CreationTimeUtc.HasValue) if(stat.CreationTimeUtc.HasValue)
@@ -671,7 +695,7 @@ sealed class ExtractFilesCommand : Command
{ {
// ignored // 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), AaruConsole.WriteLine(UI.Written_0_bytes_of_file_1_to_2, position, Markup.Escape(entry),
Markup.Escape(outputPath)); Markup.Escape(outputPath));
} }

View File

@@ -53,20 +53,12 @@ sealed class FilesystemInfoCommand : Command
public FilesystemInfoCommand() : base("info", UI.Filesystem_Info_Command_Description) public FilesystemInfoCommand() : base("info", UI.Filesystem_Info_Command_Description)
{ {
Add(new Option<string>(new[] Add(new Option<string>(new[] { "--encoding", "-e" }, () => null, UI.Name_of_character_encoding_to_use));
{
"--encoding", "-e"
}, () => null, UI.Name_of_character_encoding_to_use));
Add(new Option<bool>(new[] Add(new Option<bool>(new[] { "--filesystems", "-f" }, () => true,
{ UI.Searches_and_prints_information_about_filesystems));
"--filesystems", "-f"
}, () => true, UI.Searches_and_prints_information_about_filesystems));
Add(new Option<bool>(new[] Add(new Option<bool>(new[] { "--partitions", "-p" }, () => true, UI.Searches_and_interprets_partitions));
{
"--partitions", "-p"
}, () => true, UI.Searches_and_interprets_partitions));
AddArgument(new Argument<string> AddArgument(new Argument<string>
{ {
@@ -78,7 +70,7 @@ sealed class FilesystemInfoCommand : Command
Handler = CommandHandler.Create(typeof(FilesystemInfoCommand).GetMethod(nameof(Invoke))); 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) string imagePath)
{ {
MainClass.PrintCopyright(); MainClass.PrintCopyright();
@@ -91,40 +83,42 @@ sealed class FilesystemInfoCommand : Command
}); });
AaruConsole.DebugWriteLineEvent += (format, objects) => AaruConsole.DebugWriteLineEvent += (format, objects) =>
{ {
if(objects is null) if(objects is null)
stderrConsole.MarkupLine(format); stderrConsole.MarkupLine(format);
else else
stderrConsole.MarkupLine(format, objects); stderrConsole.MarkupLine(format, objects);
}; };
} }
if(verbose) if(verbose)
{
AaruConsole.WriteEvent += (format, objects) => AaruConsole.WriteEvent += (format, objects) =>
{ {
if(objects is null) if(objects is null)
AnsiConsole.Markup(format); AnsiConsole.Markup(format);
else else
AnsiConsole.Markup(format, objects); AnsiConsole.Markup(format, objects);
}; };
}
Statistics.AddCommand("fs-info"); Statistics.AddCommand("fs-info");
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, "--encoding={0}", encoding);
AaruConsole.DebugWriteLine(MODULE_NAME, "--filesystems={0}", filesystems); AaruConsole.DebugWriteLine(MODULE_NAME, "--filesystems={0}", filesystems);
AaruConsole.DebugWriteLine(MODULE_NAME, "--input={0}", imagePath); AaruConsole.DebugWriteLine(MODULE_NAME, "--input={0}", imagePath);
AaruConsole.DebugWriteLine(MODULE_NAME, "--partitions={0}", partitions); AaruConsole.DebugWriteLine(MODULE_NAME, "--partitions={0}", partitions);
AaruConsole.DebugWriteLine(MODULE_NAME, "--verbose={0}", verbose); AaruConsole.DebugWriteLine(MODULE_NAME, "--verbose={0}", verbose);
var filtersList = new FiltersList(); var filtersList = new FiltersList();
IFilter inputFilter = null; IFilter inputFilter = null;
Core.Spectre.ProgressSingleSpinner(ctx => Core.Spectre.ProgressSingleSpinner(ctx =>
{ {
ctx.AddTask(UI.Identifying_file_filter).IsIndeterminate(); ctx.AddTask(UI.Identifying_file_filter).IsIndeterminate();
inputFilter = filtersList.GetFilter(imagePath); inputFilter = filtersList.GetFilter(imagePath);
}); });
if(inputFilter == null) if(inputFilter == null)
{ {
@@ -136,6 +130,7 @@ sealed class FilesystemInfoCommand : Command
Encoding encodingClass = null; Encoding encodingClass = null;
if(encoding != null) if(encoding != null)
{
try try
{ {
encodingClass = Claunia.Encoding.Encoding.GetEncoding(encoding); encodingClass = Claunia.Encoding.Encoding.GetEncoding(encoding);
@@ -149,10 +144,11 @@ sealed class FilesystemInfoCommand : Command
return (int)ErrorNumber.EncodingUnknown; return (int)ErrorNumber.EncodingUnknown;
} }
}
PluginBase plugins = PluginBase.Singleton; PluginBase plugins = PluginBase.Singleton;
bool checkRaw = false; var checkRaw = false;
try try
{ {
@@ -160,11 +156,11 @@ sealed class FilesystemInfoCommand : Command
IBaseImage baseImage = null; IBaseImage baseImage = null;
Core.Spectre.ProgressSingleSpinner(ctx => Core.Spectre.ProgressSingleSpinner(ctx =>
{ {
ctx.AddTask(UI.Identifying_image_format).IsIndeterminate(); ctx.AddTask(UI.Identifying_image_format).IsIndeterminate();
baseImage = ImageFormat.Detect(inputFilter); baseImage = ImageFormat.Detect(inputFilter);
imageFormat = baseImage as IMediaImage; imageFormat = baseImage as IMediaImage;
}); });
if(baseImage == null) if(baseImage == null)
{ {
@@ -192,10 +188,10 @@ sealed class FilesystemInfoCommand : Command
ErrorNumber opened = ErrorNumber.NoData; ErrorNumber opened = ErrorNumber.NoData;
Core.Spectre.ProgressSingleSpinner(ctx => Core.Spectre.ProgressSingleSpinner(ctx =>
{ {
ctx.AddTask(UI.Invoke_Opening_image_file).IsIndeterminate(); ctx.AddTask(UI.Invoke_Opening_image_file).IsIndeterminate();
opened = imageFormat.Open(inputFilter); opened = imageFormat.Open(inputFilter);
}); });
if(opened != ErrorNumber.NoError) if(opened != ErrorNumber.NoError)
{ {
@@ -233,10 +229,10 @@ sealed class FilesystemInfoCommand : Command
List<Partition> partitionsList = null; List<Partition> partitionsList = null;
Core.Spectre.ProgressSingleSpinner(ctx => Core.Spectre.ProgressSingleSpinner(ctx =>
{ {
ctx.AddTask(UI.Enumerating_partitions).IsIndeterminate(); ctx.AddTask(UI.Enumerating_partitions).IsIndeterminate();
partitionsList = Core.Partitions.GetAll(imageFormat); partitionsList = Core.Partitions.GetAll(imageFormat);
}); });
Core.Partitions.AddSchemesToStats(partitionsList); Core.Partitions.AddSchemesToStats(partitionsList);
@@ -257,7 +253,7 @@ sealed class FilesystemInfoCommand : Command
{ {
AaruConsole.WriteLine(UI._0_partitions_found, partitionsList.Count); 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() Table table = new()
{ {
@@ -279,7 +275,7 @@ sealed class FilesystemInfoCommand : Command
string.Format(UI._0_sectors_1_bytes, partitionsList[i].Length, string.Format(UI._0_sectors_1_bytes, partitionsList[i].Length,
partitionsList[i].Size)); 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 ?? "")); table.AddRow(UI.Title_Description, Markup.Escape(partitionsList[i].Description ?? ""));
AnsiConsole.Write(table); AnsiConsole.Write(table);
@@ -288,10 +284,12 @@ sealed class FilesystemInfoCommand : Command
continue; continue;
Core.Spectre.ProgressSingleSpinner(ctx => Core.Spectre.ProgressSingleSpinner(ctx =>
{ {
ctx.AddTask(UI.Identifying_filesystems_on_partition).IsIndeterminate(); ctx.AddTask(UI.Identifying_filesystems_on_partition).
Core.Filesystems.Identify(imageFormat, out idPlugins, partitionsList[i]); IsIndeterminate();
}); Core.Filesystems.Identify(imageFormat, out idPlugins,
partitionsList[i]);
});
switch(idPlugins.Count) switch(idPlugins.Count)
{ {
@@ -305,6 +303,7 @@ sealed class FilesystemInfoCommand : Command
idPlugins.Count)}[/]"); idPlugins.Count)}[/]");
foreach(string pluginName in idPlugins) foreach(string pluginName in idPlugins)
{
if(plugins.Filesystems.TryGetValue(pluginName, out pluginType)) if(plugins.Filesystems.TryGetValue(pluginName, out pluginType))
{ {
if(Activator.CreateInstance(pluginType) is not IFilesystem fs) if(Activator.CreateInstance(pluginType) is not IFilesystem fs)
@@ -319,6 +318,7 @@ sealed class FilesystemInfoCommand : Command
AaruConsole.Write(information); AaruConsole.Write(information);
Statistics.AddFilesystem(fsMetadata.Type); Statistics.AddFilesystem(fsMetadata.Type);
} }
}
break; break;
} }
@@ -357,10 +357,10 @@ sealed class FilesystemInfoCommand : Command
}; };
Core.Spectre.ProgressSingleSpinner(ctx => Core.Spectre.ProgressSingleSpinner(ctx =>
{ {
ctx.AddTask(UI.Identifying_filesystems).IsIndeterminate(); ctx.AddTask(UI.Identifying_filesystems).IsIndeterminate();
Core.Filesystems.Identify(imageFormat, out idPlugins, wholePart); Core.Filesystems.Identify(imageFormat, out idPlugins, wholePart);
}); });
switch(idPlugins.Count) switch(idPlugins.Count)
{ {
@@ -374,6 +374,7 @@ sealed class FilesystemInfoCommand : Command
}[/]"); }[/]");
foreach(string pluginName in idPlugins) foreach(string pluginName in idPlugins)
{
if(plugins.Filesystems.TryGetValue(pluginName, out pluginType)) if(plugins.Filesystems.TryGetValue(pluginName, out pluginType))
{ {
if(Activator.CreateInstance(pluginType) is not IFilesystem fs) if(Activator.CreateInstance(pluginType) is not IFilesystem fs)
@@ -387,6 +388,7 @@ sealed class FilesystemInfoCommand : Command
AaruConsole.Write(information); AaruConsole.Write(information);
Statistics.AddFilesystem(fsMetadata.Type); Statistics.AddFilesystem(fsMetadata.Type);
} }
}
break; break;
} }

View File

@@ -56,25 +56,14 @@ sealed class LsCommand : Command
{ {
AddAlias("ls"); AddAlias("ls");
Add(new Option<string>(new[] Add(new Option<string>(new[] { "--encoding", "-e" }, () => null, UI.Name_of_character_encoding_to_use));
{
"--encoding", "-e"
}, () => null, UI.Name_of_character_encoding_to_use));
Add(new Option<bool>(new[] Add(new Option<bool>(new[] { "--long-format", "-l" }, () => true, UI.Use_long_format));
{
"--long-format", "-l"
}, () => true, UI.Use_long_format));
Add(new Option<string>(new[] Add(new Option<string>(new[] { "--options", "-O" }, () => null,
{ UI.Comma_separated_name_value_pairs_of_filesystem_options));
"--options", "-O"
}, () => null, UI.Comma_separated_name_value_pairs_of_filesystem_options));
Add(new Option<string>(new[] Add(new Option<string>(new[] { "--namespace", "-n" }, () => null, UI.Namespace_to_use_for_filenames));
{
"--namespace", "-n"
}, () => null, UI.Namespace_to_use_for_filenames));
AddArgument(new Argument<string> AddArgument(new Argument<string>
{ {
@@ -86,7 +75,7 @@ sealed class LsCommand : Command
Handler = CommandHandler.Create(GetType().GetMethod(nameof(Invoke))); 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) string @namespace, string options)
{ {
MainClass.PrintCopyright(); MainClass.PrintCopyright();
@@ -99,38 +88,40 @@ sealed class LsCommand : Command
}); });
AaruConsole.DebugWriteLineEvent += (format, objects) => AaruConsole.DebugWriteLineEvent += (format, objects) =>
{ {
if(objects is null) if(objects is null)
stderrConsole.MarkupLine(Markup.Escape(format)); stderrConsole.MarkupLine(Markup.Escape(format));
else else
stderrConsole.MarkupLine(Markup.Escape(format), objects); stderrConsole.MarkupLine(Markup.Escape(format), objects);
}; };
} }
if(verbose) if(verbose)
{
AaruConsole.WriteEvent += (format, objects) => AaruConsole.WriteEvent += (format, objects) =>
{ {
if(objects is null) if(objects is null)
AnsiConsole.Markup(format); AnsiConsole.Markup(format);
else else
AnsiConsole.Markup(format, objects); 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, "--encoding={0}", encoding);
AaruConsole.DebugWriteLine(MODULE_NAME, "--input={0}", imagePath); AaruConsole.DebugWriteLine(MODULE_NAME, "--input={0}", imagePath);
AaruConsole.DebugWriteLine(MODULE_NAME, "--options={0}", options); AaruConsole.DebugWriteLine(MODULE_NAME, "--options={0}", options);
AaruConsole.DebugWriteLine(MODULE_NAME, "--verbose={0}", verbose); AaruConsole.DebugWriteLine(MODULE_NAME, "--verbose={0}", verbose);
Statistics.AddCommand("ls"); Statistics.AddCommand("ls");
var filtersList = new FiltersList(); var filtersList = new FiltersList();
IFilter inputFilter = null; IFilter inputFilter = null;
Core.Spectre.ProgressSingleSpinner(ctx => Core.Spectre.ProgressSingleSpinner(ctx =>
{ {
ctx.AddTask(UI.Identifying_file_filter).IsIndeterminate(); ctx.AddTask(UI.Identifying_file_filter).IsIndeterminate();
inputFilter = filtersList.GetFilter(imagePath); inputFilter = filtersList.GetFilter(imagePath);
}); });
Dictionary<string, string> parsedOptions = Core.Options.Parse(options); Dictionary<string, string> parsedOptions = Core.Options.Parse(options);
AaruConsole.DebugWriteLine(MODULE_NAME, UI.Parsed_options); AaruConsole.DebugWriteLine(MODULE_NAME, UI.Parsed_options);
@@ -150,6 +141,7 @@ sealed class LsCommand : Command
Encoding encodingClass = null; Encoding encodingClass = null;
if(encoding != null) if(encoding != null)
{
try try
{ {
encodingClass = Claunia.Encoding.Encoding.GetEncoding(encoding); encodingClass = Claunia.Encoding.Encoding.GetEncoding(encoding);
@@ -163,6 +155,7 @@ sealed class LsCommand : Command
return (int)ErrorNumber.EncodingUnknown; return (int)ErrorNumber.EncodingUnknown;
} }
}
PluginBase plugins = PluginBase.Singleton; PluginBase plugins = PluginBase.Singleton;
@@ -172,11 +165,11 @@ sealed class LsCommand : Command
IBaseImage baseImage = null; IBaseImage baseImage = null;
Core.Spectre.ProgressSingleSpinner(ctx => Core.Spectre.ProgressSingleSpinner(ctx =>
{ {
ctx.AddTask(UI.Identifying_image_format).IsIndeterminate(); ctx.AddTask(UI.Identifying_image_format).IsIndeterminate();
baseImage = ImageFormat.Detect(inputFilter); baseImage = ImageFormat.Detect(inputFilter);
imageFormat = baseImage as IMediaImage; imageFormat = baseImage as IMediaImage;
}); });
if(baseImage == null) if(baseImage == null)
{ {
@@ -202,10 +195,10 @@ sealed class LsCommand : Command
ErrorNumber opened = ErrorNumber.NoData; ErrorNumber opened = ErrorNumber.NoData;
Core.Spectre.ProgressSingleSpinner(ctx => Core.Spectre.ProgressSingleSpinner(ctx =>
{ {
ctx.AddTask(UI.Invoke_Opening_image_file).IsIndeterminate(); ctx.AddTask(UI.Invoke_Opening_image_file).IsIndeterminate();
opened = imageFormat.Open(inputFilter); opened = imageFormat.Open(inputFilter);
}); });
if(opened != ErrorNumber.NoError) if(opened != ErrorNumber.NoError)
{ {
@@ -240,10 +233,10 @@ sealed class LsCommand : Command
List<Partition> partitions = null; List<Partition> partitions = null;
Core.Spectre.ProgressSingleSpinner(ctx => Core.Spectre.ProgressSingleSpinner(ctx =>
{ {
ctx.AddTask(UI.Enumerating_partitions).IsIndeterminate(); ctx.AddTask(UI.Enumerating_partitions).IsIndeterminate();
partitions = Core.Partitions.GetAll(imageFormat); partitions = Core.Partitions.GetAll(imageFormat);
}); });
Core.Partitions.AddSchemesToStats(partitions); Core.Partitions.AddSchemesToStats(partitions);
@@ -264,7 +257,7 @@ sealed class LsCommand : Command
AaruConsole.WriteLine(UI._0_partitions_found, partitions.Count); 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();
AaruConsole.WriteLine($"[bold]{string.Format(UI.Partition_0, partitions[i].Sequence)}[/]"); AaruConsole.WriteLine($"[bold]{string.Format(UI.Partition_0, partitions[i].Sequence)}[/]");
@@ -272,10 +265,12 @@ sealed class LsCommand : Command
List<string> idPlugins = null; List<string> idPlugins = null;
Core.Spectre.ProgressSingleSpinner(ctx => Core.Spectre.ProgressSingleSpinner(ctx =>
{ {
ctx.AddTask(UI.Identifying_filesystems_on_partition).IsIndeterminate(); ctx.AddTask(UI.Identifying_filesystems_on_partition).
Core.Filesystems.Identify(imageFormat, out idPlugins, partitions[i]); IsIndeterminate();
}); Core.Filesystems.Identify(imageFormat, out idPlugins,
partitions[i]);
});
if(idPlugins.Count == 0) if(idPlugins.Count == 0)
AaruConsole.WriteLine(UI.Filesystem_not_identified); AaruConsole.WriteLine(UI.Filesystem_not_identified);
@@ -290,6 +285,7 @@ sealed class LsCommand : Command
}[/]"); }[/]");
foreach(string pluginName in idPlugins) foreach(string pluginName in idPlugins)
{
if(plugins.ReadOnlyFilesystems.TryGetValue(pluginName, out pluginType)) if(plugins.ReadOnlyFilesystems.TryGetValue(pluginName, out pluginType))
{ {
if(Activator.CreateInstance(pluginType) is not IReadOnlyFilesystem fs) 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)}[/]"); AaruConsole.WriteLine($"[bold]{string.Format(UI.As_identified_by_0, fs.Name)}[/]");
Core.Spectre.ProgressSingleSpinner(ctx => Core.Spectre.ProgressSingleSpinner(ctx =>
{ {
ctx.AddTask(UI.Mounting_filesystem).IsIndeterminate(); ctx.AddTask(UI.Mounting_filesystem).
IsIndeterminate();
error = fs.Mount(imageFormat, partitions[i], encodingClass, parsedOptions, error = fs.Mount(imageFormat, partitions[i],
@namespace); encodingClass, parsedOptions,
}); @namespace);
});
if(error == ErrorNumber.NoError) if(error == ErrorNumber.NoError)
{ {
@@ -314,6 +312,7 @@ sealed class LsCommand : Command
else else
AaruConsole.ErrorWriteLine(UI.Unable_to_mount_volume_error_0, error.ToString()); AaruConsole.ErrorWriteLine(UI.Unable_to_mount_volume_error_0, error.ToString());
} }
}
} }
else else
{ {
@@ -325,10 +324,12 @@ sealed class LsCommand : Command
AaruConsole.WriteLine($"[bold]{string.Format(UI.Identified_by_0, fs.Name)}[/]"); AaruConsole.WriteLine($"[bold]{string.Format(UI.Identified_by_0, fs.Name)}[/]");
Core.Spectre.ProgressSingleSpinner(ctx => 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) if(error == ErrorNumber.NoError)
{ {
@@ -361,14 +362,15 @@ sealed class LsCommand : Command
if(path.StartsWith('/')) if(path.StartsWith('/'))
path = path[1..]; 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))); : string.Format(UI.Directory_0, Markup.Escape(path)));
Core.Spectre.ProgressSingleSpinner(ctx => Core.Spectre.ProgressSingleSpinner(ctx =>
{ {
ctx.AddTask(UI.Reading_directory).IsIndeterminate(); ctx.AddTask(UI.Reading_directory).IsIndeterminate();
error = fs.OpenDir(path, out node); error = fs.OpenDir(path, out node);
}); });
if(error != ErrorNumber.NoError) if(error != ErrorNumber.NoError)
{ {
@@ -380,32 +382,37 @@ sealed class LsCommand : Command
Dictionary<string, FileEntryInfo> stats = new(); Dictionary<string, FileEntryInfo> stats = new();
Core.Spectre.ProgressSingleSpinner(ctx => 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 && while(fs.ReadDir(node, out string entry) == ErrorNumber.NoError &&
entry is not null) entry is not null)
{ {
fs.Stat(path + "/" + entry, out FileEntryInfo stat); fs.Stat(path + "/" + entry, out FileEntryInfo stat);
stats.Add(entry, stat); stats.Add(entry, stat);
} }
fs.CloseDir(node); fs.CloseDir(node);
}); });
foreach(KeyValuePair<string, FileEntryInfo> entry in foreach(KeyValuePair<string, FileEntryInfo> entry in
stats.OrderBy(e => e.Value?.Attributes.HasFlag(FileAttributes.Directory) == false)) stats.OrderBy(e => e.Value?.Attributes.HasFlag(FileAttributes.Directory) == false))
{
if(longFormat) if(longFormat)
{ {
if(entry.Value != null) if(entry.Value != null)
{ {
if(entry.Value.Attributes.HasFlag(FileAttributes.Directory)) if(entry.Value.Attributes.HasFlag(FileAttributes.Directory))
{
AaruConsole.WriteLine("{0, 10:d} {0, 12:T} {1, -20} {2}", entry.Value.CreationTimeUtc, AaruConsole.WriteLine("{0, 10:d} {0, 12:T} {1, -20} {2}", entry.Value.CreationTimeUtc,
UI.Directory_abbreviation, Markup.Escape(entry.Key)); UI.Directory_abbreviation, Markup.Escape(entry.Key));
}
else else
{
AaruConsole.WriteLine("{0, 10:d} {0, 12:T} {1, 6}{2, 14:N0} {3}", entry.Value.CreationTimeUtc, 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)); entry.Value.Inode, entry.Value.Length, Markup.Escape(entry.Key));
}
error = fs.ListXAttr(path + "/" + entry.Key, out List<string> xattrs); error = fs.ListXAttr(path + "/" + entry.Key, out List<string> xattrs);
@@ -425,9 +432,12 @@ sealed class LsCommand : Command
AaruConsole.WriteLine("{0, 47}{1}", string.Empty, Markup.Escape(entry.Key)); AaruConsole.WriteLine("{0, 47}{1}", string.Empty, Markup.Escape(entry.Key));
} }
else else
{
AaruConsole. AaruConsole.
WriteLine(entry.Value?.Attributes.HasFlag(FileAttributes.Directory) == true ? "{0}/" : "{0}", WriteLine(entry.Value?.Attributes.HasFlag(FileAttributes.Directory) == true ? "{0}/" : "{0}",
entry.Key); entry.Key);
}
}
AaruConsole.WriteLine(); AaruConsole.WriteLine();

View File

@@ -64,24 +64,26 @@ sealed class ListOptionsCommand : Command
}); });
AaruConsole.DebugWriteLineEvent += (format, objects) => AaruConsole.DebugWriteLineEvent += (format, objects) =>
{ {
if(objects is null) if(objects is null)
stderrConsole.MarkupLine(format); stderrConsole.MarkupLine(format);
else else
stderrConsole.MarkupLine(format, objects); stderrConsole.MarkupLine(format, objects);
}; };
} }
if(verbose) if(verbose)
{
AaruConsole.WriteEvent += (format, objects) => AaruConsole.WriteEvent += (format, objects) =>
{ {
if(objects is null) if(objects is null)
AnsiConsole.Markup(format); AnsiConsole.Markup(format);
else else
AnsiConsole.Markup(format, objects); 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); AaruConsole.DebugWriteLine(MODULE_NAME, "--verbose={0}", verbose);
Statistics.AddCommand("list-options"); Statistics.AddCommand("list-options");
@@ -94,7 +96,7 @@ sealed class ListOptionsCommand : Command
if(Activator.CreateInstance(kvp.Value) is not IReadOnlyFilesystem fs) if(Activator.CreateInstance(kvp.Value) is not IReadOnlyFilesystem fs)
continue; continue;
List<(string name, Type type, string description)> options = fs.SupportedOptions.ToList(); var options = fs.SupportedOptions.ToList();
if(options.Count == 0) if(options.Count == 0)
continue; continue;
@@ -109,8 +111,10 @@ sealed class ListOptionsCommand : Command
table.AddColumn(UI.Title_Description); table.AddColumn(UI.Title_Description);
foreach((string name, Type type, string description) option in options.OrderBy(t => t.name)) foreach((string name, Type type, string description) option in options.OrderBy(t => t.name))
{
table.AddRow(Markup.Escape(option.name), $"[italic]{TypeToString(option.type)}[/]", table.AddRow(Markup.Escape(option.name), $"[italic]{TypeToString(option.type)}[/]",
Markup.Escape(option.description)); Markup.Escape(option.description));
}
AnsiConsole.Write(table); AnsiConsole.Write(table);
AaruConsole.WriteLine(); AaruConsole.WriteLine();

View File

@@ -64,26 +64,28 @@ sealed class FormatsCommand : Command
}); });
AaruConsole.DebugWriteLineEvent += (format, objects) => AaruConsole.DebugWriteLineEvent += (format, objects) =>
{ {
if(objects is null) if(objects is null)
stderrConsole.MarkupLine(format); stderrConsole.MarkupLine(format);
else else
stderrConsole.MarkupLine(format, objects); stderrConsole.MarkupLine(format, objects);
}; };
} }
if(verbose) if(verbose)
{
AaruConsole.WriteEvent += (format, objects) => AaruConsole.WriteEvent += (format, objects) =>
{ {
if(objects is null) if(objects is null)
AnsiConsole.Markup(format); AnsiConsole.Markup(format);
else else
AnsiConsole.Markup(format, objects); AnsiConsole.Markup(format, objects);
}; };
}
Statistics.AddCommand("formats"); Statistics.AddCommand("formats");
AaruConsole.DebugWriteLine(MODULE_NAME, "--debug={0}", debug); AaruConsole.DebugWriteLine(MODULE_NAME, "--debug={0}", debug);
AaruConsole.DebugWriteLine(MODULE_NAME, "--verbose={0}", verbose); AaruConsole.DebugWriteLine(MODULE_NAME, "--verbose={0}", verbose);
PluginBase plugins = PluginBase.Singleton; PluginBase plugins = PluginBase.Singleton;
@@ -100,10 +102,12 @@ sealed class FormatsCommand : Command
table.AddColumn(UI.Title_Filter); table.AddColumn(UI.Title_Filter);
foreach(KeyValuePair<string, IFilter> kvp in filtersList.Filters) foreach(KeyValuePair<string, IFilter> kvp in filtersList.Filters)
{
if(verbose) if(verbose)
table.AddRow(kvp.Value.Id.ToString(), Markup.Escape(kvp.Value.Name)); table.AddRow(kvp.Value.Id.ToString(), Markup.Escape(kvp.Value.Name));
else else
table.AddRow(Markup.Escape(kvp.Value.Name)); table.AddRow(Markup.Escape(kvp.Value.Name));
}
AnsiConsole.Write(table); AnsiConsole.Write(table);
@@ -113,7 +117,7 @@ sealed class FormatsCommand : Command
{ {
Title = new TableTitle(string.Format(UI.Read_only_media_image_formats_0, Title = new TableTitle(string.Format(UI.Read_only_media_image_formats_0,
plugins.MediaImages.Count(t => !t.Value.GetInterfaces(). plugins.MediaImages.Count(t => !t.Value.GetInterfaces().
Contains(typeof(IWritableImage))))) Contains(typeof(IWritableImage)))))
}; };
if(verbose) if(verbose)
@@ -122,7 +126,7 @@ sealed class FormatsCommand : Command
table.AddColumn(UI.Title_Media_image_format); table.AddColumn(UI.Title_Media_image_format);
foreach(KeyValuePair<string, Type> kvp in plugins.MediaImages.Where(t => !t.Value.GetInterfaces(). foreach(KeyValuePair<string, Type> kvp in plugins.MediaImages.Where(t => !t.Value.GetInterfaces().
Contains(typeof(IWritableImage)))) Contains(typeof(IWritableImage))))
{ {
if(Activator.CreateInstance(kvp.Value) is not IMediaImage imagePlugin) if(Activator.CreateInstance(kvp.Value) is not IMediaImage imagePlugin)
continue; continue;
@@ -166,8 +170,8 @@ sealed class FormatsCommand : Command
{ {
Title = new TableTitle(string.Format(UI.Supported_filesystems_for_identification_and_information_only_0, Title = new TableTitle(string.Format(UI.Supported_filesystems_for_identification_and_information_only_0,
plugins.Filesystems.Count(t => !t.Value.GetInterfaces(). plugins.Filesystems.Count(t => !t.Value.GetInterfaces().
Contains(typeof( Contains(typeof(
IReadOnlyFilesystem))))) IReadOnlyFilesystem)))))
}; };
if(verbose) if(verbose)
@@ -176,8 +180,8 @@ sealed class FormatsCommand : Command
table.AddColumn(UI.Title_Filesystem); table.AddColumn(UI.Title_Filesystem);
foreach(KeyValuePair<string, Type> kvp in plugins.Filesystems.Where(t => !t.Value.GetInterfaces(). foreach(KeyValuePair<string, Type> kvp in plugins.Filesystems.Where(t => !t.Value.GetInterfaces().
Contains(typeof( Contains(typeof(
IReadOnlyFilesystem)))) IReadOnlyFilesystem))))
{ {
if(Activator.CreateInstance(kvp.Value) is not IFilesystem fs) if(Activator.CreateInstance(kvp.Value) is not IFilesystem fs)
continue; continue;

View File

@@ -58,50 +58,29 @@ sealed class ChecksumCommand : Command
{ {
AddAlias("chk"); AddAlias("chk");
Add(new Option<bool>(new[] Add(new Option<bool>(new[] { "--adler32", "-a" }, () => false, UI.Calculates_Adler_32));
{
"--adler32", "-a"
}, () => false, UI.Calculates_Adler_32));
Add(new Option<bool>("--crc16", () => true, UI.Calculates_CRC16)); Add(new Option<bool>("--crc16", () => true, UI.Calculates_CRC16));
Add(new Option<bool>(new[] Add(new Option<bool>(new[] { "--crc32", "-c" }, () => true, UI.Calculates_CRC32));
{
"--crc32", "-c"
}, () => true, UI.Calculates_CRC32));
Add(new Option<bool>("--crc64", () => true, UI.Calculates_CRC64_ECMA)); Add(new Option<bool>("--crc64", () => true, UI.Calculates_CRC64_ECMA));
Add(new Option<bool>("--fletcher16", () => false, UI.Calculates_Fletcher_16)); Add(new Option<bool>("--fletcher16", () => false, UI.Calculates_Fletcher_16));
Add(new Option<bool>("--fletcher32", () => false, UI.Calculates_Fletcher_32)); Add(new Option<bool>("--fletcher32", () => false, UI.Calculates_Fletcher_32));
Add(new Option<bool>(new[] Add(new Option<bool>(new[] { "--md5", "-m" }, () => true, UI.Calculates_MD5));
{
"--md5", "-m"
}, () => true, UI.Calculates_MD5));
Add(new Option<bool>(new[] Add(new Option<bool>(new[] { "--separated-tracks", "-t" }, () => true, UI.Checksums_each_track_separately));
{
"--separated-tracks", "-t"
}, () => true, UI.Checksums_each_track_separately));
Add(new Option<bool>(new[] Add(new Option<bool>(new[] { "--sha1", "-s" }, () => true, UI.Calculates_SHA1));
{
"--sha1", "-s"
}, () => true, UI.Calculates_SHA1));
Add(new Option<bool>("--sha256", () => false, UI.Calculates_SHA256)); Add(new Option<bool>("--sha256", () => false, UI.Calculates_SHA256));
Add(new Option<bool>("--sha384", () => false, UI.Calculates_SHA384)); Add(new Option<bool>("--sha384", () => false, UI.Calculates_SHA384));
Add(new Option<bool>("--sha512", () => true, UI.Calculates_SHA512)); Add(new Option<bool>("--sha512", () => true, UI.Calculates_SHA512));
Add(new Option<bool>(new[] Add(new Option<bool>(new[] { "--spamsum", "-f" }, () => true, UI.Calculates_SpamSum_fuzzy_hash));
{
"--spamsum", "-f"
}, () => true, UI.Calculates_SpamSum_fuzzy_hash));
Add(new Option<bool>(new[] Add(new Option<bool>(new[] { "--whole-disc", "-w" }, () => true, UI.Checksums_the_whole_disc));
{
"--whole-disc", "-w"
}, () => true, UI.Checksums_the_whole_disc));
AddArgument(new Argument<string> AddArgument(new Argument<string>
{ {
@@ -113,9 +92,9 @@ sealed class ChecksumCommand : Command
Handler = CommandHandler.Create(GetType().GetMethod(nameof(Invoke))); Handler = CommandHandler.Create(GetType().GetMethod(nameof(Invoke)));
} }
public static int Invoke(bool debug, bool verbose, bool adler32, bool crc16, bool crc32, bool crc64, 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 fletcher16, bool fletcher32, bool md5, bool sha1, bool sha256, bool sha384,
bool sha512, bool spamSum, string imagePath, bool separatedTracks, bool wholeDisc) bool sha512, bool spamSum, string imagePath, bool separatedTracks, bool wholeDisc)
{ {
MainClass.PrintCopyright(); MainClass.PrintCopyright();
@@ -127,51 +106,53 @@ sealed class ChecksumCommand : Command
}); });
AaruConsole.DebugWriteLineEvent += (format, objects) => AaruConsole.DebugWriteLineEvent += (format, objects) =>
{ {
if(objects is null) if(objects is null)
stderrConsole.MarkupLine(format); stderrConsole.MarkupLine(format);
else else
stderrConsole.MarkupLine(format, objects); stderrConsole.MarkupLine(format, objects);
}; };
} }
if(verbose) if(verbose)
{
AaruConsole.WriteEvent += (format, objects) => AaruConsole.WriteEvent += (format, objects) =>
{ {
if(objects is null) if(objects is null)
AnsiConsole.Markup(format); AnsiConsole.Markup(format);
else else
AnsiConsole.Markup(format, objects); AnsiConsole.Markup(format, objects);
}; };
}
Statistics.AddCommand("checksum"); Statistics.AddCommand("checksum");
AaruConsole.DebugWriteLine(MODULE_NAME, "--adler32={0}", adler32); AaruConsole.DebugWriteLine(MODULE_NAME, "--adler32={0}", adler32);
AaruConsole.DebugWriteLine(MODULE_NAME, "--crc16={0}", crc16); AaruConsole.DebugWriteLine(MODULE_NAME, "--crc16={0}", crc16);
AaruConsole.DebugWriteLine(MODULE_NAME, "--crc32={0}", crc32); AaruConsole.DebugWriteLine(MODULE_NAME, "--crc32={0}", crc32);
AaruConsole.DebugWriteLine(MODULE_NAME, "--crc64={0}", crc64); AaruConsole.DebugWriteLine(MODULE_NAME, "--crc64={0}", crc64);
AaruConsole.DebugWriteLine(MODULE_NAME, "--debug={0}", debug); AaruConsole.DebugWriteLine(MODULE_NAME, "--debug={0}", debug);
AaruConsole.DebugWriteLine(MODULE_NAME, "--fletcher16={0}", fletcher16); AaruConsole.DebugWriteLine(MODULE_NAME, "--fletcher16={0}", fletcher16);
AaruConsole.DebugWriteLine(MODULE_NAME, "--fletcher32={0}", fletcher32); AaruConsole.DebugWriteLine(MODULE_NAME, "--fletcher32={0}", fletcher32);
AaruConsole.DebugWriteLine(MODULE_NAME, "--input={0}", imagePath); AaruConsole.DebugWriteLine(MODULE_NAME, "--input={0}", imagePath);
AaruConsole.DebugWriteLine(MODULE_NAME, "--md5={0}", md5); AaruConsole.DebugWriteLine(MODULE_NAME, "--md5={0}", md5);
AaruConsole.DebugWriteLine(MODULE_NAME, "--separated-tracks={0}", separatedTracks); AaruConsole.DebugWriteLine(MODULE_NAME, "--separated-tracks={0}", separatedTracks);
AaruConsole.DebugWriteLine(MODULE_NAME, "--sha1={0}", sha1); AaruConsole.DebugWriteLine(MODULE_NAME, "--sha1={0}", sha1);
AaruConsole.DebugWriteLine(MODULE_NAME, "--sha256={0}", sha256); AaruConsole.DebugWriteLine(MODULE_NAME, "--sha256={0}", sha256);
AaruConsole.DebugWriteLine(MODULE_NAME, "--sha384={0}", sha384); AaruConsole.DebugWriteLine(MODULE_NAME, "--sha384={0}", sha384);
AaruConsole.DebugWriteLine(MODULE_NAME, "--sha512={0}", sha512); AaruConsole.DebugWriteLine(MODULE_NAME, "--sha512={0}", sha512);
AaruConsole.DebugWriteLine(MODULE_NAME, "--spamsum={0}", spamSum); AaruConsole.DebugWriteLine(MODULE_NAME, "--spamsum={0}", spamSum);
AaruConsole.DebugWriteLine(MODULE_NAME, "--verbose={0}", verbose); AaruConsole.DebugWriteLine(MODULE_NAME, "--verbose={0}", verbose);
AaruConsole.DebugWriteLine(MODULE_NAME, "--whole-disc={0}", wholeDisc); AaruConsole.DebugWriteLine(MODULE_NAME, "--whole-disc={0}", wholeDisc);
var filtersList = new FiltersList(); var filtersList = new FiltersList();
IFilter inputFilter = null; IFilter inputFilter = null;
Core.Spectre.ProgressSingleSpinner(ctx => Core.Spectre.ProgressSingleSpinner(ctx =>
{ {
ctx.AddTask(UI.Identifying_file_filter).IsIndeterminate(); ctx.AddTask(UI.Identifying_file_filter).IsIndeterminate();
inputFilter = filtersList.GetFilter(imagePath); inputFilter = filtersList.GetFilter(imagePath);
}); });
if(inputFilter == null) if(inputFilter == null)
{ {
@@ -183,10 +164,10 @@ sealed class ChecksumCommand : Command
IBaseImage inputFormat = null; IBaseImage inputFormat = null;
Core.Spectre.ProgressSingleSpinner(ctx => Core.Spectre.ProgressSingleSpinner(ctx =>
{ {
ctx.AddTask(UI.Identifying_image_format).IsIndeterminate(); ctx.AddTask(UI.Identifying_image_format).IsIndeterminate();
inputFormat = ImageFormat.Detect(inputFilter); inputFormat = ImageFormat.Detect(inputFilter);
}); });
if(inputFormat == null) if(inputFormat == null)
{ {
@@ -198,10 +179,10 @@ sealed class ChecksumCommand : Command
ErrorNumber opened = ErrorNumber.NoData; ErrorNumber opened = ErrorNumber.NoData;
Core.Spectre.ProgressSingleSpinner(ctx => Core.Spectre.ProgressSingleSpinner(ctx =>
{ {
ctx.AddTask(UI.Invoke_Opening_image_file).IsIndeterminate(); ctx.AddTask(UI.Invoke_Opening_image_file).IsIndeterminate();
opened = inputFormat.Open(inputFilter); opened = inputFormat.Open(inputFilter);
}); });
if(opened != ErrorNumber.NoError) if(opened != ErrorNumber.NoError)
{ {
@@ -258,7 +239,7 @@ sealed class ChecksumCommand : Command
switch(inputFormat) switch(inputFormat)
{ {
case IOpticalMediaImage { Tracks: {} } opticalInput: case IOpticalMediaImage { Tracks: not null } opticalInput:
try try
{ {
Checksum trackChecksum = null; Checksum trackChecksum = null;
@@ -271,143 +252,154 @@ sealed class ChecksumCommand : Command
AnsiConsole.Progress().AutoClear(true).HideCompleted(true). AnsiConsole.Progress().AutoClear(true).HideCompleted(true).
Columns(new TaskDescriptionColumn(), new ProgressBarColumn(), new PercentageColumn()). Columns(new TaskDescriptionColumn(), new ProgressBarColumn(), new PercentageColumn()).
Start(ctx => Start(ctx =>
{ {
ProgressTask discTask = ctx.AddTask(Localization.Core.Hashing_tracks); ProgressTask discTask = ctx.AddTask(Localization.Core.Hashing_tracks);
discTask.MaxValue = inputTracks.Count; discTask.MaxValue = inputTracks.Count;
foreach(Track currentTrack in inputTracks) foreach(Track currentTrack in inputTracks)
{ {
discTask.Description = discTask.Description =
string.Format(UI.Hashing_track_0_of_1, discTask.Value + 1, string.Format(UI.Hashing_track_0_of_1, discTask.Value + 1,
inputTracks.Count); inputTracks.Count);
ProgressTask trackTask = ctx.AddTask(UI.Hashing_sector); ProgressTask trackTask = ctx.AddTask(UI.Hashing_sector);
/* /*
if(currentTrack.StartSector - previousTrackEnd != 0 && wholeDisc) if(currentTrack.StartSector - previousTrackEnd != 0 && wholeDisc)
for(ulong i = previousTrackEnd + 1; i < currentTrack.StartSector; i++) for(ulong i = previousTrackEnd + 1; i < currentTrack.StartSector; i++)
{ {
AaruConsole.Write("\rHashing track-less sector {0}", 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, AaruConsole.DebugWriteLine(MODULE_NAME,
UI.Track_0_starts_at_sector_1_and_ends_at_sector_2, UI.
currentTrack.Sequence, currentTrack.StartSector, Track_0_starts_at_sector_1_and_ends_at_sector_2,
currentTrack.EndSector); currentTrack.Sequence,
currentTrack.StartSector,
currentTrack.EndSector);
if(separatedTracks) if(separatedTracks)
trackChecksum = new Checksum(enabledChecksums); 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) while(doneSectors < sectors)
{ {
byte[] sector; byte[] sector;
if(sectors - doneSectors >= SECTORS_TO_READ) if(sectors - doneSectors >= SECTORS_TO_READ)
{ {
errno = opticalInput.ReadSectors(doneSectors, SECTORS_TO_READ, errno = opticalInput.ReadSectors(doneSectors, SECTORS_TO_READ,
currentTrack.Sequence, out sector); currentTrack.Sequence, out sector);
trackTask.Description = trackTask.Description =
string.Format(UI.Hashing_sectors_0_to_2_of_track_1, doneSectors, string.Format(UI.Hashing_sectors_0_to_2_of_track_1,
currentTrack.Sequence, doneSectors + SECTORS_TO_READ); doneSectors,
currentTrack.Sequence,
doneSectors + SECTORS_TO_READ);
if(errno != ErrorNumber.NoError) if(errno != ErrorNumber.NoError)
{ {
AaruConsole. AaruConsole.
ErrorWriteLine(string. ErrorWriteLine(string.
Format(UI.Error_0_while_reading_1_sectors_from_sector_2, Format(UI.Error_0_while_reading_1_sectors_from_sector_2,
errno, SECTORS_TO_READ, errno, SECTORS_TO_READ,
doneSectors)); doneSectors));
return; return;
} }
doneSectors += SECTORS_TO_READ; doneSectors += SECTORS_TO_READ;
} }
else else
{ {
errno = opticalInput.ReadSectors(doneSectors, errno = opticalInput.ReadSectors(doneSectors,
(uint)(sectors - doneSectors), currentTrack.Sequence, (uint)(sectors - doneSectors), currentTrack.Sequence,
out sector); out sector);
trackTask.Description = trackTask.Description =
string.Format(UI.Hashing_sectors_0_to_2_of_track_1, doneSectors, string.Format(UI.Hashing_sectors_0_to_2_of_track_1,
currentTrack.Sequence, doneSectors,
doneSectors + (sectors - doneSectors)); currentTrack.Sequence,
doneSectors + (sectors - doneSectors));
if(errno != ErrorNumber.NoError) if(errno != ErrorNumber.NoError)
{ {
AaruConsole. AaruConsole.
ErrorWriteLine(string. ErrorWriteLine(string.
Format(UI.Error_0_while_reading_1_sectors_from_sector_2, Format(UI.Error_0_while_reading_1_sectors_from_sector_2,
errno, sectors - doneSectors, errno, sectors - doneSectors,
doneSectors)); doneSectors));
return; return;
} }
doneSectors += sectors - doneSectors; doneSectors += sectors - doneSectors;
} }
if(wholeDisc) if(wholeDisc)
mediaChecksum?.Update(sector); mediaChecksum?.Update(sector);
if(separatedTracks) if(separatedTracks)
trackChecksum?.Update(sector); trackChecksum?.Update(sector);
trackTask.Value = doneSectors; trackTask.Value = doneSectors;
} }
trackTask.StopTask(); trackTask.StopTask();
AaruConsole.WriteLine(); AaruConsole.WriteLine();
if(!separatedTracks) if(!separatedTracks)
continue; continue;
if(trackChecksum == null) if(trackChecksum == null)
continue; continue;
foreach(CommonTypes.AaruMetadata.Checksum chk in trackChecksum.End()) 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}"); 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) if(opticalInput.Info.Sectors - previousTrackEnd != 0 && wholeDisc)
for(ulong i = previousTrackEnd + 1; i < opticalInput.Info.Sectors; i++) for(ulong i = previousTrackEnd + 1; i < opticalInput.Info.Sectors; i++)
{ {
AaruConsole.Write("\rHashing track-less sector {0}", 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);
} }
*/ */
if(!wholeDisc) if(!wholeDisc)
return; return;
if(mediaChecksum == null) if(mediaChecksum == null)
return; return;
AaruConsole.WriteLine(); AaruConsole.WriteLine();
foreach(CommonTypes.AaruMetadata.Checksum chk in mediaChecksum.End()) foreach(CommonTypes.AaruMetadata.Checksum chk in mediaChecksum.End())
AaruConsole.WriteLine($"[bold]{string.Format(UI.Checksums_Disc_has_0, chk.Type) {
}:[/] {chk.Value}"); AaruConsole.
}); WriteLine($"[bold]{string.Format(UI.Checksums_Disc_has_0, chk.Type)
}:[/] {chk.Value}");
}
});
if(errno != ErrorNumber.NoError) if(errno != ErrorNumber.NoError)
return (int)errno; return (int)errno;
@@ -434,153 +426,166 @@ sealed class ChecksumCommand : Command
AnsiConsole.Progress().AutoClear(true).HideCompleted(true). AnsiConsole.Progress().AutoClear(true).HideCompleted(true).
Columns(new TaskDescriptionColumn(), new ProgressBarColumn(), new PercentageColumn()). Columns(new TaskDescriptionColumn(), new ProgressBarColumn(), new PercentageColumn()).
Start(ctx => Start(ctx =>
{ {
ProgressTask tapeTask = ctx.AddTask(Localization.Core.Hashing_files); ProgressTask tapeTask = ctx.AddTask(Localization.Core.Hashing_files);
tapeTask.MaxValue = tapeImage.Files.Count; tapeTask.MaxValue = tapeImage.Files.Count;
foreach(TapeFile currentFile in tapeImage.Files) foreach(TapeFile currentFile in tapeImage.Files)
{ {
tapeTask.Description = tapeTask.Description =
string.Format(UI.Hashing_file_0_of_1, currentFile.File, tapeImage.Files.Count); string.Format(UI.Hashing_file_0_of_1, currentFile.File,
tapeImage.Files.Count);
if(currentFile.FirstBlock - previousFileEnd != 0 && wholeDisc) if(currentFile.FirstBlock - previousFileEnd != 0 && wholeDisc)
{ {
ProgressTask preFileTask = ctx.AddTask(UI.Hashing_sector); ProgressTask preFileTask = ctx.AddTask(UI.Hashing_sector);
preFileTask.MaxValue = currentFile.FirstBlock - previousFileEnd; preFileTask.MaxValue = currentFile.FirstBlock - previousFileEnd;
for(ulong i = previousFileEnd + 1; i < currentFile.FirstBlock; i++) for(ulong i = previousFileEnd + 1; i < currentFile.FirstBlock; i++)
{ {
preFileTask.Description = string.Format(UI.Hashing_file_less_block_0, 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) if(errno != ErrorNumber.NoError)
{ {
AaruConsole. AaruConsole.
ErrorWriteLine(string.Format(UI.Error_0_while_reading_block_1, ErrorWriteLine(string.Format(UI.Error_0_while_reading_block_1,
errno, i)); errno, i));
return; return;
} }
mediaChecksum?.Update(hiddenSector); mediaChecksum?.Update(hiddenSector);
preFileTask.Increment(1); preFileTask.Increment(1);
} }
preFileTask.StopTask(); preFileTask.StopTask();
} }
AaruConsole.DebugWriteLine(MODULE_NAME, AaruConsole.DebugWriteLine(MODULE_NAME,
UI.File_0_starts_at_block_1_and_ends_at_block_2, UI.File_0_starts_at_block_1_and_ends_at_block_2,
currentFile.File, currentFile.FirstBlock, currentFile.File, currentFile.FirstBlock,
currentFile.LastBlock); currentFile.LastBlock);
if(separatedTracks) if(separatedTracks)
trackChecksum = new Checksum(enabledChecksums); trackChecksum = new Checksum(enabledChecksums);
ulong sectors = currentFile.LastBlock - currentFile.FirstBlock + 1; ulong sectors = currentFile.LastBlock - currentFile.FirstBlock + 1;
ulong doneSectors = 0; ulong doneSectors = 0;
ProgressTask fileTask = ctx.AddTask(UI.Hashing_sector); ProgressTask fileTask = ctx.AddTask(UI.Hashing_sector);
fileTask.MaxValue = sectors; fileTask.MaxValue = sectors;
while(doneSectors < sectors) while(doneSectors < sectors)
{ {
byte[] sector; byte[] sector;
if(sectors - doneSectors >= SECTORS_TO_READ) if(sectors - doneSectors >= SECTORS_TO_READ)
{ {
errno = tapeImage.ReadSectors(doneSectors + currentFile.FirstBlock, errno = tapeImage.ReadSectors(doneSectors + currentFile.FirstBlock,
SECTORS_TO_READ, out sector); SECTORS_TO_READ, out sector);
if(errno != ErrorNumber.NoError) if(errno != ErrorNumber.NoError)
{ {
AaruConsole. AaruConsole.
ErrorWriteLine(string. ErrorWriteLine(string.
Format(UI.Error_0_while_reading_1_sectors_from_sector_2, Format(UI.Error_0_while_reading_1_sectors_from_sector_2,
errno, SECTORS_TO_READ, errno, SECTORS_TO_READ,
doneSectors + currentFile.FirstBlock)); doneSectors +
currentFile.FirstBlock));
return; return;
} }
fileTask.Description = fileTask.Description =
string.Format(UI.Hashing_blocks_0_to_2_of_file_1, doneSectors, string.Format(UI.Hashing_blocks_0_to_2_of_file_1, doneSectors,
currentFile.File, doneSectors + SECTORS_TO_READ); currentFile.File, doneSectors + SECTORS_TO_READ);
doneSectors += SECTORS_TO_READ; doneSectors += SECTORS_TO_READ;
} }
else else
{ {
errno = tapeImage.ReadSectors(doneSectors + currentFile.FirstBlock, errno = tapeImage.ReadSectors(doneSectors + currentFile.FirstBlock,
(uint)(sectors - doneSectors), out sector); (uint)(sectors - doneSectors),
out sector);
if(errno != ErrorNumber.NoError) if(errno != ErrorNumber.NoError)
{ {
AaruConsole. AaruConsole.
ErrorWriteLine(string. ErrorWriteLine(string.
Format(UI.Error_0_while_reading_1_sectors_from_sector_2, Format(UI.Error_0_while_reading_1_sectors_from_sector_2,
errno, sectors - doneSectors, errno, sectors - doneSectors,
doneSectors + currentFile.FirstBlock)); doneSectors +
currentFile.FirstBlock));
return; return;
} }
fileTask.Description = fileTask.Description =
string.Format(UI.Hashing_blocks_0_to_2_of_file_1, doneSectors, string.Format(UI.Hashing_blocks_0_to_2_of_file_1, doneSectors,
currentFile.File, doneSectors + (sectors - doneSectors)); currentFile.File,
doneSectors + (sectors - doneSectors));
doneSectors += sectors - doneSectors; doneSectors += sectors - doneSectors;
} }
fileTask.Value = doneSectors; fileTask.Value = doneSectors;
if(wholeDisc) if(wholeDisc)
mediaChecksum?.Update(sector); mediaChecksum?.Update(sector);
if(separatedTracks) if(separatedTracks)
trackChecksum?.Update(sector); trackChecksum?.Update(sector);
} }
fileTask.StopTask(); fileTask.StopTask();
AaruConsole.WriteLine(); AaruConsole.WriteLine();
if(separatedTracks) if(separatedTracks)
if(trackChecksum != null) {
foreach(CommonTypes.AaruMetadata.Checksum chk in trackChecksum.End()) if(trackChecksum != null)
AaruConsole.WriteLine($"[bold]{string.Format(UI.Checksums_File_0_has_1, {
currentFile.File, chk.Type)}[/]: {chk.Value}"); 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 || if(tapeImage.Info.Sectors - previousFileEnd == 0 ||
!wholeDisc) !wholeDisc)
return; return;
ProgressTask postFileTask = ctx.AddTask(UI.Hashing_sector); ProgressTask postFileTask = ctx.AddTask(UI.Hashing_sector);
postFileTask.MaxValue = tapeImage.Info.Sectors - previousFileEnd; postFileTask.MaxValue = tapeImage.Info.Sectors - previousFileEnd;
for(ulong i = previousFileEnd + 1; i < tapeImage.Info.Sectors; i++) for(ulong i = previousFileEnd + 1; i < tapeImage.Info.Sectors; i++)
{ {
postFileTask.Description = string.Format(UI.Hashing_file_less_block_0, 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) if(errno != ErrorNumber.NoError)
{ {
AaruConsole.ErrorWriteLine(string.Format(UI.Error_0_while_reading_block_1, AaruConsole.ErrorWriteLine(string.Format(UI.Error_0_while_reading_block_1,
errno, i)); errno, i));
return; return;
} }
mediaChecksum?.Update(hiddenSector); mediaChecksum?.Update(hiddenSector);
postFileTask.Increment(1); postFileTask.Increment(1);
} }
}); });
if(errno != ErrorNumber.NoError) if(errno != ErrorNumber.NoError)
return (int)errno; return (int)errno;
@@ -590,8 +595,10 @@ sealed class ChecksumCommand : Command
AaruConsole.WriteLine(); AaruConsole.WriteLine();
foreach(CommonTypes.AaruMetadata.Checksum chk in mediaChecksum.End()) foreach(CommonTypes.AaruMetadata.Checksum chk in mediaChecksum.End())
{
AaruConsole.WriteLine($"[bold]{string.Format(UI.Checksums_Tape_has_0, chk.Type)}[/] {chk.Value AaruConsole.WriteLine($"[bold]{string.Format(UI.Checksums_Tape_has_0, chk.Type)}[/] {chk.Value
}"); }");
}
} }
break; break;
@@ -604,64 +611,68 @@ sealed class ChecksumCommand : Command
AnsiConsole.Progress().AutoClear(true).HideCompleted(true). AnsiConsole.Progress().AutoClear(true).HideCompleted(true).
Columns(new TaskDescriptionColumn(), new ProgressBarColumn(), new PercentageColumn()). Columns(new TaskDescriptionColumn(), new ProgressBarColumn(), new PercentageColumn()).
Start(ctx => Start(ctx =>
{ {
ProgressTask imageTask = ctx.AddTask(UI.Hashing_image); ProgressTask imageTask = ctx.AddTask(UI.Hashing_image);
ulong length = byteAddressableImage.Info.Sectors; ulong length = byteAddressableImage.Info.Sectors;
imageTask.MaxValue = length; imageTask.MaxValue = length;
ulong doneBytes = 0; ulong doneBytes = 0;
byte[] data = new byte[BYTES_TO_READ]; var data = new byte[BYTES_TO_READ];
while(doneBytes < length) while(doneBytes < length)
{ {
int bytesRead; int bytesRead;
if(length - doneBytes >= BYTES_TO_READ) if(length - doneBytes >= BYTES_TO_READ)
{ {
errno = byteAddressableImage.ReadBytes(data, 0, BYTES_TO_READ, out bytesRead); errno = byteAddressableImage.ReadBytes(data, 0, BYTES_TO_READ,
out bytesRead);
if(errno != ErrorNumber.NoError) if(errno != ErrorNumber.NoError)
{ {
AaruConsole. AaruConsole.
ErrorWriteLine(string.Format(UI.Error_0_while_reading_1_bytes_from_2, ErrorWriteLine(string.
errno, BYTES_TO_READ, doneBytes)); Format(UI.Error_0_while_reading_1_bytes_from_2,
errno, BYTES_TO_READ, doneBytes));
return; return;
} }
imageTask.Description = imageTask.Description =
string.Format(UI.Hashing_bytes_0_to_1, doneBytes, string.Format(UI.Hashing_bytes_0_to_1, doneBytes,
doneBytes + BYTES_TO_READ); doneBytes + BYTES_TO_READ);
doneBytes += (ulong)bytesRead; doneBytes += (ulong)bytesRead;
if(bytesRead == 0) if(bytesRead == 0)
break; break;
} }
else else
{ {
errno = byteAddressableImage.ReadBytes(data, 0, (int)(length - doneBytes), errno = byteAddressableImage.ReadBytes(data, 0, (int)(length - doneBytes),
out bytesRead); out bytesRead);
if(errno != ErrorNumber.NoError) if(errno != ErrorNumber.NoError)
{ {
AaruConsole. AaruConsole.
ErrorWriteLine(string.Format(UI.Error_0_while_reading_1_bytes_from_2, ErrorWriteLine(string.
errno, length - doneBytes, doneBytes)); Format(UI.Error_0_while_reading_1_bytes_from_2,
errno, length - doneBytes,
doneBytes));
return; return;
} }
imageTask.Description = imageTask.Description =
string.Format(UI.Hashing_bytes_0_to_1, doneBytes, string.Format(UI.Hashing_bytes_0_to_1, doneBytes,
doneBytes + (length - doneBytes)); doneBytes + (length - doneBytes));
doneBytes += length - doneBytes; doneBytes += length - doneBytes;
} }
mediaChecksum.Update(data); mediaChecksum.Update(data);
imageTask.Value = doneBytes; imageTask.Value = doneBytes;
} }
}); });
if(errno != ErrorNumber.NoError) if(errno != ErrorNumber.NoError)
return (int)errno; return (int)errno;
@@ -682,62 +693,64 @@ sealed class ChecksumCommand : Command
AnsiConsole.Progress().AutoClear(true).HideCompleted(true). AnsiConsole.Progress().AutoClear(true).HideCompleted(true).
Columns(new TaskDescriptionColumn(), new ProgressBarColumn(), new PercentageColumn()). Columns(new TaskDescriptionColumn(), new ProgressBarColumn(), new PercentageColumn()).
Start(ctx => Start(ctx =>
{ {
ProgressTask diskTask = ctx.AddTask(Localization.Core.Hashing_sectors); ProgressTask diskTask = ctx.AddTask(Localization.Core.Hashing_sectors);
ulong sectors = mediaImage.Info.Sectors; ulong sectors = mediaImage.Info.Sectors;
diskTask.MaxValue = sectors; diskTask.MaxValue = sectors;
ulong doneSectors = 0; ulong doneSectors = 0;
while(doneSectors < sectors) while(doneSectors < sectors)
{ {
byte[] sector; byte[] sector;
if(sectors - doneSectors >= SECTORS_TO_READ) if(sectors - doneSectors >= SECTORS_TO_READ)
{ {
errno = mediaImage.ReadSectors(doneSectors, SECTORS_TO_READ, out sector); errno = mediaImage.ReadSectors(doneSectors, SECTORS_TO_READ, out sector);
if(errno != ErrorNumber.NoError) if(errno != ErrorNumber.NoError)
{ {
AaruConsole. AaruConsole.
ErrorWriteLine(string. ErrorWriteLine(string.
Format(UI.Error_0_while_reading_1_sectors_from_sector_2, Format(UI.Error_0_while_reading_1_sectors_from_sector_2,
errno, SECTORS_TO_READ, doneSectors)); errno, SECTORS_TO_READ,
doneSectors));
return; return;
} }
diskTask.Description = diskTask.Description =
string.Format(UI.Hashing_sectors_0_to_1, doneSectors, string.Format(UI.Hashing_sectors_0_to_1, doneSectors,
doneSectors + SECTORS_TO_READ); doneSectors + SECTORS_TO_READ);
doneSectors += SECTORS_TO_READ; doneSectors += SECTORS_TO_READ;
} }
else else
{ {
errno = mediaImage.ReadSectors(doneSectors, (uint)(sectors - doneSectors), errno = mediaImage.ReadSectors(doneSectors, (uint)(sectors - doneSectors),
out sector); out sector);
if(errno != ErrorNumber.NoError) if(errno != ErrorNumber.NoError)
{ {
AaruConsole. AaruConsole.
ErrorWriteLine(string. ErrorWriteLine(string.
Format(UI.Error_0_while_reading_1_sectors_from_sector_2, Format(UI.Error_0_while_reading_1_sectors_from_sector_2,
errno, sectors - doneSectors, doneSectors)); errno, sectors - doneSectors,
doneSectors));
return; return;
} }
diskTask.Description = diskTask.Description =
string.Format(UI.Hashing_sectors_0_to_1, doneSectors, string.Format(UI.Hashing_sectors_0_to_1, doneSectors,
doneSectors + (sectors - doneSectors)); doneSectors + (sectors - doneSectors));
doneSectors += sectors - doneSectors; doneSectors += sectors - doneSectors;
} }
mediaChecksum.Update(sector); mediaChecksum.Update(sector);
diskTask.Value = doneSectors; diskTask.Value = doneSectors;
} }
}); });
if(errno != ErrorNumber.NoError) if(errno != ErrorNumber.NoError)
return (int)errno; return (int)errno;

View File

@@ -86,28 +86,30 @@ sealed class CompareCommand : Command
}); });
AaruConsole.DebugWriteLineEvent += (format, objects) => AaruConsole.DebugWriteLineEvent += (format, objects) =>
{ {
if(objects is null) if(objects is null)
stderrConsole.MarkupLine(format); stderrConsole.MarkupLine(format);
else else
stderrConsole.MarkupLine(format, objects); stderrConsole.MarkupLine(format, objects);
}; };
} }
if(verbose) if(verbose)
{
AaruConsole.WriteEvent += (format, objects) => AaruConsole.WriteEvent += (format, objects) =>
{ {
if(objects is null) if(objects is null)
AnsiConsole.Markup(format); AnsiConsole.Markup(format);
else else
AnsiConsole.Markup(format, objects); AnsiConsole.Markup(format, objects);
}; };
}
Statistics.AddCommand("compare"); Statistics.AddCommand("compare");
AaruConsole.DebugWriteLine(MODULE_NAME, "--debug={0}", debug); AaruConsole.DebugWriteLine(MODULE_NAME, "--debug={0}", debug);
AaruConsole.DebugWriteLine(MODULE_NAME, "--input1={0}", imagePath1); AaruConsole.DebugWriteLine(MODULE_NAME, "--input1={0}", imagePath1);
AaruConsole.DebugWriteLine(MODULE_NAME, "--input2={0}", imagePath2); AaruConsole.DebugWriteLine(MODULE_NAME, "--input2={0}", imagePath2);
AaruConsole.DebugWriteLine(MODULE_NAME, "--verbose={0}", verbose); AaruConsole.DebugWriteLine(MODULE_NAME, "--verbose={0}", verbose);
var filtersList = new FiltersList(); var filtersList = new FiltersList();
@@ -115,18 +117,18 @@ sealed class CompareCommand : Command
IFilter inputFilter2 = null; IFilter inputFilter2 = null;
Core.Spectre.ProgressSingleSpinner(ctx => Core.Spectre.ProgressSingleSpinner(ctx =>
{ {
ctx.AddTask(UI.Identifying_first_file_filter).IsIndeterminate(); ctx.AddTask(UI.Identifying_first_file_filter).IsIndeterminate();
inputFilter1 = filtersList.GetFilter(imagePath1); inputFilter1 = filtersList.GetFilter(imagePath1);
}); });
filtersList = new FiltersList(); filtersList = new FiltersList();
Core.Spectre.ProgressSingleSpinner(ctx => Core.Spectre.ProgressSingleSpinner(ctx =>
{ {
ctx.AddTask(UI.Identifying_second_file_filter).IsIndeterminate(); ctx.AddTask(UI.Identifying_second_file_filter).IsIndeterminate();
inputFilter2 = filtersList.GetFilter(imagePath2); inputFilter2 = filtersList.GetFilter(imagePath2);
}); });
if(inputFilter1 == null) if(inputFilter1 == null)
{ {
@@ -146,16 +148,16 @@ sealed class CompareCommand : Command
IBaseImage input2Format = null; IBaseImage input2Format = null;
Core.Spectre.ProgressSingleSpinner(ctx => Core.Spectre.ProgressSingleSpinner(ctx =>
{ {
ctx.AddTask(UI.Identifying_first_image_format).IsIndeterminate(); ctx.AddTask(UI.Identifying_first_image_format).IsIndeterminate();
input1Format = ImageFormat.Detect(inputFilter1); input1Format = ImageFormat.Detect(inputFilter1);
}); });
Core.Spectre.ProgressSingleSpinner(ctx => Core.Spectre.ProgressSingleSpinner(ctx =>
{ {
ctx.AddTask(UI.Identifying_second_image_format).IsIndeterminate(); ctx.AddTask(UI.Identifying_second_image_format).IsIndeterminate();
input2Format = ImageFormat.Detect(inputFilter2); input2Format = ImageFormat.Detect(inputFilter2);
}); });
if(input1Format == null) if(input1Format == null)
{ {
@@ -165,8 +167,10 @@ sealed class CompareCommand : Command
} }
if(verbose) if(verbose)
{
AaruConsole.VerboseWriteLine(UI.First_input_file_format_identified_by_0_1, input1Format.Name, AaruConsole.VerboseWriteLine(UI.First_input_file_format_identified_by_0_1, input1Format.Name,
input1Format.Id); input1Format.Id);
}
else else
AaruConsole.WriteLine(UI.First_input_file_format_identified_by_0, input1Format.Name); AaruConsole.WriteLine(UI.First_input_file_format_identified_by_0, input1Format.Name);
@@ -178,8 +182,10 @@ sealed class CompareCommand : Command
} }
if(verbose) if(verbose)
{
AaruConsole.VerboseWriteLine(UI.Second_input_file_format_identified_by_0_1, input2Format.Name, AaruConsole.VerboseWriteLine(UI.Second_input_file_format_identified_by_0_1, input2Format.Name,
input2Format.Id); input2Format.Id);
}
else else
AaruConsole.WriteLine(UI.Second_input_file_format_identified_by_0, input2Format.Name); AaruConsole.WriteLine(UI.Second_input_file_format_identified_by_0, input2Format.Name);
@@ -187,10 +193,10 @@ sealed class CompareCommand : Command
ErrorNumber opened2 = ErrorNumber.NoData; ErrorNumber opened2 = ErrorNumber.NoData;
Core.Spectre.ProgressSingleSpinner(ctx => Core.Spectre.ProgressSingleSpinner(ctx =>
{ {
ctx.AddTask(UI.Opening_first_image_file).IsIndeterminate(); ctx.AddTask(UI.Opening_first_image_file).IsIndeterminate();
opened1 = input1Format.Open(inputFilter1); opened1 = input1Format.Open(inputFilter1);
}); });
if(opened1 != ErrorNumber.NoError) if(opened1 != ErrorNumber.NoError)
{ {
@@ -201,10 +207,10 @@ sealed class CompareCommand : Command
} }
Core.Spectre.ProgressSingleSpinner(ctx => Core.Spectre.ProgressSingleSpinner(ctx =>
{ {
ctx.AddTask(UI.Opening_second_image_file).IsIndeterminate(); ctx.AddTask(UI.Opening_second_image_file).IsIndeterminate();
opened2 = input2Format.Open(inputFilter2); opened2 = input2Format.Open(inputFilter2);
}); });
if(opened2 != ErrorNumber.NoError) if(opened2 != ErrorNumber.NoError)
{ {
@@ -230,8 +236,8 @@ sealed class CompareCommand : Command
if(verbose) if(verbose)
{ {
table.AddRow(UI.Title_File, Markup.Escape(imagePath1), Markup.Escape(imagePath2)); 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_Media_image_format, input1Format.Name, input2Format.Name);
} }
else else
{ {
@@ -239,7 +245,7 @@ sealed class CompareCommand : Command
sb.AppendFormat($"[bold]{UI.Title_Second_Media_image}:[/] {imagePath2}").AppendLine(); sb.AppendFormat($"[bold]{UI.Title_Second_Media_image}:[/] {imagePath2}").AppendLine();
} }
bool imagesDiffer = false; var imagesDiffer = false;
ErrorNumber errno; ErrorNumber errno;
ImageInfo image1Info = input1Format.Info; ImageInfo image1Info = input1Format.Info;
@@ -250,6 +256,7 @@ sealed class CompareCommand : Command
var input2MediaImage = input2Format as IMediaImage; var input2MediaImage = input2Format as IMediaImage;
if(input1MediaImage != null) if(input1MediaImage != null)
{
foreach(MediaTagType diskTag in Enum.GetValues(typeof(MediaTagType))) foreach(MediaTagType diskTag in Enum.GetValues(typeof(MediaTagType)))
{ {
errno = input1MediaImage.ReadMediaTag(diskTag, out byte[] tempArray); errno = input1MediaImage.ReadMediaTag(diskTag, out byte[] tempArray);
@@ -257,8 +264,10 @@ sealed class CompareCommand : Command
if(errno == ErrorNumber.NoError) if(errno == ErrorNumber.NoError)
image1DiskTags.Add(diskTag, tempArray); image1DiskTags.Add(diskTag, tempArray);
} }
}
if(input2MediaImage != null) if(input2MediaImage != null)
{
foreach(MediaTagType diskTag in Enum.GetValues(typeof(MediaTagType))) foreach(MediaTagType diskTag in Enum.GetValues(typeof(MediaTagType)))
{ {
errno = input2MediaImage.ReadMediaTag(diskTag, out byte[] tempArray); errno = input2MediaImage.ReadMediaTag(diskTag, out byte[] tempArray);
@@ -266,6 +275,7 @@ sealed class CompareCommand : Command
if(errno == ErrorNumber.NoError) if(errno == ErrorNumber.NoError)
image2DiskTags.Add(diskTag, tempArray); image2DiskTags.Add(diskTag, tempArray);
} }
}
if(verbose) if(verbose)
{ {
@@ -335,76 +345,78 @@ sealed class CompareCommand : Command
foreach(MediaTagType diskTag in foreach(MediaTagType diskTag in
(Enum.GetValues(typeof(MediaTagType)) as MediaTagType[]).OrderBy(e => e.ToString())) (Enum.GetValues(typeof(MediaTagType)) as MediaTagType[]).OrderBy(e => e.ToString()))
{
table.AddRow(string.Format(UI.Has_tag_0_Question, diskTag), table.AddRow(string.Format(UI.Has_tag_0_Question, diskTag),
image1DiskTags.ContainsKey(diskTag).ToString(), image1DiskTags.ContainsKey(diskTag).ToString(),
image2DiskTags.ContainsKey(diskTag).ToString()); image2DiskTags.ContainsKey(diskTag).ToString());
}
} }
ulong leastSectors = 0; ulong leastSectors = 0;
Core.Spectre.ProgressSingleSpinner(ctx => 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) if(image1Info.HasPartitions != image2Info.HasPartitions)
{ {
imagesDiffer = true; imagesDiffer = true;
if(!verbose) if(!verbose)
sb.AppendLine(UI.Image_partitioned_status_differ); sb.AppendLine(UI.Image_partitioned_status_differ);
} }
if(image1Info.HasSessions != image2Info.HasSessions) if(image1Info.HasSessions != image2Info.HasSessions)
{ {
imagesDiffer = true; imagesDiffer = true;
if(!verbose) if(!verbose)
sb.AppendLine(UI.Image_session_status_differ); sb.AppendLine(UI.Image_session_status_differ);
} }
if(image1Info.Sectors != image2Info.Sectors) if(image1Info.Sectors != image2Info.Sectors)
{ {
imagesDiffer = true; imagesDiffer = true;
if(!verbose) if(!verbose)
sb.AppendLine(UI.Image_sectors_differ); sb.AppendLine(UI.Image_sectors_differ);
} }
if(image1Info.SectorSize != image2Info.SectorSize) if(image1Info.SectorSize != image2Info.SectorSize)
{ {
imagesDiffer = true; imagesDiffer = true;
if(!verbose) if(!verbose)
sb.AppendLine(UI.Image_sector_size_differ); sb.AppendLine(UI.Image_sector_size_differ);
} }
if(image1Info.MediaType != image2Info.MediaType) if(image1Info.MediaType != image2Info.MediaType)
{ {
imagesDiffer = true; imagesDiffer = true;
if(!verbose) if(!verbose)
sb.AppendLine(UI.Media_type_differs); sb.AppendLine(UI.Media_type_differs);
} }
if(image1Info.Sectors < image2Info.Sectors) if(image1Info.Sectors < image2Info.Sectors)
{ {
imagesDiffer = true; imagesDiffer = true;
leastSectors = image1Info.Sectors; leastSectors = image1Info.Sectors;
if(!verbose) if(!verbose)
sb.AppendLine(UI.Second_image_has_more_sectors); sb.AppendLine(UI.Second_image_has_more_sectors);
} }
else if(image1Info.Sectors > image2Info.Sectors) else if(image1Info.Sectors > image2Info.Sectors)
{ {
imagesDiffer = true; imagesDiffer = true;
leastSectors = image2Info.Sectors; leastSectors = image2Info.Sectors;
if(!verbose) if(!verbose)
sb.AppendLine(UI.First_image_has_more_sectors); sb.AppendLine(UI.First_image_has_more_sectors);
} }
else else
leastSectors = image1Info.Sectors; leastSectors = image1Info.Sectors;
}); });
var input1ByteAddressable = input1Format as IByteAddressableImage; var input1ByteAddressable = input1Format as IByteAddressableImage;
var input2ByteAddressable = input2Format as IByteAddressableImage; var input2ByteAddressable = input2Format as IByteAddressableImage;
@@ -427,94 +439,105 @@ sealed class CompareCommand : Command
if(input1MediaImage is not null && if(input1MediaImage is not null &&
input2MediaImage is not null) input2MediaImage is not null)
{
AnsiConsole.Progress().AutoClear(true).HideCompleted(true). AnsiConsole.Progress().AutoClear(true).HideCompleted(true).
Columns(new TaskDescriptionColumn(), new ProgressBarColumn(), new PercentageColumn()). Columns(new TaskDescriptionColumn(), new ProgressBarColumn(), new PercentageColumn()).
Start(ctx => Start(ctx =>
{ {
ProgressTask task = ctx.AddTask(UI.Comparing_sectors); ProgressTask task = ctx.AddTask(UI.Comparing_sectors);
task.MaxValue = leastSectors; task.MaxValue = leastSectors;
for(ulong sector = 0; sector < leastSectors; sector++) for(ulong sector = 0; sector < leastSectors; sector++)
{ {
task.Value = sector; task.Value = sector;
task.Description = string.Format(UI.Comparing_sector_0_of_1, sector + 1, leastSectors); task.Description =
string.Format(UI.Comparing_sector_0_of_1, sector + 1, leastSectors);
try try
{ {
errno = input1MediaImage.ReadSector(sector, out byte[] image1Sector); errno = input1MediaImage.ReadSector(sector, out byte[] image1Sector);
if(errno != ErrorNumber.NoError) if(errno != ErrorNumber.NoError)
AaruConsole. {
ErrorWriteLine(string.Format(UI.Error_0_reading_sector_1_from_first_image, AaruConsole.
errno, sector)); 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) if(errno != ErrorNumber.NoError)
AaruConsole. {
ErrorWriteLine(string.Format(UI.Error_0_reading_sector_1_from_second_image, AaruConsole.
errno, sector)); ErrorWriteLine(string.
Format(UI.Error_0_reading_sector_1_from_second_image,
errno, sector));
}
ArrayHelpers.CompareBytes(out bool different, out bool sameSize, image1Sector, ArrayHelpers.CompareBytes(out bool different, out bool sameSize, image1Sector,
image2Sector); image2Sector);
if(different) if(different)
imagesDiffer = true; imagesDiffer = true;
// sb.AppendFormat("Sector {0} is different", sector).AppendLine(); // sb.AppendFormat("Sector {0} is different", sector).AppendLine();
else if(!sameSize) else if(!sameSize)
imagesDiffer = true; imagesDiffer = true;
/* sb. /* sb.
AppendFormat("Sector {0} has different sizes ({1} bytes in image 1, {2} in image 2) but are otherwise identical", 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();*/ sector, image1Sector.LongLength, image2Sector.LongLength).AppendLine();*/
} }
#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
catch catch
{ {
// ignored // 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
} }
}); });
}
if(input1ByteAddressable is not null && if(input1ByteAddressable is not null &&
input2ByteAddressable is not null) input2ByteAddressable is not null)
{
AnsiConsole.Progress().AutoClear(true).HideCompleted(true). AnsiConsole.Progress().AutoClear(true).HideCompleted(true).
Columns(new TaskDescriptionColumn(), new ProgressBarColumn(), new PercentageColumn()). Columns(new TaskDescriptionColumn(), new ProgressBarColumn(), new PercentageColumn()).
Start(ctx => Start(ctx =>
{ {
ProgressTask task = ctx.AddTask(UI.Comparing_images); ProgressTask task = ctx.AddTask(UI.Comparing_images);
task.IsIndeterminate = true; task.IsIndeterminate = true;
byte[] data1 = new byte[input1ByteAddressable.Info.Sectors]; var data1 = new byte[input1ByteAddressable.Info.Sectors];
byte[] data2 = new byte[input2ByteAddressable.Info.Sectors]; var data2 = new byte[input2ByteAddressable.Info.Sectors];
byte[] tmp; byte[] tmp;
input1ByteAddressable.ReadBytes(data1, 0, data1.Length, out int bytesRead); input1ByteAddressable.ReadBytes(data1, 0, data1.Length, out int bytesRead);
if(bytesRead != data1.Length) if(bytesRead != data1.Length)
{ {
tmp = new byte[bytesRead]; tmp = new byte[bytesRead];
Array.Copy(data1, 0, tmp, 0, bytesRead); Array.Copy(data1, 0, tmp, 0, bytesRead);
data1 = tmp; data1 = tmp;
} }
input2ByteAddressable.ReadBytes(data2, 0, data2.Length, out bytesRead); input2ByteAddressable.ReadBytes(data2, 0, data2.Length, out bytesRead);
if(bytesRead != data2.Length) if(bytesRead != data2.Length)
{ {
tmp = new byte[bytesRead]; tmp = new byte[bytesRead];
Array.Copy(data2, 0, tmp, 0, bytesRead); Array.Copy(data2, 0, tmp, 0, bytesRead);
data2 = tmp; data2 = tmp;
} }
ArrayHelpers.CompareBytes(out bool different, out bool sameSize, data1, data2); ArrayHelpers.CompareBytes(out bool different, out bool sameSize, data1, data2);
if(different) if(different)
imagesDiffer = true; imagesDiffer = true;
else if(!sameSize) else if(!sameSize)
imagesDiffer = true; imagesDiffer = true;
}); });
}
AaruConsole.WriteLine(); AaruConsole.WriteLine();

File diff suppressed because it is too large Load Diff

View File

@@ -31,7 +31,6 @@
// ****************************************************************************/ // ****************************************************************************/
using System; using System;
using System.Collections.Generic;
using System.CommandLine; using System.CommandLine;
using System.CommandLine.NamingConventionBinder; using System.CommandLine.NamingConventionBinder;
using System.IO; using System.IO;
@@ -60,20 +59,11 @@ sealed class CreateSidecarCommand : Command
public CreateSidecarCommand() : base("create-sidecar", UI.Image_Create_Sidecar_Command_Description) public CreateSidecarCommand() : base("create-sidecar", UI.Image_Create_Sidecar_Command_Description)
{ {
Add(new Option<int>(new[] Add(new Option<int>(new[] { "--block-size", "-b" }, () => 512, UI.Tape_block_size_argument_help));
{
"--block-size", "-b"
}, () => 512, UI.Tape_block_size_argument_help));
Add(new Option<string>(new[] Add(new Option<string>(new[] { "--encoding", "-e" }, () => null, UI.Name_of_character_encoding_to_use));
{
"--encoding", "-e"
}, () => null, UI.Name_of_character_encoding_to_use));
Add(new Option<bool>(new[] Add(new Option<bool>(new[] { "--tape", "-t" }, () => false, UI.Tape_argument_input_help));
{
"--tape", "-t"
}, () => false, UI.Tape_argument_input_help));
AddArgument(new Argument<string> AddArgument(new Argument<string>
{ {
@@ -85,7 +75,7 @@ sealed class CreateSidecarCommand : Command
Handler = CommandHandler.Create(GetType().GetMethod(nameof(Invoke))); 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) string imagePath, bool tape)
{ {
MainClass.PrintCopyright(); MainClass.PrintCopyright();
@@ -98,35 +88,38 @@ sealed class CreateSidecarCommand : Command
}); });
AaruConsole.DebugWriteLineEvent += (format, objects) => AaruConsole.DebugWriteLineEvent += (format, objects) =>
{ {
if(objects is null) if(objects is null)
stderrConsole.MarkupLine(format); stderrConsole.MarkupLine(format);
else else
stderrConsole.MarkupLine(format, objects); stderrConsole.MarkupLine(format, objects);
}; };
} }
if(verbose) if(verbose)
{
AaruConsole.WriteEvent += (format, objects) => AaruConsole.WriteEvent += (format, objects) =>
{ {
if(objects is null) if(objects is null)
AnsiConsole.Markup(format); AnsiConsole.Markup(format);
else else
AnsiConsole.Markup(format, objects); AnsiConsole.Markup(format, objects);
}; };
}
Statistics.AddCommand("create-sidecar"); Statistics.AddCommand("create-sidecar");
AaruConsole.DebugWriteLine(MODULE_NAME, "--block-size={0}", blockSize); AaruConsole.DebugWriteLine(MODULE_NAME, "--block-size={0}", blockSize);
AaruConsole.DebugWriteLine(MODULE_NAME, "--debug={0}", debug); AaruConsole.DebugWriteLine(MODULE_NAME, "--debug={0}", debug);
AaruConsole.DebugWriteLine(MODULE_NAME, "--encoding={0}", encodingName); AaruConsole.DebugWriteLine(MODULE_NAME, "--encoding={0}", encodingName);
AaruConsole.DebugWriteLine(MODULE_NAME, "--input={0}", imagePath); AaruConsole.DebugWriteLine(MODULE_NAME, "--input={0}", imagePath);
AaruConsole.DebugWriteLine(MODULE_NAME, "--tape={0}", tape); AaruConsole.DebugWriteLine(MODULE_NAME, "--tape={0}", tape);
AaruConsole.DebugWriteLine(MODULE_NAME, "--verbose={0}", verbose); AaruConsole.DebugWriteLine(MODULE_NAME, "--verbose={0}", verbose);
Encoding encodingClass = null; Encoding encodingClass = null;
if(encodingName != null) if(encodingName != null)
{
try try
{ {
encodingClass = Claunia.Encoding.Encoding.GetEncoding(encodingName); encodingClass = Claunia.Encoding.Encoding.GetEncoding(encodingName);
@@ -140,6 +133,7 @@ sealed class CreateSidecarCommand : Command
return (int)ErrorNumber.EncodingUnknown; return (int)ErrorNumber.EncodingUnknown;
} }
}
if(File.Exists(imagePath)) if(File.Exists(imagePath))
{ {
@@ -154,10 +148,10 @@ sealed class CreateSidecarCommand : Command
IFilter inputFilter = null; IFilter inputFilter = null;
Core.Spectre.ProgressSingleSpinner(ctx => Core.Spectre.ProgressSingleSpinner(ctx =>
{ {
ctx.AddTask(UI.Identifying_file_filter).IsIndeterminate(); ctx.AddTask(UI.Identifying_file_filter).IsIndeterminate();
inputFilter = filtersList.GetFilter(imagePath); inputFilter = filtersList.GetFilter(imagePath);
}); });
if(inputFilter == null) if(inputFilter == null)
{ {
@@ -171,10 +165,10 @@ sealed class CreateSidecarCommand : Command
IBaseImage imageFormat = null; IBaseImage imageFormat = null;
Core.Spectre.ProgressSingleSpinner(ctx => Core.Spectre.ProgressSingleSpinner(ctx =>
{ {
ctx.AddTask(UI.Identifying_image_format).IsIndeterminate(); ctx.AddTask(UI.Identifying_image_format).IsIndeterminate();
imageFormat = ImageFormat.Detect(inputFilter); imageFormat = ImageFormat.Detect(inputFilter);
}); });
if(imageFormat == null) if(imageFormat == null)
{ {
@@ -193,10 +187,10 @@ sealed class CreateSidecarCommand : Command
ErrorNumber opened = ErrorNumber.NoData; ErrorNumber opened = ErrorNumber.NoData;
Core.Spectre.ProgressSingleSpinner(ctx => Core.Spectre.ProgressSingleSpinner(ctx =>
{ {
ctx.AddTask(UI.Invoke_Opening_image_file).IsIndeterminate(); ctx.AddTask(UI.Invoke_Opening_image_file).IsIndeterminate();
opened = imageFormat.Open(inputFilter); opened = imageFormat.Open(inputFilter);
}); });
if(opened != ErrorNumber.NoError) if(opened != ErrorNumber.NoError)
{ {
@@ -225,75 +219,80 @@ sealed class CreateSidecarCommand : Command
AnsiConsole.Progress().AutoClear(true).HideCompleted(true). AnsiConsole.Progress().AutoClear(true).HideCompleted(true).
Columns(new TaskDescriptionColumn(), new ProgressBarColumn(), new PercentageColumn()). Columns(new TaskDescriptionColumn(), new ProgressBarColumn(), new PercentageColumn()).
Start(ctx => Start(ctx =>
{ {
sidecarClass.InitProgressEvent += () => sidecarClass.InitProgressEvent += () =>
{ {
_progressTask1 = ctx.AddTask("Progress"); _progressTask1 = ctx.AddTask("Progress");
}; };
sidecarClass.InitProgressEvent2 += () => sidecarClass.InitProgressEvent2 += () =>
{ {
_progressTask2 = ctx.AddTask("Progress"); _progressTask2 = ctx.AddTask("Progress");
}; };
sidecarClass.UpdateProgressEvent += (text, current, maximum) => sidecarClass.UpdateProgressEvent += (text, current, maximum) =>
{ {
_progressTask1 ??= ctx.AddTask("Progress"); _progressTask1 ??=
_progressTask1.Description = Markup.Escape(text); ctx.AddTask("Progress");
_progressTask1.Value = current; _progressTask1.Description =
_progressTask1.MaxValue = maximum; Markup.Escape(text);
}; _progressTask1.Value = current;
_progressTask1.MaxValue = maximum;
};
sidecarClass.UpdateProgressEvent2 += (text, current, maximum) => sidecarClass.UpdateProgressEvent2 += (text, current, maximum) =>
{ {
_progressTask2 ??= ctx.AddTask("Progress"); _progressTask2 ??=
_progressTask2.Description = Markup.Escape(text); ctx.AddTask("Progress");
_progressTask2.Value = current; _progressTask2.Description =
_progressTask2.MaxValue = maximum; Markup.Escape(text);
}; _progressTask2.Value = current;
_progressTask2.MaxValue = maximum;
};
sidecarClass.EndProgressEvent += () => sidecarClass.EndProgressEvent += () =>
{ {
_progressTask1?.StopTask(); _progressTask1?.StopTask();
_progressTask1 = null; _progressTask1 = null;
}; };
sidecarClass.EndProgressEvent2 += () => sidecarClass.EndProgressEvent2 += () =>
{ {
_progressTask2?.StopTask(); _progressTask2?.StopTask();
_progressTask2 = null; _progressTask2 = null;
}; };
sidecarClass.UpdateStatusEvent += text => sidecarClass.UpdateStatusEvent += text =>
{ {
AaruConsole.WriteLine(Markup.Escape(text)); AaruConsole.WriteLine(Markup.Escape(text));
}; };
System.Console.CancelKeyPress += (_, e) => System.Console.CancelKeyPress += (_, e) =>
{ {
e.Cancel = true; e.Cancel = true;
sidecarClass.Abort(); sidecarClass.Abort();
}; };
sidecar = sidecarClass.Create(); sidecar = sidecarClass.Create();
}); });
Core.Spectre.ProgressSingleSpinner(ctx => Core.Spectre.ProgressSingleSpinner(ctx =>
{ {
ctx.AddTask(Localization.Core.Writing_metadata_sidecar).IsIndeterminate(); ctx.AddTask(Localization.Core.Writing_metadata_sidecar).
IsIndeterminate();
var jsonFs = var jsonFs =
new new
FileStream(Path.Combine(Path.GetDirectoryName(imagePath) ?? throw new InvalidOperationException(), Path.GetFileNameWithoutExtension(imagePath) + ".metadata.json"), FileStream(Path.Combine(Path.GetDirectoryName(imagePath) ?? throw new InvalidOperationException(), Path.GetFileNameWithoutExtension(imagePath) + ".metadata.json"),
FileMode.Create); FileMode.Create);
JsonSerializer.Serialize(jsonFs, new MetadataJson JsonSerializer.Serialize(jsonFs, new MetadataJson
{ {
AaruMetadata = sidecar AaruMetadata = sidecar
}, typeof(MetadataJson), MetadataJsonContext.Default); }, typeof(MetadataJson), MetadataJsonContext.Default);
jsonFs.Close(); jsonFs.Close();
}); });
} }
catch(Exception ex) catch(Exception ex)
{ {
@@ -312,8 +311,8 @@ sealed class CreateSidecarCommand : Command
return (int)ErrorNumber.IsDirectory; return (int)ErrorNumber.IsDirectory;
} }
string[] contents = Directory.GetFiles(imagePath, "*", SearchOption.TopDirectoryOnly); string[] contents = Directory.GetFiles(imagePath, "*", SearchOption.TopDirectoryOnly);
List<string> files = contents.Where(file => new FileInfo(file).Length % blockSize == 0).ToList(); var files = contents.Where(file => new FileInfo(file).Length % blockSize == 0).ToList();
files.Sort(StringComparer.CurrentCultureIgnoreCase); files.Sort(StringComparer.CurrentCultureIgnoreCase);
@@ -323,75 +322,75 @@ sealed class CreateSidecarCommand : Command
AnsiConsole.Progress().AutoClear(true).HideCompleted(true). AnsiConsole.Progress().AutoClear(true).HideCompleted(true).
Columns(new TaskDescriptionColumn(), new ProgressBarColumn(), new PercentageColumn()). Columns(new TaskDescriptionColumn(), new ProgressBarColumn(), new PercentageColumn()).
Start(ctx => Start(ctx =>
{ {
sidecarClass.InitProgressEvent += () => sidecarClass.InitProgressEvent += () => { _progressTask1 = ctx.AddTask("Progress"); };
{
_progressTask1 = ctx.AddTask("Progress");
};
sidecarClass.InitProgressEvent2 += () => sidecarClass.InitProgressEvent2 += () =>
{ {
_progressTask2 = ctx.AddTask("Progress"); _progressTask2 = ctx.AddTask("Progress");
}; };
sidecarClass.UpdateProgressEvent += (text, current, maximum) => sidecarClass.UpdateProgressEvent += (text, current, maximum) =>
{ {
_progressTask1 ??= ctx.AddTask("Progress"); _progressTask1 ??= ctx.AddTask("Progress");
_progressTask1.Description = Markup.Escape(text); _progressTask1.Description =
_progressTask1.Value = current; Markup.Escape(text);
_progressTask1.MaxValue = maximum; _progressTask1.Value = current;
}; _progressTask1.MaxValue = maximum;
};
sidecarClass.UpdateProgressEvent2 += (text, current, maximum) => sidecarClass.UpdateProgressEvent2 += (text, current, maximum) =>
{ {
_progressTask2 ??= ctx.AddTask("Progress"); _progressTask2 ??= ctx.AddTask("Progress");
_progressTask2.Description = Markup.Escape(text); _progressTask2.Description =
_progressTask2.Value = current; Markup.Escape(text);
_progressTask2.MaxValue = maximum; _progressTask2.Value = current;
}; _progressTask2.MaxValue = maximum;
};
sidecarClass.EndProgressEvent += () => sidecarClass.EndProgressEvent += () =>
{ {
_progressTask1?.StopTask(); _progressTask1?.StopTask();
_progressTask1 = null; _progressTask1 = null;
}; };
sidecarClass.EndProgressEvent2 += () => sidecarClass.EndProgressEvent2 += () =>
{ {
_progressTask2?.StopTask(); _progressTask2?.StopTask();
_progressTask2 = null; _progressTask2 = null;
}; };
sidecarClass.UpdateStatusEvent += text => sidecarClass.UpdateStatusEvent += text =>
{ {
AaruConsole.WriteLine(Markup.Escape(text)); AaruConsole.WriteLine(Markup.Escape(text));
}; };
System.Console.CancelKeyPress += (_, e) => System.Console.CancelKeyPress += (_, e) =>
{ {
e.Cancel = true; e.Cancel = true;
sidecarClass.Abort(); sidecarClass.Abort();
}; };
sidecar = sidecarClass.BlockTape(Path.GetFileName(imagePath), files, blockSize); sidecar = sidecarClass.BlockTape(Path.GetFileName(imagePath), files, blockSize);
}); });
Core.Spectre.ProgressSingleSpinner(ctx => Core.Spectre.ProgressSingleSpinner(ctx =>
{ {
ctx.AddTask(Localization.Core.Writing_metadata_sidecar).IsIndeterminate(); ctx.AddTask(Localization.Core.Writing_metadata_sidecar).
IsIndeterminate();
var jsonFs = var jsonFs =
new new
FileStream(Path.Combine(Path.GetDirectoryName(imagePath) ?? throw new InvalidOperationException(), Path.GetFileNameWithoutExtension(imagePath) + ".metadata.json"), FileStream(Path.Combine(Path.GetDirectoryName(imagePath) ?? throw new InvalidOperationException(), Path.GetFileNameWithoutExtension(imagePath) + ".metadata.json"),
FileMode.Create); FileMode.Create);
JsonSerializer.Serialize(jsonFs, new MetadataJson JsonSerializer.Serialize(jsonFs, new MetadataJson
{ {
AaruMetadata = sidecar AaruMetadata = sidecar
}, typeof(MetadataJson), MetadataJsonContext.Default); }, typeof(MetadataJson), MetadataJsonContext.Default);
jsonFs.Close(); jsonFs.Close();
}); });
} }
else else
AaruConsole.ErrorWriteLine(UI.The_specified_input_file_cannot_be_found); AaruConsole.ErrorWriteLine(UI.The_specified_input_file_cannot_be_found);

View File

@@ -52,25 +52,14 @@ sealed class DecodeCommand : Command
public DecodeCommand() : base("decode", UI.Image_Decode_Command_Description) public DecodeCommand() : base("decode", UI.Image_Decode_Command_Description)
{ {
Add(new Option<bool>(new[] Add(new Option<bool>(new[] { "--disk-tags", "-f" }, () => true, UI.Decode_media_tags));
{
"--disk-tags", "-f"
}, () => true, UI.Decode_media_tags));
Add(new Option<string>(new[] Add(new Option<string>(new[] { "--length", "-l" }, () => UI.Parameter_response_all_sectors,
{ UI.How_many_sectors_to_decode_or_all));
"--length", "-l"
}, () => UI.Parameter_response_all_sectors, UI.How_many_sectors_to_decode_or_all));
Add(new Option<bool>(new[] Add(new Option<bool>(new[] { "--sector-tags", "-p" }, () => true, UI.Decode_sector_tags));
{
"--sector-tags", "-p"
}, () => true, UI.Decode_sector_tags));
Add(new Option<ulong>(new[] Add(new Option<ulong>(new[] { "--start", "-s" }, () => 0, UI.Sector_to_start_decoding_from));
{
"--start", "-s"
}, () => 0, UI.Sector_to_start_decoding_from));
AddArgument(new Argument<string> AddArgument(new Argument<string>
{ {
@@ -82,7 +71,7 @@ sealed class DecodeCommand : Command
Handler = CommandHandler.Create(GetType().GetMethod(nameof(Invoke))); Handler = CommandHandler.Create(GetType().GetMethod(nameof(Invoke)));
} }
public static int Invoke(bool verbose, bool debug, bool diskTags, string imagePath, string length, bool sectorTags, public static int Invoke(bool verbose, bool debug, bool diskTags, string imagePath, string length, bool sectorTags,
ulong startSector) ulong startSector)
{ {
MainClass.PrintCopyright(); MainClass.PrintCopyright();
@@ -95,41 +84,43 @@ sealed class DecodeCommand : Command
}); });
AaruConsole.DebugWriteLineEvent += (format, objects) => AaruConsole.DebugWriteLineEvent += (format, objects) =>
{ {
if(objects is null) if(objects is null)
stderrConsole.MarkupLine(format); stderrConsole.MarkupLine(format);
else else
stderrConsole.MarkupLine(format, objects); stderrConsole.MarkupLine(format, objects);
}; };
} }
if(verbose) if(verbose)
{
AaruConsole.WriteEvent += (format, objects) => AaruConsole.WriteEvent += (format, objects) =>
{ {
if(objects is null) if(objects is null)
AnsiConsole.Markup(format); AnsiConsole.Markup(format);
else else
AnsiConsole.Markup(format, objects); AnsiConsole.Markup(format, objects);
}; };
}
Statistics.AddCommand("decode"); Statistics.AddCommand("decode");
AaruConsole.DebugWriteLine(MODULE_NAME, "--debug={0}", debug); AaruConsole.DebugWriteLine(MODULE_NAME, "--debug={0}", debug);
AaruConsole.DebugWriteLine(MODULE_NAME, "--disk-tags={0}", diskTags); AaruConsole.DebugWriteLine(MODULE_NAME, "--disk-tags={0}", diskTags);
AaruConsole.DebugWriteLine(MODULE_NAME, "--input={0}", imagePath); AaruConsole.DebugWriteLine(MODULE_NAME, "--input={0}", imagePath);
AaruConsole.DebugWriteLine(MODULE_NAME, "--length={0}", length); AaruConsole.DebugWriteLine(MODULE_NAME, "--length={0}", length);
AaruConsole.DebugWriteLine(MODULE_NAME, "--sector-tags={0}", sectorTags); AaruConsole.DebugWriteLine(MODULE_NAME, "--sector-tags={0}", sectorTags);
AaruConsole.DebugWriteLine(MODULE_NAME, "--start={0}", startSector); AaruConsole.DebugWriteLine(MODULE_NAME, "--start={0}", startSector);
AaruConsole.DebugWriteLine(MODULE_NAME, "--verbose={0}", verbose); AaruConsole.DebugWriteLine(MODULE_NAME, "--verbose={0}", verbose);
var filtersList = new FiltersList(); var filtersList = new FiltersList();
IFilter inputFilter = null; IFilter inputFilter = null;
Core.Spectre.ProgressSingleSpinner(ctx => Core.Spectre.ProgressSingleSpinner(ctx =>
{ {
ctx.AddTask(UI.Identifying_file_filter).IsIndeterminate(); ctx.AddTask(UI.Identifying_file_filter).IsIndeterminate();
inputFilter = filtersList.GetFilter(imagePath); inputFilter = filtersList.GetFilter(imagePath);
}); });
if(inputFilter == null) if(inputFilter == null)
{ {
@@ -142,11 +133,11 @@ sealed class DecodeCommand : Command
IBaseImage baseImage = null; IBaseImage baseImage = null;
Core.Spectre.ProgressSingleSpinner(ctx => Core.Spectre.ProgressSingleSpinner(ctx =>
{ {
ctx.AddTask(UI.Identifying_image_format).IsIndeterminate(); ctx.AddTask(UI.Identifying_image_format).IsIndeterminate();
baseImage = ImageFormat.Detect(inputFilter); baseImage = ImageFormat.Detect(inputFilter);
inputFormat = baseImage as IMediaImage; inputFormat = baseImage as IMediaImage;
}); });
if(baseImage == null) if(baseImage == null)
{ {
@@ -165,10 +156,10 @@ sealed class DecodeCommand : Command
ErrorNumber opened = ErrorNumber.NoData; ErrorNumber opened = ErrorNumber.NoData;
Core.Spectre.ProgressSingleSpinner(ctx => Core.Spectre.ProgressSingleSpinner(ctx =>
{ {
ctx.AddTask(UI.Invoke_Opening_image_file).IsIndeterminate(); ctx.AddTask(UI.Invoke_Opening_image_file).IsIndeterminate();
opened = inputFormat.Open(inputFilter); opened = inputFormat.Open(inputFilter);
}); });
if(opened != ErrorNumber.NoError) if(opened != ErrorNumber.NoError)
{ {
@@ -184,10 +175,13 @@ sealed class DecodeCommand : Command
ErrorNumber errno; ErrorNumber errno;
if(diskTags) if(diskTags)
{
if(inputFormat.Info.ReadableMediaTags.Count == 0) if(inputFormat.Info.ReadableMediaTags.Count == 0)
AaruConsole.WriteLine(UI.There_are_no_media_tags_in_chosen_disc_image); AaruConsole.WriteLine(UI.There_are_no_media_tags_in_chosen_disc_image);
else else
{
foreach(MediaTagType tag in inputFormat.Info.ReadableMediaTags) foreach(MediaTagType tag in inputFormat.Info.ReadableMediaTags)
{
switch(tag) switch(tag)
{ {
case MediaTagType.SCSI_INQUIRY: case MediaTagType.SCSI_INQUIRY:
@@ -216,8 +210,10 @@ sealed class DecodeCommand : Command
errno = inputFormat.ReadMediaTag(MediaTagType.ATA_IDENTIFY, out byte[] identify); errno = inputFormat.ReadMediaTag(MediaTagType.ATA_IDENTIFY, out byte[] identify);
if(errno != ErrorNumber.NoError) if(errno != ErrorNumber.NoError)
{
AaruConsole.WriteLine(UI.Error_0_reading_ATA_IDENTIFY_DEVICE_response_from_disc_image, AaruConsole.WriteLine(UI.Error_0_reading_ATA_IDENTIFY_DEVICE_response_from_disc_image,
errno); errno);
}
else else
{ {
AaruConsole.WriteLine($"[bold]{UI.ATA_IDENTIFY_DEVICE_command_response}[/]"); 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); errno = inputFormat.ReadMediaTag(MediaTagType.ATAPI_IDENTIFY, out byte[] identify);
if(identify == null) if(identify == null)
{
AaruConsole. AaruConsole.
WriteLine(UI.Error_0_reading_ATA_IDENTIFY_PACKET_DEVICE_response_from_disc_image, WriteLine(UI.Error_0_reading_ATA_IDENTIFY_PACKET_DEVICE_response_from_disc_image,
errno); errno);
}
else else
{ {
AaruConsole.WriteLine($"[bold]{UI.ATA_IDENTIFY_PACKET_DEVICE_command_response}[/]"); AaruConsole.WriteLine($"[bold]{UI.ATA_IDENTIFY_PACKET_DEVICE_command_response}[/]");
@@ -388,6 +386,9 @@ sealed class DecodeCommand : Command
break; break;
} }
}
}
}
if(!sectorTags) if(!sectorTags)
return (int)ErrorNumber.NoError; return (int)ErrorNumber.NoError;
@@ -407,7 +408,9 @@ sealed class DecodeCommand : Command
if(inputFormat.Info.ReadableSectorTags.Count == 0) if(inputFormat.Info.ReadableSectorTags.Count == 0)
AaruConsole.WriteLine(UI.There_are_no_sector_tags_in_chosen_disc_image); AaruConsole.WriteLine(UI.There_are_no_sector_tags_in_chosen_disc_image);
else else
{
foreach(SectorTagType tag in inputFormat.Info.ReadableSectorTags) foreach(SectorTagType tag in inputFormat.Info.ReadableSectorTags)
{
switch(tag) switch(tag)
{ {
default: default:
@@ -415,6 +418,8 @@ sealed class DecodeCommand : Command
break; break;
} }
}
}
// TODO: Not implemented // TODO: Not implemented

View File

@@ -50,20 +50,13 @@ sealed class EntropyCommand : Command
public EntropyCommand() : base("entropy", UI.Image_Entropy_Command_Description) public EntropyCommand() : base("entropy", UI.Image_Entropy_Command_Description)
{ {
Add(new Option<bool>(new[] Add(new Option<bool>(new[] { "--duplicated-sectors", "-p" }, () => true,
{ UI.Calculates_how_many_sectors_are_duplicated));
"--duplicated-sectors", "-p"
}, () => true, UI.Calculates_how_many_sectors_are_duplicated));
Add(new Option<bool>(new[] Add(new Option<bool>(new[] { "--separated-tracks", "-t" }, () => true,
{ UI.Calculates_entropy_for_each_track_separately));
"--separated-tracks", "-t"
}, () => true, UI.Calculates_entropy_for_each_track_separately));
Add(new Option<bool>(new[] Add(new Option<bool>(new[] { "--whole-disc", "-w" }, () => true, UI.Calculates_entropy_for_the_whole_disc));
{
"--whole-disc", "-w"
}, () => true, UI.Calculates_entropy_for_the_whole_disc));
AddArgument(new Argument<string> AddArgument(new Argument<string>
{ {
@@ -88,40 +81,42 @@ sealed class EntropyCommand : Command
}); });
AaruConsole.DebugWriteLineEvent += (format, objects) => AaruConsole.DebugWriteLineEvent += (format, objects) =>
{ {
if(objects is null) if(objects is null)
stderrConsole.MarkupLine(format); stderrConsole.MarkupLine(format);
else else
stderrConsole.MarkupLine(format, objects); stderrConsole.MarkupLine(format, objects);
}; };
} }
if(verbose) if(verbose)
{
AaruConsole.WriteEvent += (format, objects) => AaruConsole.WriteEvent += (format, objects) =>
{ {
if(objects is null) if(objects is null)
AnsiConsole.Markup(format); AnsiConsole.Markup(format);
else else
AnsiConsole.Markup(format, objects); AnsiConsole.Markup(format, objects);
}; };
}
Statistics.AddCommand("entropy"); 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, "--duplicated-sectors={0}", duplicatedSectors);
AaruConsole.DebugWriteLine(MODULE_NAME, "--input={0}", imagePath); AaruConsole.DebugWriteLine(MODULE_NAME, "--input={0}", imagePath);
AaruConsole.DebugWriteLine(MODULE_NAME, "--separated-tracks={0}", separatedTracks); AaruConsole.DebugWriteLine(MODULE_NAME, "--separated-tracks={0}", separatedTracks);
AaruConsole.DebugWriteLine(MODULE_NAME, "--verbose={0}", verbose); AaruConsole.DebugWriteLine(MODULE_NAME, "--verbose={0}", verbose);
AaruConsole.DebugWriteLine(MODULE_NAME, "--whole-disc={0}", wholeDisc); AaruConsole.DebugWriteLine(MODULE_NAME, "--whole-disc={0}", wholeDisc);
var filtersList = new FiltersList(); var filtersList = new FiltersList();
IFilter inputFilter = null; IFilter inputFilter = null;
Core.Spectre.ProgressSingleSpinner(ctx => Core.Spectre.ProgressSingleSpinner(ctx =>
{ {
ctx.AddTask(UI.Identifying_file_filter).IsIndeterminate(); ctx.AddTask(UI.Identifying_file_filter).IsIndeterminate();
inputFilter = filtersList.GetFilter(imagePath); inputFilter = filtersList.GetFilter(imagePath);
}); });
if(inputFilter == null) if(inputFilter == null)
{ {
@@ -133,10 +128,10 @@ sealed class EntropyCommand : Command
IBaseImage inputFormat = null; IBaseImage inputFormat = null;
Core.Spectre.ProgressSingleSpinner(ctx => Core.Spectre.ProgressSingleSpinner(ctx =>
{ {
ctx.AddTask(UI.Identifying_image_format).IsIndeterminate(); ctx.AddTask(UI.Identifying_image_format).IsIndeterminate();
inputFormat = ImageFormat.Detect(inputFilter); inputFormat = ImageFormat.Detect(inputFilter);
}); });
if(inputFormat == null) if(inputFormat == null)
{ {
@@ -148,10 +143,10 @@ sealed class EntropyCommand : Command
ErrorNumber opened = ErrorNumber.NoData; ErrorNumber opened = ErrorNumber.NoData;
Core.Spectre.ProgressSingleSpinner(ctx => Core.Spectre.ProgressSingleSpinner(ctx =>
{ {
ctx.AddTask(UI.Invoke_Opening_image_file).IsIndeterminate(); ctx.AddTask(UI.Invoke_Opening_image_file).IsIndeterminate();
opened = inputFormat.Open(inputFilter); opened = inputFormat.Open(inputFilter);
}); });
if(opened != ErrorNumber.NoError) if(opened != ErrorNumber.NoError)
{ {
@@ -171,42 +166,48 @@ sealed class EntropyCommand : Command
Columns(new TaskDescriptionColumn(), new ProgressBarColumn(), new PercentageColumn()).Start(ctx => Columns(new TaskDescriptionColumn(), new ProgressBarColumn(), new PercentageColumn()).Start(ctx =>
{ {
entropyCalculator.InitProgressEvent += () => entropyCalculator.InitProgressEvent += () =>
{ {
_progressTask1 = ctx.AddTask("Progress"); _progressTask1 =
}; ctx.AddTask("Progress");
};
entropyCalculator.InitProgress2Event += () => entropyCalculator.InitProgress2Event += () =>
{ {
_progressTask2 = ctx.AddTask("Progress"); _progressTask2 =
}; ctx.AddTask("Progress");
};
entropyCalculator.UpdateProgressEvent += (text, current, maximum) => entropyCalculator.UpdateProgressEvent += (text, current, maximum) =>
{ {
_progressTask1 ??= ctx.AddTask("Progress"); _progressTask1 ??=
_progressTask1.Description = Markup.Escape(text); ctx.AddTask("Progress");
_progressTask1.Value = current; _progressTask1.Description =
_progressTask1.MaxValue = maximum; Markup.Escape(text);
}; _progressTask1.Value = current;
_progressTask1.MaxValue = maximum;
};
entropyCalculator.UpdateProgress2Event += (text, current, maximum) => entropyCalculator.UpdateProgress2Event += (text, current, maximum) =>
{ {
_progressTask2 ??= ctx.AddTask("Progress"); _progressTask2 ??=
_progressTask2.Description = Markup.Escape(text); ctx.AddTask("Progress");
_progressTask2.Value = current; _progressTask2.Description =
_progressTask2.MaxValue = maximum; Markup.Escape(text);
}; _progressTask2.Value = current;
_progressTask2.MaxValue = maximum;
};
entropyCalculator.EndProgressEvent += () => entropyCalculator.EndProgressEvent += () =>
{ {
_progressTask1?.StopTask(); _progressTask1?.StopTask();
_progressTask1 = null; _progressTask1 = null;
}; };
entropyCalculator.EndProgress2Event += () => entropyCalculator.EndProgress2Event += () =>
{ {
_progressTask2?.StopTask(); _progressTask2?.StopTask();
_progressTask2 = null; _progressTask2 = null;
}; };
if(wholeDisc && inputFormat is IOpticalMediaImage opticalFormat) if(wholeDisc && inputFormat is IOpticalMediaImage opticalFormat)
{ {
@@ -233,24 +234,31 @@ sealed class EntropyCommand : Command
trackEntropy.Entropy); trackEntropy.Entropy);
if(trackEntropy.UniqueSectors != null) 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, trackEntropy.UniqueSectors,
(double)trackEntropy.UniqueSectors / trackEntropy.Sectors); (double)trackEntropy.UniqueSectors /
trackEntropy.Sectors);
}
} }
} }
if(!wholeDisc) if(!wholeDisc)
return; return;
EntropyResults entropy = inputFormat.Info.MetadataMediaType == MetadataMediaType.LinearMedia EntropyResults entropy =
? entropyCalculator.CalculateLinearMediaEntropy() inputFormat.Info.MetadataMediaType == MetadataMediaType.LinearMedia
: entropyCalculator.CalculateMediaEntropy(duplicatedSectors); ? entropyCalculator.CalculateLinearMediaEntropy()
: entropyCalculator.CalculateMediaEntropy(duplicatedSectors);
AaruConsole.WriteLine(UI.Entropy_for_disk_is_0, entropy.Entropy); AaruConsole.WriteLine(UI.Entropy_for_disk_is_0, entropy.Entropy);
if(entropy.UniqueSectors != null) if(entropy.UniqueSectors != null)
{
AaruConsole.WriteLine(UI.Disk_has_0_unique_sectors_1, entropy.UniqueSectors, AaruConsole.WriteLine(UI.Disk_has_0_unique_sectors_1, entropy.UniqueSectors,
(double)entropy.UniqueSectors / entropy.Sectors); (double)entropy.UniqueSectors / entropy.Sectors);
}
}); });
return (int)ErrorNumber.NoError; return (int)ErrorNumber.NoError;

View File

@@ -71,37 +71,39 @@ sealed class ImageInfoCommand : Command
}); });
AaruConsole.DebugWriteLineEvent += (format, objects) => AaruConsole.DebugWriteLineEvent += (format, objects) =>
{ {
if(objects is null) if(objects is null)
stderrConsole.MarkupLine(format); stderrConsole.MarkupLine(format);
else else
stderrConsole.MarkupLine(format, objects); stderrConsole.MarkupLine(format, objects);
}; };
} }
if(verbose) if(verbose)
{
AaruConsole.WriteEvent += (format, objects) => AaruConsole.WriteEvent += (format, objects) =>
{ {
if(objects is null) if(objects is null)
AnsiConsole.Markup(format); AnsiConsole.Markup(format);
else else
AnsiConsole.Markup(format, objects); AnsiConsole.Markup(format, objects);
}; };
}
Statistics.AddCommand("image-info"); Statistics.AddCommand("image-info");
AaruConsole.DebugWriteLine(MODULE_NAME, "--debug={0}", debug); AaruConsole.DebugWriteLine(MODULE_NAME, "--debug={0}", debug);
AaruConsole.DebugWriteLine(MODULE_NAME, "--input={0}", imagePath); AaruConsole.DebugWriteLine(MODULE_NAME, "--input={0}", imagePath);
AaruConsole.DebugWriteLine(MODULE_NAME, "--verbose={0}", verbose); AaruConsole.DebugWriteLine(MODULE_NAME, "--verbose={0}", verbose);
var filtersList = new FiltersList(); var filtersList = new FiltersList();
IFilter inputFilter = null; IFilter inputFilter = null;
Core.Spectre.ProgressSingleSpinner(ctx => Core.Spectre.ProgressSingleSpinner(ctx =>
{ {
ctx.AddTask(UI.Identifying_file_filter).IsIndeterminate(); ctx.AddTask(UI.Identifying_file_filter).IsIndeterminate();
inputFilter = filtersList.GetFilter(imagePath); inputFilter = filtersList.GetFilter(imagePath);
}); });
if(inputFilter == null) if(inputFilter == null)
{ {
@@ -115,10 +117,10 @@ sealed class ImageInfoCommand : Command
IBaseImage imageFormat = null; IBaseImage imageFormat = null;
Core.Spectre.ProgressSingleSpinner(ctx => Core.Spectre.ProgressSingleSpinner(ctx =>
{ {
ctx.AddTask(UI.Identifying_image_format).IsIndeterminate(); ctx.AddTask(UI.Identifying_image_format).IsIndeterminate();
imageFormat = ImageFormat.Detect(inputFilter); imageFormat = ImageFormat.Detect(inputFilter);
}); });
if(imageFormat == null) if(imageFormat == null)
{ {
@@ -135,10 +137,10 @@ sealed class ImageInfoCommand : Command
ErrorNumber opened = ErrorNumber.NoData; ErrorNumber opened = ErrorNumber.NoData;
Core.Spectre.ProgressSingleSpinner(ctx => Core.Spectre.ProgressSingleSpinner(ctx =>
{ {
ctx.AddTask(UI.Invoke_Opening_image_file).IsIndeterminate(); ctx.AddTask(UI.Invoke_Opening_image_file).IsIndeterminate();
opened = imageFormat.Open(inputFilter); opened = imageFormat.Open(inputFilter);
}); });
if(opened != ErrorNumber.NoError) if(opened != ErrorNumber.NoError)
{ {

View File

@@ -64,24 +64,26 @@ sealed class ListOptionsCommand : Command
}); });
AaruConsole.DebugWriteLineEvent += (format, objects) => AaruConsole.DebugWriteLineEvent += (format, objects) =>
{ {
if(objects is null) if(objects is null)
stderrConsole.MarkupLine(format); stderrConsole.MarkupLine(format);
else else
stderrConsole.MarkupLine(format, objects); stderrConsole.MarkupLine(format, objects);
}; };
} }
if(verbose) if(verbose)
{
AaruConsole.WriteEvent += (format, objects) => AaruConsole.WriteEvent += (format, objects) =>
{ {
if(objects is null) if(objects is null)
AnsiConsole.Markup(format); AnsiConsole.Markup(format);
else else
AnsiConsole.Markup(format, objects); 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); AaruConsole.DebugWriteLine(MODULE_NAME, "--verbose={0}", verbose);
Statistics.AddCommand("list-options"); Statistics.AddCommand("list-options");
@@ -94,7 +96,7 @@ sealed class ListOptionsCommand : Command
if(Activator.CreateInstance(kvp.Value) is not IBaseWritableImage plugin) if(Activator.CreateInstance(kvp.Value) is not IBaseWritableImage plugin)
continue; continue;
List<(string name, Type type, string description, object @default)> options = var options =
plugin.SupportedOptions.ToList(); plugin.SupportedOptions.ToList();
if(options.Count == 0) if(options.Count == 0)
@@ -112,8 +114,10 @@ sealed class ListOptionsCommand : Command
foreach((string name, Type type, string description, object @default) option in foreach((string name, Type type, string description, object @default) option in
options.OrderBy(t => t.name)) options.OrderBy(t => t.name))
{
table.AddRow(Markup.Escape(option.name), TypeToString(option.type), option.@default?.ToString() ?? "", table.AddRow(Markup.Escape(option.name), TypeToString(option.type), option.@default?.ToString() ?? "",
Markup.Escape(option.description)); Markup.Escape(option.description));
}
AnsiConsole.Write(table); AnsiConsole.Write(table);
AaruConsole.WriteLine(); AaruConsole.WriteLine();

View File

@@ -50,25 +50,13 @@ sealed class PrintHexCommand : Command
public PrintHexCommand() : base("print", UI.Image_Print_Command_Description) public PrintHexCommand() : base("print", UI.Image_Print_Command_Description)
{ {
Add(new Option<ulong>(new[] Add(new Option<ulong>(new[] { "--length", "-l" }, () => 1, UI.How_many_sectors_to_print));
{
"--length", "-l"
}, () => 1, UI.How_many_sectors_to_print));
Add(new Option<bool>(new[] Add(new Option<bool>(new[] { "--long-sectors", "-r" }, () => false, UI.Print_sectors_with_tags_included));
{
"--long-sectors", "-r"
}, () => false, UI.Print_sectors_with_tags_included));
Add(new Option<ulong>(new[] Add(new Option<ulong>(new[] { "--start", "-s" }, UI.Starting_sector));
{
"--start", "-s"
}, UI.Starting_sector));
Add(new Option<ushort>(new[] Add(new Option<ushort>(new[] { "--width", "-w" }, () => 32, UI.How_many_bytes_to_print_per_line));
{
"--width", "-w"
}, () => 32, UI.How_many_bytes_to_print_per_line));
AddArgument(new Argument<string> AddArgument(new Argument<string>
{ {
@@ -80,7 +68,7 @@ sealed class PrintHexCommand : Command
Handler = CommandHandler.Create(GetType().GetMethod(nameof(Invoke))); 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) ushort width)
{ {
MainClass.PrintCopyright(); MainClass.PrintCopyright();
@@ -93,41 +81,43 @@ sealed class PrintHexCommand : Command
}); });
AaruConsole.DebugWriteLineEvent += (format, objects) => AaruConsole.DebugWriteLineEvent += (format, objects) =>
{ {
if(objects is null) if(objects is null)
stderrConsole.MarkupLine(format); stderrConsole.MarkupLine(format);
else else
stderrConsole.MarkupLine(format, objects); stderrConsole.MarkupLine(format, objects);
}; };
} }
if(verbose) if(verbose)
{
AaruConsole.WriteEvent += (format, objects) => AaruConsole.WriteEvent += (format, objects) =>
{ {
if(objects is null) if(objects is null)
AnsiConsole.Markup(format); AnsiConsole.Markup(format);
else else
AnsiConsole.Markup(format, objects); AnsiConsole.Markup(format, objects);
}; };
}
Statistics.AddCommand("print-hex"); Statistics.AddCommand("print-hex");
AaruConsole.DebugWriteLine(MODULE_NAME, "--debug={0}", debug); AaruConsole.DebugWriteLine(MODULE_NAME, "--debug={0}", debug);
AaruConsole.DebugWriteLine(MODULE_NAME, "--input={0}", imagePath); AaruConsole.DebugWriteLine(MODULE_NAME, "--input={0}", imagePath);
AaruConsole.DebugWriteLine(MODULE_NAME, "--length={0}", length); AaruConsole.DebugWriteLine(MODULE_NAME, "--length={0}", length);
AaruConsole.DebugWriteLine(MODULE_NAME, "--long-sectors={0}", longSectors); AaruConsole.DebugWriteLine(MODULE_NAME, "--long-sectors={0}", longSectors);
AaruConsole.DebugWriteLine(MODULE_NAME, "--start={0}", start); AaruConsole.DebugWriteLine(MODULE_NAME, "--start={0}", start);
AaruConsole.DebugWriteLine(MODULE_NAME, "--verbose={0}", verbose); AaruConsole.DebugWriteLine(MODULE_NAME, "--verbose={0}", verbose);
AaruConsole.DebugWriteLine(MODULE_NAME, "--width={0}", width); AaruConsole.DebugWriteLine(MODULE_NAME, "--width={0}", width);
var filtersList = new FiltersList(); var filtersList = new FiltersList();
IFilter inputFilter = null; IFilter inputFilter = null;
Core.Spectre.ProgressSingleSpinner(ctx => Core.Spectre.ProgressSingleSpinner(ctx =>
{ {
ctx.AddTask(UI.Identifying_file_filter).IsIndeterminate(); ctx.AddTask(UI.Identifying_file_filter).IsIndeterminate();
inputFilter = filtersList.GetFilter(imagePath); inputFilter = filtersList.GetFilter(imagePath);
}); });
if(inputFilter == null) if(inputFilter == null)
{ {
@@ -139,10 +129,10 @@ sealed class PrintHexCommand : Command
IBaseImage inputFormat = null; IBaseImage inputFormat = null;
Core.Spectre.ProgressSingleSpinner(ctx => Core.Spectre.ProgressSingleSpinner(ctx =>
{ {
ctx.AddTask(UI.Identifying_image_format).IsIndeterminate(); ctx.AddTask(UI.Identifying_image_format).IsIndeterminate();
inputFormat = ImageFormat.Detect(inputFilter); inputFormat = ImageFormat.Detect(inputFilter);
}); });
if(inputFormat == null) if(inputFormat == null)
{ {
@@ -154,10 +144,10 @@ sealed class PrintHexCommand : Command
ErrorNumber opened = ErrorNumber.NoData; ErrorNumber opened = ErrorNumber.NoData;
Core.Spectre.ProgressSingleSpinner(ctx => Core.Spectre.ProgressSingleSpinner(ctx =>
{ {
ctx.AddTask(UI.Invoke_Opening_image_file).IsIndeterminate(); ctx.AddTask(UI.Invoke_Opening_image_file).IsIndeterminate();
opened = inputFormat.Open(inputFilter); opened = inputFormat.Open(inputFilter);
}); });
if(opened != ErrorNumber.NoError) 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)}[/][/]"); 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; ErrorNumber errno = ErrorNumber.NoError;
int bytesRead = 0; var bytesRead = 0;
Core.Spectre.ProgressSingleSpinner(ctx => 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) ?? errno = byteAddressableImage?.ReadBytesAt((long)start, data, 0,
ErrorNumber.InvalidArgument; (int)length, out bytesRead) ??
}); ErrorNumber.InvalidArgument;
});
// TODO: Span // TODO: Span
if(bytesRead != (int)length) if(bytesRead != (int)length)
{ {
byte[] tmp = new byte[bytesRead]; var tmp = new byte[bytesRead];
Array.Copy(data, 0, tmp, 0, bytesRead); Array.Copy(data, 0, tmp, 0, bytesRead);
data = tmp; data = tmp;
} }
@@ -199,6 +190,7 @@ sealed class PrintHexCommand : Command
AaruConsole.ErrorWriteLine(string.Format(UI.Error_0_reading_data_from_1, errno, start)); AaruConsole.ErrorWriteLine(string.Format(UI.Error_0_reading_data_from_1, errno, start));
} }
else else
{
for(ulong i = 0; i < length; i++) for(ulong i = 0; i < length; i++)
{ {
if(inputFormat is not IMediaImage blockImage) if(inputFormat is not IMediaImage blockImage)
@@ -231,18 +223,20 @@ sealed class PrintHexCommand : Command
ErrorNumber errno = ErrorNumber.NoError; ErrorNumber errno = ErrorNumber.NoError;
Core.Spectre.ProgressSingleSpinner(ctx => Core.Spectre.ProgressSingleSpinner(ctx =>
{ {
ctx.AddTask(UI.Reading_sector).IsIndeterminate(); ctx.AddTask(UI.Reading_sector).IsIndeterminate();
errno = longSectors ? blockImage.ReadSectorLong(start + i, out sector) errno = longSectors
: blockImage.ReadSector(start + i, out sector); ? blockImage.ReadSectorLong(start + i, out sector)
}); : blockImage.ReadSector(start + i, out sector);
});
if(errno == ErrorNumber.NoError) if(errno == ErrorNumber.NoError)
AaruConsole.WriteLine(Markup.Escape(PrintHex.ByteArrayToHexArrayString(sector, width, true))); AaruConsole.WriteLine(Markup.Escape(PrintHex.ByteArrayToHexArrayString(sector, width, true)));
else else
AaruConsole.ErrorWriteLine(string.Format(UI.Error_0_reading_sector_1, errno, start + i)); AaruConsole.ErrorWriteLine(string.Format(UI.Error_0_reading_sector_1, errno, start + i));
} }
}
return (int)ErrorNumber.NoError; return (int)ErrorNumber.NoError;
} }

View File

@@ -55,25 +55,13 @@ sealed class VerifyCommand : Command
public VerifyCommand() : base("verify", UI.Image_Verify_Command_Description) public VerifyCommand() : base("verify", UI.Image_Verify_Command_Description)
{ {
Add(new Option<bool>(new[] Add(new Option<bool>(new[] { "--verify-disc", "-w" }, () => true, UI.Verify_media_image_if_supported));
{
"--verify-disc", "-w"
}, () => true, UI.Verify_media_image_if_supported));
Add(new Option<bool>(new[] Add(new Option<bool>(new[] { "--verify-sectors", "-s" }, () => true, UI.Verify_all_sectors_if_supported));
{
"--verify-sectors", "-s"
}, () => true, UI.Verify_all_sectors_if_supported));
Add(new Option<bool>(new[] Add(new Option<bool>(new[] { "--create-graph", "-g" }, () => true, UI.Create_graph_of_verified_disc));
{
"--create-graph", "-g"
}, () => true, UI.Create_graph_of_verified_disc));
Add(new Option<uint>(new[] Add(new Option<uint>(new[] { "--dimensions" }, () => 1080, UI.Verify_dimensions_paramater_help));
{
"--dimensions"
}, () => 1080, UI.Verify_dimensions_paramater_help));
AddArgument(new Argument<string> AddArgument(new Argument<string>
{ {
@@ -85,7 +73,7 @@ sealed class VerifyCommand : Command
Handler = CommandHandler.Create(GetType().GetMethod(nameof(Invoke))); 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) bool createGraph, uint dimensions)
{ {
MainClass.PrintCopyright(); MainClass.PrintCopyright();
@@ -98,41 +86,43 @@ sealed class VerifyCommand : Command
}); });
AaruConsole.DebugWriteLineEvent += (format, objects) => AaruConsole.DebugWriteLineEvent += (format, objects) =>
{ {
if(objects is null) if(objects is null)
stderrConsole.MarkupLine(format); stderrConsole.MarkupLine(format);
else else
stderrConsole.MarkupLine(format, objects); stderrConsole.MarkupLine(format, objects);
}; };
} }
if(verbose) if(verbose)
{
AaruConsole.WriteEvent += (format, objects) => AaruConsole.WriteEvent += (format, objects) =>
{ {
if(objects is null) if(objects is null)
AnsiConsole.Markup(format); AnsiConsole.Markup(format);
else else
AnsiConsole.Markup(format, objects); AnsiConsole.Markup(format, objects);
}; };
}
Statistics.AddCommand("verify"); Statistics.AddCommand("verify");
AaruConsole.DebugWriteLine(MODULE_NAME, "--debug={0}", debug); AaruConsole.DebugWriteLine(MODULE_NAME, "--debug={0}", debug);
AaruConsole.DebugWriteLine(MODULE_NAME, "--input={0}", imagePath); AaruConsole.DebugWriteLine(MODULE_NAME, "--input={0}", imagePath);
AaruConsole.DebugWriteLine(MODULE_NAME, "--verbose={0}", verbose); AaruConsole.DebugWriteLine(MODULE_NAME, "--verbose={0}", verbose);
AaruConsole.DebugWriteLine(MODULE_NAME, "--verify-disc={0}", verifyDisc); AaruConsole.DebugWriteLine(MODULE_NAME, "--verify-disc={0}", verifyDisc);
AaruConsole.DebugWriteLine(MODULE_NAME, "--verify-sectors={0}", verifySectors); AaruConsole.DebugWriteLine(MODULE_NAME, "--verify-sectors={0}", verifySectors);
AaruConsole.DebugWriteLine(MODULE_NAME, "--create-graph={0}", createGraph); AaruConsole.DebugWriteLine(MODULE_NAME, "--create-graph={0}", createGraph);
AaruConsole.DebugWriteLine(MODULE_NAME, "--dimensions={0}", dimensions); AaruConsole.DebugWriteLine(MODULE_NAME, "--dimensions={0}", dimensions);
var filtersList = new FiltersList(); var filtersList = new FiltersList();
IFilter inputFilter = null; IFilter inputFilter = null;
Core.Spectre.ProgressSingleSpinner(ctx => Core.Spectre.ProgressSingleSpinner(ctx =>
{ {
ctx.AddTask(UI.Identifying_file_filter).IsIndeterminate(); ctx.AddTask(UI.Identifying_file_filter).IsIndeterminate();
inputFilter = filtersList.GetFilter(imagePath); inputFilter = filtersList.GetFilter(imagePath);
}); });
if(inputFilter == null) if(inputFilter == null)
{ {
@@ -144,10 +134,10 @@ sealed class VerifyCommand : Command
IBaseImage inputFormat = null; IBaseImage inputFormat = null;
Core.Spectre.ProgressSingleSpinner(ctx => Core.Spectre.ProgressSingleSpinner(ctx =>
{ {
ctx.AddTask(UI.Identifying_image_format).IsIndeterminate(); ctx.AddTask(UI.Identifying_image_format).IsIndeterminate();
inputFormat = ImageFormat.Detect(inputFilter); inputFormat = ImageFormat.Detect(inputFilter);
}); });
if(inputFormat == null) if(inputFormat == null)
{ {
@@ -159,10 +149,10 @@ sealed class VerifyCommand : Command
ErrorNumber opened = ErrorNumber.NoData; ErrorNumber opened = ErrorNumber.NoData;
Core.Spectre.ProgressSingleSpinner(ctx => Core.Spectre.ProgressSingleSpinner(ctx =>
{ {
ctx.AddTask(UI.Invoke_Opening_image_file).IsIndeterminate(); ctx.AddTask(UI.Invoke_Opening_image_file).IsIndeterminate();
opened = inputFormat.Open(inputFilter); opened = inputFormat.Open(inputFilter);
}); });
if(opened != ErrorNumber.NoError) if(opened != ErrorNumber.NoError)
{ {
@@ -197,13 +187,13 @@ sealed class VerifyCommand : Command
bool? discCheckStatus = null; bool? discCheckStatus = null;
Core.Spectre.ProgressSingleSpinner(ctx => Core.Spectre.ProgressSingleSpinner(ctx =>
{ {
ctx.AddTask(UI.Verifying_image_checksums).IsIndeterminate(); ctx.AddTask(UI.Verifying_image_checksums).IsIndeterminate();
chkWatch.Start(); chkWatch.Start();
discCheckStatus = verifiableImage.VerifyMediaImage(); discCheckStatus = verifiableImage.VerifyMediaImage();
chkWatch.Stop(); chkWatch.Stop();
}); });
switch(discCheckStatus) switch(discCheckStatus)
{ {
@@ -228,19 +218,21 @@ sealed class VerifyCommand : Command
} }
if(!verifySectors) if(!verifySectors)
{
return correctImage switch return correctImage switch
{ {
null => (int)ErrorNumber.NotVerifiable, null => (int)ErrorNumber.NotVerifiable,
false => (int)ErrorNumber.BadImageSectorsNotVerified, false => (int)ErrorNumber.BadImageSectorsNotVerified,
true => (int)ErrorNumber.CorrectImageSectorsNotVerified true => (int)ErrorNumber.CorrectImageSectorsNotVerified
}; };
}
var stopwatch = new Stopwatch(); var stopwatch = new Stopwatch();
List<ulong> failingLbas = new(); List<ulong> failingLbas = new();
List<ulong> unknownLbas = new(); List<ulong> unknownLbas = new();
IMediaGraph mediaGraph = null; IMediaGraph mediaGraph = null;
if(verifiableSectorsImage is IOpticalMediaImage { Tracks: {} } opticalMediaImage) if(verifiableSectorsImage is IOpticalMediaImage { Tracks: not null } opticalMediaImage)
{ {
Spiral.DiscParameters spiralParameters = null; Spiral.DiscParameters spiralParameters = null;
@@ -248,8 +240,10 @@ sealed class VerifyCommand : Command
spiralParameters = Spiral.DiscParametersFromMediaType(opticalMediaImage.Info.MediaType); spiralParameters = Spiral.DiscParametersFromMediaType(opticalMediaImage.Info.MediaType);
if(spiralParameters is not null) if(spiralParameters is not null)
{
mediaGraph = new Spiral((int)dimensions, (int)dimensions, spiralParameters, mediaGraph = new Spiral((int)dimensions, (int)dimensions, spiralParameters,
opticalMediaImage.Info.Sectors); opticalMediaImage.Info.Sectors);
}
else if(createGraph) else if(createGraph)
mediaGraph = new BlockMap((int)dimensions, (int)dimensions, opticalMediaImage.Info.Sectors); mediaGraph = new BlockMap((int)dimensions, (int)dimensions, opticalMediaImage.Info.Sectors);
@@ -261,88 +255,96 @@ sealed class VerifyCommand : Command
AnsiConsole.Progress().AutoClear(true).HideCompleted(true). AnsiConsole.Progress().AutoClear(true).HideCompleted(true).
Columns(new TaskDescriptionColumn(), new ProgressBarColumn(), new PercentageColumn()). Columns(new TaskDescriptionColumn(), new ProgressBarColumn(), new PercentageColumn()).
Start(ctx => Start(ctx =>
{ {
ProgressTask discTask = ctx.AddTask(UI.Checking_tracks); ProgressTask discTask = ctx.AddTask(UI.Checking_tracks);
discTask.MaxValue = inputTracks.Count; discTask.MaxValue = inputTracks.Count;
foreach(Track currentTrack in inputTracks) foreach(Track currentTrack in inputTracks)
{ {
discTask.Description = discTask.Description =
string.Format(UI.Checking_track_0_of_1, discTask.Value + 1, inputTracks.Count); 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); ProgressTask trackTask = ctx.AddTask(UI.Checking_sector);
trackTask.MaxValue = remainingSectors; trackTask.MaxValue = remainingSectors;
while(remainingSectors > 0) while(remainingSectors > 0)
{ {
trackTask.Description = trackTask.Description =
string.Format(UI.Checking_sector_0_of_1_on_track_2, currentSectorAll, string.Format(UI.Checking_sector_0_of_1_on_track_2, currentSectorAll,
inputFormat.Info.Sectors, currentTrack.Sequence); inputFormat.Info.Sectors, currentTrack.Sequence);
List<ulong> tempFailingLbas; List<ulong> tempFailingLbas;
List<ulong> tempUnknownLbas; List<ulong> tempUnknownLbas;
if(remainingSectors < 512) if(remainingSectors < 512)
opticalMediaImage.VerifySectors(currentSector, (uint)remainingSectors, {
currentTrack.Sequence, out tempFailingLbas, opticalMediaImage.VerifySectors(currentSector, (uint)remainingSectors,
out tempUnknownLbas); currentTrack.Sequence,
else out tempFailingLbas,
opticalMediaImage.VerifySectors(currentSector, 512, currentTrack.Sequence, out tempUnknownLbas);
out tempFailingLbas, out tempUnknownLbas); }
else
{
opticalMediaImage.VerifySectors(currentSector, 512, currentTrack.Sequence,
out tempFailingLbas, out tempUnknownLbas);
}
if(mediaGraph != null) if(mediaGraph != null)
{ {
List<ulong> tempCorrectLbas = new(); List<ulong> tempCorrectLbas = new();
for(ulong l = 0; l < (remainingSectors < 512 ? remainingSectors : 512); l++) for(ulong l = 0;
tempCorrectLbas.Add(currentSector + l); l < (remainingSectors < 512 ? remainingSectors : 512);
l++)
tempCorrectLbas.Add(currentSector + l);
foreach(ulong f in tempFailingLbas) foreach(ulong f in tempFailingLbas)
tempCorrectLbas.Remove(f); tempCorrectLbas.Remove(f);
foreach(ulong u in tempUnknownLbas) foreach(ulong u in tempUnknownLbas)
{ {
tempCorrectLbas.Remove(u); tempCorrectLbas.Remove(u);
mediaGraph.PaintSectorUnknown(currentTrack.StartSector + u); mediaGraph.PaintSectorUnknown(currentTrack.StartSector + u);
} }
foreach(ulong lba in tempCorrectLbas) foreach(ulong lba in tempCorrectLbas)
mediaGraph.PaintSectorGood(currentTrack.StartSector + lba); mediaGraph.PaintSectorGood(currentTrack.StartSector + lba);
foreach(ulong f in tempFailingLbas) foreach(ulong f in tempFailingLbas)
mediaGraph.PaintSectorBad(currentTrack.StartSector + f); mediaGraph.PaintSectorBad(currentTrack.StartSector + f);
} }
failingLbas.AddRange(tempFailingLbas); failingLbas.AddRange(tempFailingLbas);
unknownLbas.AddRange(tempUnknownLbas); unknownLbas.AddRange(tempUnknownLbas);
if(remainingSectors < 512) if(remainingSectors < 512)
{ {
currentSector += remainingSectors; currentSector += remainingSectors;
currentSectorAll += remainingSectors; currentSectorAll += remainingSectors;
trackTask.Value += remainingSectors; trackTask.Value += remainingSectors;
remainingSectors = 0; remainingSectors = 0;
} }
else else
{ {
currentSector += 512; currentSector += 512;
currentSectorAll += 512; currentSectorAll += 512;
trackTask.Value += 512; trackTask.Value += 512;
remainingSectors -= 512; remainingSectors -= 512;
} }
} }
trackTask.StopTask(); trackTask.StopTask();
discTask.Increment(1); discTask.Increment(1);
} }
stopwatch.Stop(); stopwatch.Stop();
}); });
} }
else if(verifiableSectorsImage != null) else if(verifiableSectorsImage != null)
{ {
@@ -352,65 +354,71 @@ sealed class VerifyCommand : Command
AnsiConsole.Progress().AutoClear(true).HideCompleted(true). AnsiConsole.Progress().AutoClear(true).HideCompleted(true).
Columns(new TaskDescriptionColumn(), new ProgressBarColumn(), new PercentageColumn()). Columns(new TaskDescriptionColumn(), new ProgressBarColumn(), new PercentageColumn()).
Start(ctx => Start(ctx =>
{ {
ProgressTask diskTask = ctx.AddTask(UI.Checking_sectors); ProgressTask diskTask = ctx.AddTask(UI.Checking_sectors);
diskTask.MaxValue = inputFormat.Info.Sectors; diskTask.MaxValue = inputFormat.Info.Sectors;
stopwatch.Restart(); stopwatch.Restart();
while(remainingSectors > 0) while(remainingSectors > 0)
{ {
diskTask.Description = diskTask.Description =
string.Format(UI.Checking_sector_0_of_1, currentSector, inputFormat.Info.Sectors); string.Format(UI.Checking_sector_0_of_1, currentSector,
inputFormat.Info.Sectors);
List<ulong> tempFailingLbas; List<ulong> tempFailingLbas;
List<ulong> tempUnknownLbas; List<ulong> tempUnknownLbas;
if(remainingSectors < 512) if(remainingSectors < 512)
verifiableSectorsImage.VerifySectors(currentSector, (uint)remainingSectors, {
out tempFailingLbas, out tempUnknownLbas); verifiableSectorsImage.VerifySectors(currentSector, (uint)remainingSectors,
else out tempFailingLbas,
verifiableSectorsImage.VerifySectors(currentSector, 512, out tempFailingLbas, out tempUnknownLbas);
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) if(mediaGraph != null)
{ {
List<ulong> tempCorrectLbas = new(); List<ulong> tempCorrectLbas = new();
for(ulong l = 0; l < (remainingSectors < 512 ? remainingSectors : 512); l++) for(ulong l = 0; l < (remainingSectors < 512 ? remainingSectors : 512); l++)
tempCorrectLbas.Add(currentSector + l); tempCorrectLbas.Add(currentSector + l);
foreach(ulong f in tempFailingLbas) foreach(ulong f in tempFailingLbas)
tempCorrectLbas.Remove(f); tempCorrectLbas.Remove(f);
foreach(ulong u in tempUnknownLbas) foreach(ulong u in tempUnknownLbas)
tempCorrectLbas.Remove(u); tempCorrectLbas.Remove(u);
mediaGraph.PaintSectorsUnknown(tempUnknownLbas); mediaGraph.PaintSectorsUnknown(tempUnknownLbas);
mediaGraph.PaintSectorsGood(tempCorrectLbas); mediaGraph.PaintSectorsGood(tempCorrectLbas);
mediaGraph.PaintSectorsBad(tempFailingLbas); mediaGraph.PaintSectorsBad(tempFailingLbas);
} }
if(remainingSectors < 512) if(remainingSectors < 512)
{ {
currentSector += remainingSectors; currentSector += remainingSectors;
diskTask.Value += remainingSectors; diskTask.Value += remainingSectors;
remainingSectors = 0; remainingSectors = 0;
} }
else else
{ {
currentSector += 512; currentSector += 512;
diskTask.Value += 512; diskTask.Value += 512;
remainingSectors -= 512; remainingSectors -= 512;
} }
} }
stopwatch.Stop(); stopwatch.Stop();
}); });
} }
if(unknownLbas.Count > 0) if(unknownLbas.Count > 0)
@@ -433,16 +441,20 @@ sealed class VerifyCommand : Command
if(failingLbas.Count == (int)inputFormat.Info.Sectors) if(failingLbas.Count == (int)inputFormat.Info.Sectors)
AaruConsole.VerboseWriteLine($"\t[red]{UI.all_sectors}[/]"); AaruConsole.VerboseWriteLine($"\t[red]{UI.all_sectors}[/]");
else else
{
foreach(ulong t in failingLbas) foreach(ulong t in failingLbas)
AaruConsole.VerboseWriteLine("\t{0}", t); AaruConsole.VerboseWriteLine("\t{0}", t);
}
AaruConsole.WriteLine($"[yellow3_1]{UI.LBAs_without_checksum}[/]"); AaruConsole.WriteLine($"[yellow3_1]{UI.LBAs_without_checksum}[/]");
if(unknownLbas.Count == (int)inputFormat.Info.Sectors) if(unknownLbas.Count == (int)inputFormat.Info.Sectors)
AaruConsole.VerboseWriteLine($"\t[yellow3_1]{UI.all_sectors}[/]"); AaruConsole.VerboseWriteLine($"\t[yellow3_1]{UI.all_sectors}[/]");
else else
{
foreach(ulong t in unknownLbas) foreach(ulong t in unknownLbas)
AaruConsole.VerboseWriteLine("\t{0}", t); AaruConsole.VerboseWriteLine("\t{0}", t);
}
} }
// TODO: Convert to table // TODO: Convert to table
@@ -459,16 +471,16 @@ sealed class VerifyCommand : Command
correctSectors = true; correctSectors = true;
return correctImage switch return correctImage switch
{ {
null when correctSectors is null => (int)ErrorNumber.NotVerifiable, null when correctSectors is null => (int)ErrorNumber.NotVerifiable,
null when correctSectors == false => (int)ErrorNumber.BadSectorsImageNotVerified, null when correctSectors == false => (int)ErrorNumber.BadSectorsImageNotVerified,
null => (int)ErrorNumber.CorrectSectorsImageNotVerified, null => (int)ErrorNumber.CorrectSectorsImageNotVerified,
false when correctSectors is null => (int)ErrorNumber.BadImageSectorsNotVerified, false when correctSectors is null => (int)ErrorNumber.BadImageSectorsNotVerified,
false when correctSectors == false => (int)ErrorNumber.BadImageBadSectors, false when correctSectors == false => (int)ErrorNumber.BadImageBadSectors,
false => (int)ErrorNumber.CorrectSectorsBadImage, false => (int)ErrorNumber.CorrectSectorsBadImage,
true when correctSectors is null => (int)ErrorNumber.CorrectImageSectorsNotVerified, true when correctSectors is null => (int)ErrorNumber.CorrectImageSectorsNotVerified,
true when correctSectors == false => (int)ErrorNumber.CorrectImageBadSectors, true when correctSectors == false => (int)ErrorNumber.CorrectImageBadSectors,
true => (int)ErrorNumber.NoError true => (int)ErrorNumber.NoError
}; };
} }
} }

View File

@@ -30,7 +30,6 @@
// Copyright © 2011-2023 Natalia Portillo // Copyright © 2011-2023 Natalia Portillo
// ****************************************************************************/ // ****************************************************************************/
using System.Collections.Generic;
using System.CommandLine; using System.CommandLine;
using System.CommandLine.NamingConventionBinder; using System.CommandLine.NamingConventionBinder;
using System.Linq; using System.Linq;
@@ -62,29 +61,31 @@ sealed class ListEncodingsCommand : Command
}); });
AaruConsole.DebugWriteLineEvent += (format, objects) => AaruConsole.DebugWriteLineEvent += (format, objects) =>
{ {
if(objects is null) if(objects is null)
stderrConsole.MarkupLine(format); stderrConsole.MarkupLine(format);
else else
stderrConsole.MarkupLine(format, objects); stderrConsole.MarkupLine(format, objects);
}; };
} }
if(verbose) if(verbose)
{
AaruConsole.WriteEvent += (format, objects) => AaruConsole.WriteEvent += (format, objects) =>
{ {
if(objects is null) if(objects is null)
AnsiConsole.Markup(format); AnsiConsole.Markup(format);
else else
AnsiConsole.Markup(format, objects); AnsiConsole.Markup(format, objects);
}; };
}
Statistics.AddCommand("list-encodings"); 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); AaruConsole.DebugWriteLine(MODULE_NAME, "--verbose={0}", verbose);
List<CommonEncodingInfo> encodings = Encoding.GetEncodings().Select(info => new CommonEncodingInfo var encodings = Encoding.GetEncodings().Select(info => new CommonEncodingInfo
{ {
Name = info.Name, Name = info.Name,
DisplayName = info.GetEncoding().EncodingName DisplayName = info.GetEncoding().EncodingName
@@ -108,9 +109,13 @@ sealed class ListEncodingsCommand : Command
return (int)ErrorNumber.NoError; return (int)ErrorNumber.NoError;
} }
#region Nested type: CommonEncodingInfo
struct CommonEncodingInfo struct CommonEncodingInfo
{ {
public string Name; public string Name;
public string DisplayName; public string DisplayName;
} }
#endregion
} }

View File

@@ -63,24 +63,26 @@ sealed class ListNamespacesCommand : Command
}); });
AaruConsole.DebugWriteLineEvent += (format, objects) => AaruConsole.DebugWriteLineEvent += (format, objects) =>
{ {
if(objects is null) if(objects is null)
stderrConsole.MarkupLine(format); stderrConsole.MarkupLine(format);
else else
stderrConsole.MarkupLine(format, objects); stderrConsole.MarkupLine(format, objects);
}; };
} }
if(verbose) if(verbose)
{
AaruConsole.WriteEvent += (format, objects) => AaruConsole.WriteEvent += (format, objects) =>
{ {
if(objects is null) if(objects is null)
AnsiConsole.Markup(format); AnsiConsole.Markup(format);
else else
AnsiConsole.Markup(format, objects); 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); AaruConsole.DebugWriteLine(MODULE_NAME, "--verbose={0}", verbose);
Statistics.AddCommand("list-namespaces"); Statistics.AddCommand("list-namespaces");

View File

@@ -71,60 +71,37 @@ sealed class DumpMediaCommand : Command
public DumpMediaCommand() : base("dump", UI.Media_Dump_Command_Description) public DumpMediaCommand() : base("dump", UI.Media_Dump_Command_Description)
{ {
Add(new Option<string>(new[] Add(new Option<string>(new[] { "--cicm-xml", "-x" }, () => null,
{ UI.Take_metadata_from_existing_CICM_XML_sidecar));
"--cicm-xml", "-x"
}, () => null, UI.Take_metadata_from_existing_CICM_XML_sidecar));
Add(new Option<string>(new[] Add(new Option<string>(new[] { "--encoding", "-e" }, () => null, UI.Name_of_character_encoding_to_use));
{
"--encoding", "-e"
}, () => null, UI.Name_of_character_encoding_to_use));
Add(new Option<bool>("--first-pregap", () => false, UI.Try_to_read_first_track_pregap)); Add(new Option<bool>("--first-pregap", () => false, UI.Try_to_read_first_track_pregap));
Add(new Option<bool>("--fix-offset", () => true, UI.Fix_audio_tracks_offset)); Add(new Option<bool>("--fix-offset", () => true, UI.Fix_audio_tracks_offset));
Add(new Option<bool>(new[] Add(new Option<bool>(new[] { "--force", "-f" }, () => false, UI.Continue_dumping_whatever_happens));
{
"--force", "-f"
}, () => false, UI.Continue_dumping_whatever_happens));
Add(new Option<string>(new[] Add(new Option<string>(new[] { "--format", "-t" }, () => null,
{ UI.Format_of_the_output_image_as_plugin_name_or_plugin_id));
"--format", "-t"
}, () => null, UI.Format_of_the_output_image_as_plugin_name_or_plugin_id));
Add(new Option<bool>("--metadata", () => true, UI.Enables_creating_Aaru_Metadata_sidecar)); Add(new Option<bool>("--metadata", () => true, UI.Enables_creating_Aaru_Metadata_sidecar));
Add(new Option<bool>("--trim", () => true, UI.Enables_trimming_errored_from_skipped_sectors)); Add(new Option<bool>("--trim", () => true, UI.Enables_trimming_errored_from_skipped_sectors));
Add(new Option<string>(new[] Add(new Option<string>(new[] { "--options", "-O" }, () => null,
{ UI.Comma_separated_name_value_pairs_of_image_options));
"--options", "-O"
}, () => null, UI.Comma_separated_name_value_pairs_of_image_options));
Add(new Option<bool>("--persistent", () => false, UI.Try_to_recover_partial_or_incorrect_data)); Add(new Option<bool>("--persistent", () => false, UI.Try_to_recover_partial_or_incorrect_data));
Add(new Option<bool>(new[] Add(new Option<bool>(new[] { "--resume", "-r" }, () => true, UI.Create_or_use_resume_mapfile));
{
"--resume", "-r"
}, () => true, UI.Create_or_use_resume_mapfile));
Add(new Option<ushort>(new[] Add(new Option<ushort>(new[] { "--retry-passes", "-p" }, () => 5, UI.How_many_retry_passes_to_do));
{
"--retry-passes", "-p"
}, () => 5, UI.How_many_retry_passes_to_do));
Add(new Option<uint>(new[] Add(new Option<uint>(new[] { "--skip", "-k" }, () => 512,
{ UI.When_an_unreadable_sector_is_found_skip_this_many_sectors));
"--skip", "-k"
}, () => 512, UI.When_an_unreadable_sector_is_found_skip_this_many_sectors));
Add(new Option<bool>(new[] Add(new Option<bool>(new[] { "--stop-on-error", "-s" }, () => false, UI.Stop_media_dump_on_first_error));
{
"--stop-on-error", "-s"
}, () => false, UI.Stop_media_dump_on_first_error));
Add(new Option<string>("--subchannel", () => UI.Subchannel_name_any, UI.Subchannel_to_dump_help)); Add(new Option<string>("--subchannel", () => UI.Subchannel_name_any, UI.Subchannel_to_dump_help));
@@ -144,85 +121,40 @@ sealed class DumpMediaCommand : Command
Name = "output-path" Name = "output-path"
}); });
Add(new Option<bool>(new[] Add(new Option<bool>(new[] { "--private" }, () => false,
{ UI.Do_not_store_paths_and_serial_numbers_in_log_or_metadata));
"--private"
}, () => false, UI.Do_not_store_paths_and_serial_numbers_in_log_or_metadata));
Add(new Option<bool>(new[] Add(new Option<bool>(new[] { "--fix-subchannel-position" }, () => true, UI.Fix_subchannel_position_help));
{
"--fix-subchannel-position"
}, () => true, UI.Fix_subchannel_position_help));
Add(new Option<bool>(new[] Add(new Option<bool>(new[] { "--retry-subchannel" }, () => true, UI.Retry_subchannel_help));
{
"--retry-subchannel"
}, () => true, UI.Retry_subchannel_help));
Add(new Option<bool>(new[] Add(new Option<bool>(new[] { "--fix-subchannel" }, () => false, UI.Fix_subchannel_help));
{
"--fix-subchannel"
}, () => false, UI.Fix_subchannel_help));
Add(new Option<bool>(new[] Add(new Option<bool>(new[] { "--fix-subchannel-crc" }, () => false, UI.Fix_subchannel_crc_help));
{
"--fix-subchannel-crc"
}, () => false, UI.Fix_subchannel_crc_help));
Add(new Option<bool>(new[] Add(new Option<bool>(new[] { "--generate-subchannels" }, () => false, UI.Generate_subchannels_dump_help));
{
"--generate-subchannels"
}, () => false, UI.Generate_subchannels_dump_help));
Add(new Option<bool>(new[] Add(new Option<bool>(new[] { "--skip-cdiready-hole" }, () => true, UI.Skip_CDi_Ready_hole_help));
{
"--skip-cdiready-hole"
}, () => true, UI.Skip_CDi_Ready_hole_help));
Add(new Option<bool>(new[] Add(new Option<bool>(new[] { "--eject" }, () => false, UI.Eject_media_after_dump_finishes));
{
"--eject"
}, () => false, UI.Eject_media_after_dump_finishes));
Add(new Option<uint>(new[] Add(new Option<uint>(new[] { "--max-blocks" }, () => 64, UI.Maximum_number_of_blocks_to_read_at_once));
{
"--max-blocks"
}, () => 64, UI.Maximum_number_of_blocks_to_read_at_once));
Add(new Option<bool>(new[] Add(new Option<bool>(new[] { "--use-buffered-reads" }, () => true, UI.OS_buffered_reads_help));
{
"--use-buffered-reads"
}, () => true, UI.OS_buffered_reads_help));
Add(new Option<bool>(new[] Add(new Option<bool>(new[] { "--store-encrypted" }, () => true, UI.Store_encrypted_data_as_is));
{
"--store-encrypted"
}, () => true, UI.Store_encrypted_data_as_is));
Add(new Option<bool>(new[] Add(new Option<bool>(new[] { "--title-keys" }, () => true, UI.Try_to_read_the_title_keys_from_CSS_DVDs));
{
"--title-keys"
}, () => true, UI.Try_to_read_the_title_keys_from_CSS_DVDs));
Add(new Option<uint>(new[] Add(new Option<uint>(new[] { "--ignore-cdr-runouts" }, () => 10,
{ UI.How_many_CDRW_run_out_sectors_to_ignore_and_regenerate));
"--ignore-cdr-runouts"
}, () => 10, UI.How_many_CDRW_run_out_sectors_to_ignore_and_regenerate));
Add(new Option<bool>(new[] Add(new Option<bool>(new[] { "--create-graph", "-g" }, () => true, UI.Create_graph_of_dumped_media));
{
"--create-graph", "-g"
}, () => true, UI.Create_graph_of_dumped_media));
Add(new Option<uint>(new[] Add(new Option<uint>(new[] { "--dimensions" }, () => 1080, UI.Dump_graph_dimensions_argument_help));
{
"--dimensions"
}, () => 1080, UI.Dump_graph_dimensions_argument_help));
Add(new Option<string>(new[] Add(new Option<string>(new[] { "--aaru-metadata", "-m" }, () => null,
{ "Take metadata from existing Aaru Metadata sidecar."));
"--aaru-metadata", "-m"
}, () => null, "Take metadata from existing Aaru Metadata sidecar."));
Handler = CommandHandler.Create(GetType().GetMethod(nameof(Invoke))); Handler = CommandHandler.Create(GetType().GetMethod(nameof(Invoke)));
} }
@@ -246,22 +178,24 @@ sealed class DumpMediaCommand : Command
}); });
AaruConsole.DebugWriteLineEvent += (format, objects) => AaruConsole.DebugWriteLineEvent += (format, objects) =>
{ {
if(objects is null) if(objects is null)
stderrConsole.MarkupLine(format); stderrConsole.MarkupLine(format);
else else
stderrConsole.MarkupLine(format, objects); stderrConsole.MarkupLine(format, objects);
}; };
} }
if(verbose) if(verbose)
{
AaruConsole.WriteEvent += (format, objects) => AaruConsole.WriteEvent += (format, objects) =>
{ {
if(objects is null) if(objects is null)
AnsiConsole.Markup(format); AnsiConsole.Markup(format);
else else
AnsiConsole.Markup(format, objects); AnsiConsole.Markup(format, objects);
}; };
}
fixSubchannel |= fixSubchannelCrc; fixSubchannel |= fixSubchannelCrc;
fixSubchannelPosition |= retrySubchannel || fixSubchannel; fixSubchannelPosition |= retrySubchannel || fixSubchannel;
@@ -271,41 +205,41 @@ sealed class DumpMediaCommand : Command
Statistics.AddCommand("dump-media"); Statistics.AddCommand("dump-media");
AaruConsole.DebugWriteLine(MODULE_NAME, "--cicm-xml={0}", cicmXml); AaruConsole.DebugWriteLine(MODULE_NAME, "--cicm-xml={0}", cicmXml);
AaruConsole.DebugWriteLine(MODULE_NAME, "--debug={0}", debug); AaruConsole.DebugWriteLine(MODULE_NAME, "--debug={0}", debug);
AaruConsole.DebugWriteLine(MODULE_NAME, "--device={0}", devicePath); AaruConsole.DebugWriteLine(MODULE_NAME, "--device={0}", devicePath);
AaruConsole.DebugWriteLine(MODULE_NAME, "--encoding={0}", encoding); AaruConsole.DebugWriteLine(MODULE_NAME, "--encoding={0}", encoding);
AaruConsole.DebugWriteLine(MODULE_NAME, "--first-pregap={0}", firstPregap); AaruConsole.DebugWriteLine(MODULE_NAME, "--first-pregap={0}", firstPregap);
AaruConsole.DebugWriteLine(MODULE_NAME, "--fix-offset={0}", fixOffset); AaruConsole.DebugWriteLine(MODULE_NAME, "--fix-offset={0}", fixOffset);
AaruConsole.DebugWriteLine(MODULE_NAME, "--force={0}", force); AaruConsole.DebugWriteLine(MODULE_NAME, "--force={0}", force);
AaruConsole.DebugWriteLine(MODULE_NAME, "--format={0}", format); AaruConsole.DebugWriteLine(MODULE_NAME, "--format={0}", format);
AaruConsole.DebugWriteLine(MODULE_NAME, "--metadata={0}", metadata); AaruConsole.DebugWriteLine(MODULE_NAME, "--metadata={0}", metadata);
AaruConsole.DebugWriteLine(MODULE_NAME, "--options={0}", options); AaruConsole.DebugWriteLine(MODULE_NAME, "--options={0}", options);
AaruConsole.DebugWriteLine(MODULE_NAME, "--output={0}", outputPath); AaruConsole.DebugWriteLine(MODULE_NAME, "--output={0}", outputPath);
AaruConsole.DebugWriteLine(MODULE_NAME, "--persistent={0}", persistent); AaruConsole.DebugWriteLine(MODULE_NAME, "--persistent={0}", persistent);
AaruConsole.DebugWriteLine(MODULE_NAME, "--resume={0}", resume); AaruConsole.DebugWriteLine(MODULE_NAME, "--resume={0}", resume);
AaruConsole.DebugWriteLine(MODULE_NAME, "--retry-passes={0}", retryPasses); AaruConsole.DebugWriteLine(MODULE_NAME, "--retry-passes={0}", retryPasses);
AaruConsole.DebugWriteLine(MODULE_NAME, "--skip={0}", skip); AaruConsole.DebugWriteLine(MODULE_NAME, "--skip={0}", skip);
AaruConsole.DebugWriteLine(MODULE_NAME, "--stop-on-error={0}", stopOnError); AaruConsole.DebugWriteLine(MODULE_NAME, "--stop-on-error={0}", stopOnError);
AaruConsole.DebugWriteLine(MODULE_NAME, "--trim={0}", trim); AaruConsole.DebugWriteLine(MODULE_NAME, "--trim={0}", trim);
AaruConsole.DebugWriteLine(MODULE_NAME, "--verbose={0}", verbose); AaruConsole.DebugWriteLine(MODULE_NAME, "--verbose={0}", verbose);
AaruConsole.DebugWriteLine(MODULE_NAME, "--subchannel={0}", subchannel); AaruConsole.DebugWriteLine(MODULE_NAME, "--subchannel={0}", subchannel);
AaruConsole.DebugWriteLine(MODULE_NAME, "--private={0}", @private); AaruConsole.DebugWriteLine(MODULE_NAME, "--private={0}", @private);
AaruConsole.DebugWriteLine(MODULE_NAME, "--fix-subchannel-position={0}", fixSubchannelPosition); AaruConsole.DebugWriteLine(MODULE_NAME, "--fix-subchannel-position={0}", fixSubchannelPosition);
AaruConsole.DebugWriteLine(MODULE_NAME, "--retry-subchannel={0}", retrySubchannel); AaruConsole.DebugWriteLine(MODULE_NAME, "--retry-subchannel={0}", retrySubchannel);
AaruConsole.DebugWriteLine(MODULE_NAME, "--fix-subchannel={0}", fixSubchannel); AaruConsole.DebugWriteLine(MODULE_NAME, "--fix-subchannel={0}", fixSubchannel);
AaruConsole.DebugWriteLine(MODULE_NAME, "--fix-subchannel-crc={0}", fixSubchannelCrc); AaruConsole.DebugWriteLine(MODULE_NAME, "--fix-subchannel-crc={0}", fixSubchannelCrc);
AaruConsole.DebugWriteLine(MODULE_NAME, "--generate-subchannels={0}", generateSubchannels); AaruConsole.DebugWriteLine(MODULE_NAME, "--generate-subchannels={0}", generateSubchannels);
AaruConsole.DebugWriteLine(MODULE_NAME, "--skip-cdiready-hole={0}", skipCdiReadyHole); AaruConsole.DebugWriteLine(MODULE_NAME, "--skip-cdiready-hole={0}", skipCdiReadyHole);
AaruConsole.DebugWriteLine(MODULE_NAME, "--eject={0}", eject); AaruConsole.DebugWriteLine(MODULE_NAME, "--eject={0}", eject);
AaruConsole.DebugWriteLine(MODULE_NAME, "--max-blocks={0}", maxBlocks); AaruConsole.DebugWriteLine(MODULE_NAME, "--max-blocks={0}", maxBlocks);
AaruConsole.DebugWriteLine(MODULE_NAME, "--use-buffered-reads={0}", useBufferedReads); AaruConsole.DebugWriteLine(MODULE_NAME, "--use-buffered-reads={0}", useBufferedReads);
AaruConsole.DebugWriteLine(MODULE_NAME, "--store-encrypted={0}", storeEncrypted); AaruConsole.DebugWriteLine(MODULE_NAME, "--store-encrypted={0}", storeEncrypted);
AaruConsole.DebugWriteLine(MODULE_NAME, "--title-keys={0}", titleKeys); AaruConsole.DebugWriteLine(MODULE_NAME, "--title-keys={0}", titleKeys);
AaruConsole.DebugWriteLine(MODULE_NAME, "--ignore-cdr-runouts={0}", ignoreCdrRunOuts); AaruConsole.DebugWriteLine(MODULE_NAME, "--ignore-cdr-runouts={0}", ignoreCdrRunOuts);
AaruConsole.DebugWriteLine(MODULE_NAME, "--create-graph={0}", createGraph); AaruConsole.DebugWriteLine(MODULE_NAME, "--create-graph={0}", createGraph);
AaruConsole.DebugWriteLine(MODULE_NAME, "--dimensions={0}", dimensions); AaruConsole.DebugWriteLine(MODULE_NAME, "--dimensions={0}", dimensions);
AaruConsole.DebugWriteLine(MODULE_NAME, "--aaru-metadata={0}", aaruMetadata); AaruConsole.DebugWriteLine(MODULE_NAME, "--aaru-metadata={0}", aaruMetadata);
// TODO: Disabled temporarily // TODO: Disabled temporarily
//AaruConsole.DebugWriteLine(MODULE_NAME, "--raw={0}", raw); //AaruConsole.DebugWriteLine(MODULE_NAME, "--raw={0}", raw);
@@ -319,6 +253,7 @@ sealed class DumpMediaCommand : Command
Encoding encodingClass = null; Encoding encodingClass = null;
if(encoding != null) if(encoding != null)
{
try try
{ {
encodingClass = Claunia.Encoding.Encoding.GetEncoding(encoding); encodingClass = Claunia.Encoding.Encoding.GetEncoding(encoding);
@@ -332,6 +267,7 @@ sealed class DumpMediaCommand : Command
return (int)ErrorNumber.EncodingUnknown; return (int)ErrorNumber.EncodingUnknown;
} }
}
DumpSubchannel wantedSubchannel = DumpSubchannel.Any; DumpSubchannel wantedSubchannel = DumpSubchannel.Any;
@@ -358,8 +294,10 @@ sealed class DumpMediaCommand : Command
TextReader resReader; TextReader resReader;
if(isResponse) if(isResponse)
{
resReader = new StreamReader(Path.Combine(Path.GetDirectoryName(outputPath), resReader = new StreamReader(Path.Combine(Path.GetDirectoryName(outputPath),
Path.GetFileNameWithoutExtension(outputPath))); Path.GetFileNameWithoutExtension(outputPath)));
}
else else
resReader = new StringReader(Path.GetFileNameWithoutExtension(outputPath)); resReader = new StringReader(Path.GetFileNameWithoutExtension(outputPath));
@@ -372,24 +310,36 @@ sealed class DumpMediaCommand : Command
// Try extension // Try extension
if(string.IsNullOrEmpty(format)) if(string.IsNullOrEmpty(format))
{
candidates.AddRange(from pluginType in plugins.WritableImages.Values candidates.AddRange(from pluginType in plugins.WritableImages.Values
select Activator.CreateInstance(pluginType) as IBaseWritableImage into plugin select Activator.CreateInstance(pluginType) as IBaseWritableImage
where plugin is not null where plugin.KnownExtensions.Contains(extension) into plugin
where plugin is not null
where plugin.KnownExtensions.Contains(extension)
select plugin); select plugin);
}
// Try Id // Try Id
else if(Guid.TryParse(format, out Guid outId)) else if(Guid.TryParse(format, out Guid outId))
{
candidates.AddRange(from pluginType in plugins.WritableImages.Values candidates.AddRange(from pluginType in plugins.WritableImages.Values
select Activator.CreateInstance(pluginType) as IBaseWritableImage into plugin select Activator.CreateInstance(pluginType) as IBaseWritableImage
where plugin is not null where plugin.Id.Equals(outId) select plugin); into plugin
where plugin is not null
where plugin.Id.Equals(outId)
select plugin);
}
// Try name // Try name
else else
{
candidates.AddRange(from pluginType in plugins.WritableImages.Values 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 is not null
where plugin.Name.Equals(format, StringComparison.InvariantCultureIgnoreCase) where plugin.Name.Equals(format, StringComparison.InvariantCultureIgnoreCase)
select plugin); select plugin);
}
switch(candidates.Count) 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. // Replace Windows forbidden filename characters with Japanese equivalents that are visually the same, but bigger.
if(DetectOS.IsWindows) if(DetectOS.IsWindows)
{
responseLine = responseLine.Replace('<', '\uFF1C').Replace('>', '\uFF1E').Replace(':', '\uFF1A'). responseLine = responseLine.Replace('<', '\uFF1C').Replace('>', '\uFF1E').Replace(':', '\uFF1A').
Replace('"', '\u2033').Replace('\\', '').Replace('|', ''). Replace('"', '\u2033').Replace('\\', '').Replace('|', '').
Replace('?', '').Replace('*', ''); Replace('?', '').Replace('*', '');
}
if(devicePath.Length == 2 && if(devicePath.Length == 2 &&
devicePath[1] == ':' && devicePath[1] == ':' &&
@@ -443,10 +395,10 @@ sealed class DumpMediaCommand : Command
ErrorNumber devErrno = ErrorNumber.NoError; ErrorNumber devErrno = ErrorNumber.NoError;
Core.Spectre.ProgressSingleSpinner(ctx => Core.Spectre.ProgressSingleSpinner(ctx =>
{ {
ctx.AddTask(UI.Opening_device).IsIndeterminate(); ctx.AddTask(UI.Opening_device).IsIndeterminate();
dev = Devices.Device.Create(devicePath, out devErrno); dev = Devices.Device.Create(devicePath, out devErrno);
}); });
switch(dev) switch(dev)
{ {
@@ -502,16 +454,16 @@ sealed class DumpMediaCommand : Command
else if(File.Exists(outputPrefix + ".resume.xml") && resume) else if(File.Exists(outputPrefix + ".resume.xml") && resume)
{ {
// Should be covered by virtue of being the same exact class as the JSON above // 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)); var xs = new XmlSerializer(typeof(Resume));
#pragma warning restore IL2026 #pragma warning restore IL2026
var sr = new StreamReader(outputPrefix + ".resume.xml"); var sr = new StreamReader(outputPrefix + ".resume.xml");
// Should be covered by virtue of being the same exact class as the JSON above // 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); resumeClass = (Resume)xs.Deserialize(sr);
#pragma warning restore IL2026 #pragma warning restore IL2026
sr.Close(); sr.Close();
} }
@@ -545,7 +497,9 @@ sealed class DumpMediaCommand : Command
Metadata sidecar = null; Metadata sidecar = null;
if(aaruMetadata != null) if(aaruMetadata != null)
{
if(File.Exists(aaruMetadata)) if(File.Exists(aaruMetadata))
{
try try
{ {
var fs = new FileStream(aaruMetadata, FileMode.Open); var fs = new FileStream(aaruMetadata, FileMode.Open);
@@ -565,6 +519,7 @@ sealed class DumpMediaCommand : Command
return (int)ErrorNumber.InvalidSidecar; return (int)ErrorNumber.InvalidSidecar;
} }
}
else else
{ {
AaruConsole.ErrorWriteLine(UI.Could_not_find_metadata_sidecar); AaruConsole.ErrorWriteLine(UI.Could_not_find_metadata_sidecar);
@@ -574,21 +529,24 @@ sealed class DumpMediaCommand : Command
return (int)ErrorNumber.NoSuchFile; return (int)ErrorNumber.NoSuchFile;
} }
}
else if(cicmXml != null) else if(cicmXml != null)
{
if(File.Exists(cicmXml)) if(File.Exists(cicmXml))
{
try try
{ {
var sr = new StreamReader(cicmXml); var sr = new StreamReader(cicmXml);
// Bypassed by JSON source generator used above // Bypassed by JSON source generator used above
#pragma warning disable IL2026 #pragma warning disable IL2026
var sidecarXs = new XmlSerializer(typeof(CICMMetadataType)); var sidecarXs = new XmlSerializer(typeof(CICMMetadataType));
#pragma warning restore IL2026 #pragma warning restore IL2026
// Bypassed by JSON source generator used above // Bypassed by JSON source generator used above
#pragma warning disable IL2026 #pragma warning disable IL2026
sidecar = (CICMMetadataType)sidecarXs.Deserialize(sr); sidecar = (CICMMetadataType)sidecarXs.Deserialize(sr);
#pragma warning restore IL2026 #pragma warning restore IL2026
sr.Close(); sr.Close();
} }
@@ -601,6 +559,7 @@ sealed class DumpMediaCommand : Command
return (int)ErrorNumber.InvalidSidecar; return (int)ErrorNumber.InvalidSidecar;
} }
}
else else
{ {
AaruConsole.ErrorWriteLine(UI.Could_not_find_metadata_sidecar); AaruConsole.ErrorWriteLine(UI.Could_not_find_metadata_sidecar);
@@ -610,30 +569,43 @@ sealed class DumpMediaCommand : Command
return (int)ErrorNumber.NoSuchFile; return (int)ErrorNumber.NoSuchFile;
} }
}
plugins = PluginBase.Singleton; plugins = PluginBase.Singleton;
candidates = new List<IBaseWritableImage>(); candidates = new List<IBaseWritableImage>();
// Try extension // Try extension
if(string.IsNullOrEmpty(format)) if(string.IsNullOrEmpty(format))
{
candidates.AddRange(from pluginType in plugins.WritableImages.Values 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 is not null
where plugin.KnownExtensions.Contains(Path.GetExtension(outputPath)) select plugin); where plugin.KnownExtensions.Contains(Path.GetExtension(outputPath))
select plugin);
}
// Try Id // Try Id
else if(Guid.TryParse(format, out Guid outId)) else if(Guid.TryParse(format, out Guid outId))
{
candidates.AddRange(from pluginType in plugins.WritableImages.Values candidates.AddRange(from pluginType in plugins.WritableImages.Values
select Activator.CreateInstance(pluginType) as IBaseWritableImage into plugin select Activator.CreateInstance(pluginType) as IBaseWritableImage
where plugin is not null where plugin.Id.Equals(outId) select plugin); into plugin
where plugin is not null
where plugin.Id.Equals(outId)
select plugin);
}
// Try name // Try name
else else
{
candidates.AddRange(from pluginType in plugins.WritableImages.Values 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 is not null
where plugin.Name.Equals(format, StringComparison.InvariantCultureIgnoreCase) where plugin.Name.Equals(format, StringComparison.InvariantCultureIgnoreCase)
select plugin); select plugin);
}
IBaseWritableImage outputFormat = candidates[0]; IBaseWritableImage outputFormat = candidates[0];
@@ -663,121 +635,120 @@ sealed class DumpMediaCommand : Command
AnsiConsole.Progress().AutoClear(true).HideCompleted(true). AnsiConsole.Progress().AutoClear(true).HideCompleted(true).
Columns(new TaskDescriptionColumn(), new ProgressBarColumn(), new PercentageColumn()). Columns(new TaskDescriptionColumn(), new ProgressBarColumn(), new PercentageColumn()).
Start(ctx => Start(ctx =>
{ {
dumper.UpdateStatus += text => dumper.UpdateStatus += text => { AaruConsole.WriteLine(Markup.Escape(text)); };
{
AaruConsole.WriteLine(Markup.Escape(text));
};
dumper.ErrorMessage += text => dumper.ErrorMessage += text =>
{ {
AaruConsole.ErrorWriteLine($"[red]{Markup.Escape(text)}[/]"); AaruConsole.
}; ErrorWriteLine($"[red]{Markup.Escape(text)}[/]");
};
dumper.StoppingErrorMessage += text => dumper.StoppingErrorMessage += text =>
{ {
AaruConsole.ErrorWriteLine($"[red]{Markup.Escape(text)}[/]"); AaruConsole.
}; ErrorWriteLine($"[red]{Markup.Escape(text)}[/]");
};
dumper.UpdateProgress += (text, current, maximum) => dumper.UpdateProgress += (text, current, maximum) =>
{ {
_progressTask1 ??= ctx.AddTask("Progress"); _progressTask1 ??= ctx.AddTask("Progress");
_progressTask1.Description = Markup.Escape(text); _progressTask1.Description = Markup.Escape(text);
_progressTask1.Value = current; _progressTask1.Value = current;
_progressTask1.MaxValue = maximum; _progressTask1.MaxValue = maximum;
}; };
dumper.PulseProgress += text => dumper.PulseProgress += text =>
{ {
if(_progressTask1 is null) if(_progressTask1 is null)
ctx.AddTask(Markup.Escape(text)).IsIndeterminate(); ctx.AddTask(Markup.Escape(text)).IsIndeterminate();
else else
{ {
_progressTask1.Description = Markup.Escape(text); _progressTask1.Description = Markup.Escape(text);
_progressTask1.IsIndeterminate = true; _progressTask1.IsIndeterminate = true;
} }
}; };
dumper.InitProgress += () => dumper.InitProgress += () => { _progressTask1 = ctx.AddTask("Progress"); };
{
_progressTask1 = ctx.AddTask("Progress");
};
dumper.EndProgress += () => dumper.EndProgress += () =>
{ {
_progressTask1?.StopTask(); _progressTask1?.StopTask();
_progressTask1 = null; _progressTask1 = null;
}; };
dumper.InitProgress2 += () => dumper.InitProgress2 += () => { _progressTask2 = ctx.AddTask("Progress"); };
{
_progressTask2 = ctx.AddTask("Progress");
};
dumper.EndProgress2 += () => dumper.EndProgress2 += () =>
{ {
_progressTask2?.StopTask(); _progressTask2?.StopTask();
_progressTask2 = null; _progressTask2 = null;
}; };
dumper.UpdateProgress2 += (text, current, maximum) => dumper.UpdateProgress2 += (text, current, maximum) =>
{ {
_progressTask2 ??= ctx.AddTask("Progress"); _progressTask2 ??= ctx.AddTask("Progress");
_progressTask2.Description = Markup.Escape(text); _progressTask2.Description = Markup.Escape(text);
_progressTask2.Value = current; _progressTask2.Value = current;
_progressTask2.MaxValue = maximum; _progressTask2.MaxValue = maximum;
}; };
System.Console.CancelKeyPress += (_, e) => System.Console.CancelKeyPress += (_, e) =>
{ {
e.Cancel = true; e.Cancel = true;
dumper.Abort(); dumper.Abort();
}; };
dumper.Start(); dumper.Start();
}); });
if(eject && dev.IsRemovable) if(eject && dev.IsRemovable)
{
Core.Spectre.ProgressSingleSpinner(ctx => Core.Spectre.ProgressSingleSpinner(ctx =>
{ {
ctx.AddTask(UI.Ejecting_media).IsIndeterminate(); ctx.AddTask(UI.Ejecting_media).IsIndeterminate();
switch(dev.Type) switch(dev.Type)
{ {
case DeviceType.ATA: case DeviceType.ATA:
dev.DoorUnlock(out _, dev.Timeout, out _); dev.DoorUnlock(out _, dev.Timeout, out _);
dev.MediaEject(out _, dev.Timeout, out _); dev.MediaEject(out _, dev.Timeout, out _);
break; break;
case DeviceType.ATAPI: case DeviceType.ATAPI:
case DeviceType.SCSI: case DeviceType.SCSI:
switch(dev.ScsiType) switch(dev.ScsiType)
{ {
case PeripheralDeviceTypes.DirectAccess: case PeripheralDeviceTypes.DirectAccess:
case PeripheralDeviceTypes.SimplifiedDevice: case PeripheralDeviceTypes.SimplifiedDevice:
case PeripheralDeviceTypes.SCSIZonedBlockDevice: case PeripheralDeviceTypes.SCSIZonedBlockDevice:
case PeripheralDeviceTypes.WriteOnceDevice: case PeripheralDeviceTypes.WriteOnceDevice:
case PeripheralDeviceTypes.OpticalDevice: case PeripheralDeviceTypes.OpticalDevice:
case PeripheralDeviceTypes.OCRWDevice: case PeripheralDeviceTypes.OCRWDevice:
dev.SpcAllowMediumRemoval(out _, dev.Timeout, out _); dev.SpcAllowMediumRemoval(out _, dev.Timeout,
dev.EjectTray(out _, dev.Timeout, out _); out _);
dev.EjectTray(out _, dev.Timeout, out _);
break; break;
case PeripheralDeviceTypes.MultiMediaDevice: case PeripheralDeviceTypes.MultiMediaDevice:
dev.AllowMediumRemoval(out _, dev.Timeout, out _); dev.AllowMediumRemoval(out _, dev.Timeout,
dev.EjectTray(out _, dev.Timeout, out _); out _);
dev.EjectTray(out _, dev.Timeout, out _);
break; break;
case PeripheralDeviceTypes.SequentialAccess: case PeripheralDeviceTypes.SequentialAccess:
dev.SpcAllowMediumRemoval(out _, dev.Timeout, out _); dev.SpcAllowMediumRemoval(out _, dev.Timeout,
dev.LoadUnload(out _, true, false, false, false, false, dev.Timeout, out _); out _);
dev.LoadUnload(out _, true, false, false, false,
false, dev.Timeout, out _);
break; break;
} }
break; break;
} }
}); });
}
dev.Close(); dev.Close();
} }

View File

@@ -69,10 +69,7 @@ sealed class MediaInfoCommand : Command
public MediaInfoCommand() : base("info", UI.Media_Info_Command_Description) public MediaInfoCommand() : base("info", UI.Media_Info_Command_Description)
{ {
Add(new Option<string>(new[] Add(new Option<string>(new[] { "--output-prefix", "-w" }, () => null, UI.Prefix_for_saving_binary_information));
{
"--output-prefix", "-w"
}, () => null, UI.Prefix_for_saving_binary_information));
AddArgument(new Argument<string> AddArgument(new Argument<string>
{ {
@@ -96,29 +93,31 @@ sealed class MediaInfoCommand : Command
}); });
AaruConsole.DebugWriteLineEvent += (format, objects) => AaruConsole.DebugWriteLineEvent += (format, objects) =>
{ {
if(objects is null) if(objects is null)
stderrConsole.MarkupLine(format); stderrConsole.MarkupLine(format);
else else
stderrConsole.MarkupLine(format, objects); stderrConsole.MarkupLine(format, objects);
}; };
} }
if(verbose) if(verbose)
{
AaruConsole.WriteEvent += (format, objects) => AaruConsole.WriteEvent += (format, objects) =>
{ {
if(objects is null) if(objects is null)
AnsiConsole.Markup(format); AnsiConsole.Markup(format);
else else
AnsiConsole.Markup(format, objects); AnsiConsole.Markup(format, objects);
}; };
}
Statistics.AddCommand("media-info"); Statistics.AddCommand("media-info");
AaruConsole.DebugWriteLine(MODULE_NAME, "--debug={0}", debug); AaruConsole.DebugWriteLine(MODULE_NAME, "--debug={0}", debug);
AaruConsole.DebugWriteLine(MODULE_NAME, "--device={0}", devicePath); AaruConsole.DebugWriteLine(MODULE_NAME, "--device={0}", devicePath);
AaruConsole.DebugWriteLine(MODULE_NAME, "--output-prefix={0}", outputPrefix); 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 && if(devicePath.Length == 2 &&
devicePath[1] == ':' && devicePath[1] == ':' &&
@@ -130,10 +129,10 @@ sealed class MediaInfoCommand : Command
ErrorNumber devErrno = ErrorNumber.NoError; ErrorNumber devErrno = ErrorNumber.NoError;
Core.Spectre.ProgressSingleSpinner(ctx => Core.Spectre.ProgressSingleSpinner(ctx =>
{ {
ctx.AddTask(UI.Opening_device).IsIndeterminate(); ctx.AddTask(UI.Opening_device).IsIndeterminate();
dev = Devices.Device.Create(devicePath, out devErrno); dev = Devices.Device.Create(devicePath, out devErrno);
}); });
switch(dev) switch(dev)
{ {
@@ -178,7 +177,8 @@ sealed class MediaInfoCommand : Command
DoScsiMediaInfo(debug, outputPrefix, dev); DoScsiMediaInfo(debug, outputPrefix, dev);
break; break;
default: throw new NotSupportedException(Localization.Core.Unknown_device_type); default:
throw new NotSupportedException(Localization.Core.Unknown_device_type);
} }
return (int)ErrorNumber.NoError; return (int)ErrorNumber.NoError;
@@ -196,21 +196,25 @@ sealed class MediaInfoCommand : Command
ScsiInfo scsiInfo = null; ScsiInfo scsiInfo = null;
Core.Spectre.ProgressSingleSpinner(ctx => Core.Spectre.ProgressSingleSpinner(ctx =>
{ {
ctx.AddTask(UI.Retrieving_SCSI_information).IsIndeterminate(); ctx.AddTask(UI.Retrieving_SCSI_information).IsIndeterminate();
scsiInfo = new ScsiInfo(dev); scsiInfo = new ScsiInfo(dev);
}); });
if(!scsiInfo.MediaInserted) if(!scsiInfo.MediaInserted)
return; return;
if(scsiInfo.DeviceInfo.ScsiModeSense6 != null) if(scsiInfo.DeviceInfo.ScsiModeSense6 != null)
{
DataFile.WriteTo(MODULE_NAME, outputPrefix, "_scsi_modesense6.bin", "SCSI MODE SENSE (6)", DataFile.WriteTo(MODULE_NAME, outputPrefix, "_scsi_modesense6.bin", "SCSI MODE SENSE (6)",
scsiInfo.DeviceInfo.ScsiModeSense6); scsiInfo.DeviceInfo.ScsiModeSense6);
}
if(scsiInfo.DeviceInfo.ScsiModeSense10 != null) if(scsiInfo.DeviceInfo.ScsiModeSense10 != null)
{
DataFile.WriteTo(MODULE_NAME, outputPrefix, "_scsi_modesense10.bin", "SCSI MODE SENSE (10)", DataFile.WriteTo(MODULE_NAME, outputPrefix, "_scsi_modesense10.bin", "SCSI MODE SENSE (10)",
scsiInfo.DeviceInfo.ScsiModeSense10); scsiInfo.DeviceInfo.ScsiModeSense10);
}
switch(dev.ScsiType) switch(dev.ScsiType)
{ {
@@ -223,18 +227,24 @@ sealed class MediaInfoCommand : Command
case PeripheralDeviceTypes.BridgingExpander when dev.Model.StartsWith("MDM", StringComparison.Ordinal) || case PeripheralDeviceTypes.BridgingExpander when dev.Model.StartsWith("MDM", StringComparison.Ordinal) ||
dev.Model.StartsWith("MDH", StringComparison.Ordinal): dev.Model.StartsWith("MDH", StringComparison.Ordinal):
if(scsiInfo.ReadCapacity != null) if(scsiInfo.ReadCapacity != null)
{
DataFile.WriteTo(MODULE_NAME, outputPrefix, "_readcapacity.bin", "SCSI READ CAPACITY", DataFile.WriteTo(MODULE_NAME, outputPrefix, "_readcapacity.bin", "SCSI READ CAPACITY",
scsiInfo.ReadCapacity); scsiInfo.ReadCapacity);
}
if(scsiInfo.ReadCapacity16 != null) if(scsiInfo.ReadCapacity16 != null)
{
DataFile.WriteTo(MODULE_NAME, outputPrefix, "_readcapacity16.bin", DataFile.WriteTo(MODULE_NAME, outputPrefix, "_readcapacity16.bin",
"SCSI READ CAPACITY(16)", scsiInfo.ReadCapacity16); "SCSI READ CAPACITY(16)", scsiInfo.ReadCapacity16);
}
if(scsiInfo.Blocks != 0 && if(scsiInfo.Blocks != 0 &&
scsiInfo.BlockSize != 0) scsiInfo.BlockSize != 0)
{
AaruConsole.WriteLine(Localization.Core.Media_has_0_blocks_of_1_bytes_each_for_a_total_of_2, AaruConsole.WriteLine(Localization.Core.Media_has_0_blocks_of_1_bytes_each_for_a_total_of_2,
scsiInfo.Blocks, scsiInfo.BlockSize, scsiInfo.Blocks, scsiInfo.BlockSize,
ByteSize.FromBytes(scsiInfo.Blocks * scsiInfo.BlockSize).ToString("0.000")); ByteSize.FromBytes(scsiInfo.Blocks * scsiInfo.BlockSize).ToString("0.000"));
}
break; break;
case PeripheralDeviceTypes.SequentialAccess: case PeripheralDeviceTypes.SequentialAccess:
@@ -270,16 +280,22 @@ sealed class MediaInfoCommand : Command
if(dev.ScsiType == PeripheralDeviceTypes.MultiMediaDevice) if(dev.ScsiType == PeripheralDeviceTypes.MultiMediaDevice)
{ {
if(scsiInfo.MmcConfiguration != null) if(scsiInfo.MmcConfiguration != null)
{
DataFile.WriteTo(MODULE_NAME, outputPrefix, "_getconfiguration_current.bin", DataFile.WriteTo(MODULE_NAME, outputPrefix, "_getconfiguration_current.bin",
"SCSI GET CONFIGURATION", scsiInfo.MmcConfiguration); "SCSI GET CONFIGURATION", scsiInfo.MmcConfiguration);
}
if(scsiInfo.RecognizedFormatLayers != null) if(scsiInfo.RecognizedFormatLayers != null)
{
DataFile.WriteTo(MODULE_NAME, outputPrefix, "_readdiscstructure_formatlayers.bin", DataFile.WriteTo(MODULE_NAME, outputPrefix, "_readdiscstructure_formatlayers.bin",
"SCSI READ DISC STRUCTURE", scsiInfo.RecognizedFormatLayers); "SCSI READ DISC STRUCTURE", scsiInfo.RecognizedFormatLayers);
}
if(scsiInfo.WriteProtectionStatus != null) if(scsiInfo.WriteProtectionStatus != null)
{
DataFile.WriteTo(MODULE_NAME, outputPrefix, "_readdiscstructure_writeprotection.bin", DataFile.WriteTo(MODULE_NAME, outputPrefix, "_readdiscstructure_writeprotection.bin",
"SCSI READ DISC STRUCTURE", scsiInfo.WriteProtectionStatus); "SCSI READ DISC STRUCTURE", scsiInfo.WriteProtectionStatus);
}
if(scsiInfo.DvdPfi != null) if(scsiInfo.DvdPfi != null)
{ {
@@ -296,11 +312,15 @@ sealed class MediaInfoCommand : Command
"SCSI READ DISC STRUCTURE", scsiInfo.DvdDmi); "SCSI READ DISC STRUCTURE", scsiInfo.DvdDmi);
if(DMI.IsXbox(scsiInfo.DvdDmi)) if(DMI.IsXbox(scsiInfo.DvdDmi))
{
AaruConsole.WriteLine($"[bold]{Localization.Core.Xbox_DMI}:[/]", AaruConsole.WriteLine($"[bold]{Localization.Core.Xbox_DMI}:[/]",
$"\n{Markup.Escape(DMI.PrettifyXbox(scsiInfo.DvdDmi))}"); $"\n{Markup.Escape(DMI.PrettifyXbox(scsiInfo.DvdDmi))}");
}
else if(DMI.IsXbox360(scsiInfo.DvdDmi)) else if(DMI.IsXbox360(scsiInfo.DvdDmi))
{
AaruConsole.WriteLine($"[bold]{Localization.Core.Xbox_360_DMI}:[/]", AaruConsole.WriteLine($"[bold]{Localization.Core.Xbox_360_DMI}:[/]",
$"\n{Markup.Escape(DMI.PrettifyXbox360(scsiInfo.DvdDmi))}"); $"\n{Markup.Escape(DMI.PrettifyXbox360(scsiInfo.DvdDmi))}");
}
} }
if(scsiInfo.DvdCmi != null) if(scsiInfo.DvdCmi != null)
@@ -313,20 +333,28 @@ sealed class MediaInfoCommand : Command
} }
if(scsiInfo.DvdDiscKey != null) if(scsiInfo.DvdDiscKey != null)
{
DataFile.WriteTo(MODULE_NAME, outputPrefix, "_readdiscstructure_dvd_disckey.bin", DataFile.WriteTo(MODULE_NAME, outputPrefix, "_readdiscstructure_dvd_disckey.bin",
"SCSI READ DISC STRUCTURE", scsiInfo.DvdDiscKey); "SCSI READ DISC STRUCTURE", scsiInfo.DvdDiscKey);
}
if(scsiInfo.DvdSectorCmi != null) if(scsiInfo.DvdSectorCmi != null)
{
DataFile.WriteTo(MODULE_NAME, outputPrefix, "_readdiscstructure_dvd_sectorcmi.bin", DataFile.WriteTo(MODULE_NAME, outputPrefix, "_readdiscstructure_dvd_sectorcmi.bin",
"SCSI READ DISC STRUCTURE", scsiInfo.DvdSectorCmi); "SCSI READ DISC STRUCTURE", scsiInfo.DvdSectorCmi);
}
if(scsiInfo.DvdBca != null) if(scsiInfo.DvdBca != null)
{
DataFile.WriteTo(MODULE_NAME, outputPrefix, "_readdiscstructure_dvd_bca.bin", DataFile.WriteTo(MODULE_NAME, outputPrefix, "_readdiscstructure_dvd_bca.bin",
"SCSI READ DISC STRUCTURE", scsiInfo.DvdBca); "SCSI READ DISC STRUCTURE", scsiInfo.DvdBca);
}
if(scsiInfo.DvdAacs != null) if(scsiInfo.DvdAacs != null)
{
DataFile.WriteTo(MODULE_NAME, outputPrefix, "_readdiscstructure_dvd_aacs.bin", DataFile.WriteTo(MODULE_NAME, outputPrefix, "_readdiscstructure_dvd_aacs.bin",
"SCSI READ DISC STRUCTURE", scsiInfo.DvdAacs); "SCSI READ DISC STRUCTURE", scsiInfo.DvdAacs);
}
if(scsiInfo.DvdRamDds != null) if(scsiInfo.DvdRamDds != null)
{ {
@@ -356,8 +384,10 @@ sealed class MediaInfoCommand : Command
} }
if(scsiInfo.LastBorderOutRmd != null) if(scsiInfo.LastBorderOutRmd != null)
{
DataFile.WriteTo(MODULE_NAME, outputPrefix, "_readdiscstructure_dvd_lastrmd.bin", DataFile.WriteTo(MODULE_NAME, outputPrefix, "_readdiscstructure_dvd_lastrmd.bin",
"SCSI READ DISC STRUCTURE", scsiInfo.LastBorderOutRmd); "SCSI READ DISC STRUCTURE", scsiInfo.LastBorderOutRmd);
}
if(scsiInfo.DvdPreRecordedInfo != null) if(scsiInfo.DvdPreRecordedInfo != null)
{ {
@@ -365,13 +395,17 @@ sealed class MediaInfoCommand : Command
"SCSI READ DISC STRUCTURE", scsiInfo.DvdPreRecordedInfo); "SCSI READ DISC STRUCTURE", scsiInfo.DvdPreRecordedInfo);
if(scsiInfo.DecodedDvdPrePitInformation.HasValue) if(scsiInfo.DecodedDvdPrePitInformation.HasValue)
{
AaruConsole.WriteLine($"[bold]{Localization.Core.DVD_RW_Pre_Recorded_Information}:[/]", AaruConsole.WriteLine($"[bold]{Localization.Core.DVD_RW_Pre_Recorded_Information}:[/]",
$"\n{Markup.Escape(PRI.Prettify(scsiInfo.DecodedDvdPrePitInformation))}"); $"\n{Markup.Escape(PRI.Prettify(scsiInfo.DecodedDvdPrePitInformation))}");
}
} }
if(scsiInfo.DvdrMediaIdentifier != null) if(scsiInfo.DvdrMediaIdentifier != null)
{
DataFile.WriteTo(MODULE_NAME, outputPrefix, "_readdiscstructure_dvdr_mediaid.bin", DataFile.WriteTo(MODULE_NAME, outputPrefix, "_readdiscstructure_dvdr_mediaid.bin",
"SCSI READ DISC STRUCTURE", scsiInfo.DvdrMediaIdentifier); "SCSI READ DISC STRUCTURE", scsiInfo.DvdrMediaIdentifier);
}
if(scsiInfo.DvdrPhysicalInformation != null) if(scsiInfo.DvdrPhysicalInformation != null)
{ {
@@ -379,49 +413,71 @@ sealed class MediaInfoCommand : Command
"SCSI READ DISC STRUCTURE", scsiInfo.DvdrPhysicalInformation); "SCSI READ DISC STRUCTURE", scsiInfo.DvdrPhysicalInformation);
if(scsiInfo.DecodedDvdrPfi.HasValue) if(scsiInfo.DecodedDvdrPfi.HasValue)
{
AaruConsole.WriteLine($"[bold]{Localization.Core.DVD_RW_PFI}:[/]", AaruConsole.WriteLine($"[bold]{Localization.Core.DVD_RW_PFI}:[/]",
$"\n{Markup.Escape(PFI.Prettify(scsiInfo.DecodedDvdrPfi))}"); $"\n{Markup.Escape(PFI.Prettify(scsiInfo.DecodedDvdrPfi))}");
}
} }
if(scsiInfo.DvdPlusAdip != null) if(scsiInfo.DvdPlusAdip != null)
{
DataFile.WriteTo(MODULE_NAME, outputPrefix, "_readdiscstructure_dvd+_adip.bin", DataFile.WriteTo(MODULE_NAME, outputPrefix, "_readdiscstructure_dvd+_adip.bin",
"SCSI READ DISC STRUCTURE", scsiInfo.DvdPlusAdip); "SCSI READ DISC STRUCTURE", scsiInfo.DvdPlusAdip);
}
if(scsiInfo.DvdPlusDcb != null) if(scsiInfo.DvdPlusDcb != null)
{
DataFile.WriteTo(MODULE_NAME, outputPrefix, "_readdiscstructure_dvd+_dcb.bin", DataFile.WriteTo(MODULE_NAME, outputPrefix, "_readdiscstructure_dvd+_dcb.bin",
"SCSI READ DISC STRUCTURE", scsiInfo.DvdPlusDcb); "SCSI READ DISC STRUCTURE", scsiInfo.DvdPlusDcb);
}
if(scsiInfo.HddvdCopyrightInformation != null) if(scsiInfo.HddvdCopyrightInformation != null)
{
DataFile.WriteTo(MODULE_NAME, outputPrefix, "_readdiscstructure_hddvd_cmi.bin", DataFile.WriteTo(MODULE_NAME, outputPrefix, "_readdiscstructure_hddvd_cmi.bin",
"SCSI READ DISC STRUCTURE", scsiInfo.HddvdCopyrightInformation); "SCSI READ DISC STRUCTURE", scsiInfo.HddvdCopyrightInformation);
}
if(scsiInfo.HddvdrMediumStatus != null) if(scsiInfo.HddvdrMediumStatus != null)
{
DataFile.WriteTo(MODULE_NAME, outputPrefix, "_readdiscstructure_hddvdr_status.bin", DataFile.WriteTo(MODULE_NAME, outputPrefix, "_readdiscstructure_hddvdr_status.bin",
"SCSI READ DISC STRUCTURE", scsiInfo.HddvdrMediumStatus); "SCSI READ DISC STRUCTURE", scsiInfo.HddvdrMediumStatus);
}
if(scsiInfo.HddvdrLastRmd != null) if(scsiInfo.HddvdrLastRmd != null)
{
DataFile.WriteTo(MODULE_NAME, outputPrefix, "_readdiscstructure_hddvdr_lastrmd.bin", DataFile.WriteTo(MODULE_NAME, outputPrefix, "_readdiscstructure_hddvdr_lastrmd.bin",
"SCSI READ DISC STRUCTURE", scsiInfo.HddvdrLastRmd); "SCSI READ DISC STRUCTURE", scsiInfo.HddvdrLastRmd);
}
if(scsiInfo.DvdrLayerCapacity != null) if(scsiInfo.DvdrLayerCapacity != null)
{
DataFile.WriteTo(MODULE_NAME, outputPrefix, "_readdiscstructure_dvdr_layercap.bin", DataFile.WriteTo(MODULE_NAME, outputPrefix, "_readdiscstructure_dvdr_layercap.bin",
"SCSI READ DISC STRUCTURE", scsiInfo.DvdrLayerCapacity); "SCSI READ DISC STRUCTURE", scsiInfo.DvdrLayerCapacity);
}
if(scsiInfo.DvdrDlMiddleZoneStart != null) if(scsiInfo.DvdrDlMiddleZoneStart != null)
{
DataFile.WriteTo(MODULE_NAME, outputPrefix, "_readdiscstructure_dvd_mzs.bin", DataFile.WriteTo(MODULE_NAME, outputPrefix, "_readdiscstructure_dvd_mzs.bin",
"SCSI READ DISC STRUCTURE", scsiInfo.DvdrDlMiddleZoneStart); "SCSI READ DISC STRUCTURE", scsiInfo.DvdrDlMiddleZoneStart);
}
if(scsiInfo.DvdrDlJumpIntervalSize != null) if(scsiInfo.DvdrDlJumpIntervalSize != null)
{
DataFile.WriteTo(MODULE_NAME, outputPrefix, "_readdiscstructure_dvd_jis.bin", DataFile.WriteTo(MODULE_NAME, outputPrefix, "_readdiscstructure_dvd_jis.bin",
"SCSI READ DISC STRUCTURE", scsiInfo.DvdrDlJumpIntervalSize); "SCSI READ DISC STRUCTURE", scsiInfo.DvdrDlJumpIntervalSize);
}
if(scsiInfo.DvdrDlManualLayerJumpStartLba != null) if(scsiInfo.DvdrDlManualLayerJumpStartLba != null)
{
DataFile.WriteTo(MODULE_NAME, outputPrefix, "_readdiscstructure_dvd_manuallj.bin", DataFile.WriteTo(MODULE_NAME, outputPrefix, "_readdiscstructure_dvd_manuallj.bin",
"SCSI READ DISC STRUCTURE", scsiInfo.DvdrDlManualLayerJumpStartLba); "SCSI READ DISC STRUCTURE", scsiInfo.DvdrDlManualLayerJumpStartLba);
}
if(scsiInfo.DvdrDlRemapAnchorPoint != null) if(scsiInfo.DvdrDlRemapAnchorPoint != null)
{
DataFile.WriteTo(MODULE_NAME, outputPrefix, "_readdiscstructure_dvd_remapanchor.bin", DataFile.WriteTo(MODULE_NAME, outputPrefix, "_readdiscstructure_dvd_remapanchor.bin",
"SCSI READ DISC STRUCTURE", scsiInfo.DvdrDlRemapAnchorPoint); "SCSI READ DISC STRUCTURE", scsiInfo.DvdrDlRemapAnchorPoint);
}
if(scsiInfo.BlurayDiscInformation != null) if(scsiInfo.BlurayDiscInformation != null)
{ {
@@ -433,8 +489,10 @@ sealed class MediaInfoCommand : Command
} }
if(scsiInfo.BlurayPac != null) if(scsiInfo.BlurayPac != null)
{
DataFile.WriteTo(MODULE_NAME, outputPrefix, "_readdiscstructure_bd_pac.bin", DataFile.WriteTo(MODULE_NAME, outputPrefix, "_readdiscstructure_bd_pac.bin",
"SCSI READ DISC STRUCTURE", scsiInfo.BlurayPac); "SCSI READ DISC STRUCTURE", scsiInfo.BlurayPac);
}
if(scsiInfo.BlurayBurstCuttingArea != null) if(scsiInfo.BlurayBurstCuttingArea != null)
{ {
@@ -461,7 +519,7 @@ sealed class MediaInfoCommand : Command
AaruConsole.WriteLine($"[bold]{Localization.Core.Bluray_Cartridge_Status}:[/]", AaruConsole.WriteLine($"[bold]{Localization.Core.Bluray_Cartridge_Status}:[/]",
$"\n{Markup.Escape(Decoders.Bluray.Cartridge.Prettify(scsiInfo. $"\n{Markup.Escape(Decoders.Bluray.Cartridge.Prettify(scsiInfo.
BlurayCartridgeStatus))}"); BlurayCartridgeStatus))}");
} }
if(scsiInfo.BluraySpareAreaInformation != null) if(scsiInfo.BluraySpareAreaInformation != null)
@@ -471,12 +529,14 @@ sealed class MediaInfoCommand : Command
AaruConsole.WriteLine($"[bold]{Localization.Core.Bluray_Spare_Area_Information}:[/]", AaruConsole.WriteLine($"[bold]{Localization.Core.Bluray_Spare_Area_Information}:[/]",
$"\n{Markup.Escape(Decoders.Bluray.Spare.Prettify(scsiInfo. $"\n{Markup.Escape(Decoders.Bluray.Spare.Prettify(scsiInfo.
BluraySpareAreaInformation))}"); BluraySpareAreaInformation))}");
} }
if(scsiInfo.BlurayRawDfl != null) if(scsiInfo.BlurayRawDfl != null)
{
DataFile.WriteTo(MODULE_NAME, outputPrefix, "_readdiscstructure_bd_dfl.bin", DataFile.WriteTo(MODULE_NAME, outputPrefix, "_readdiscstructure_bd_dfl.bin",
"SCSI READ DISC STRUCTURE", scsiInfo.BlurayRawDfl); "SCSI READ DISC STRUCTURE", scsiInfo.BlurayRawDfl);
}
if(scsiInfo.BlurayTrackResources != null) if(scsiInfo.BlurayTrackResources != null)
{ {
@@ -502,8 +562,10 @@ sealed class MediaInfoCommand : Command
scsiInfo.Toc); scsiInfo.Toc);
if(scsiInfo.DecodedToc.HasValue) if(scsiInfo.DecodedToc.HasValue)
{
AaruConsole.WriteLine($"[bold]{UI.Title_TOC}:[/]", AaruConsole.WriteLine($"[bold]{UI.Title_TOC}:[/]",
$"\n{Markup.Escape(TOC.Prettify(scsiInfo.DecodedToc))}"); $"\n{Markup.Escape(TOC.Prettify(scsiInfo.DecodedToc))}");
}
} }
if(scsiInfo.Atip != null) if(scsiInfo.Atip != null)
@@ -512,8 +574,10 @@ sealed class MediaInfoCommand : Command
scsiInfo.Atip); scsiInfo.Atip);
if(scsiInfo.DecodedAtip != null) if(scsiInfo.DecodedAtip != null)
{
AaruConsole.WriteLine($"[bold]{UI.Title_ATIP}:[/]", AaruConsole.WriteLine($"[bold]{UI.Title_ATIP}:[/]",
$"\n{Markup.Escape(ATIP.Prettify(scsiInfo.DecodedAtip))}"); $"\n{Markup.Escape(ATIP.Prettify(scsiInfo.DecodedAtip))}");
}
} }
if(scsiInfo.DiscInformation != null) if(scsiInfo.DiscInformation != null)
@@ -522,9 +586,11 @@ sealed class MediaInfoCommand : Command
"SCSI READ DISC INFORMATION", scsiInfo.DiscInformation); "SCSI READ DISC INFORMATION", scsiInfo.DiscInformation);
if(scsiInfo.DecodedDiscInformation.HasValue) if(scsiInfo.DecodedDiscInformation.HasValue)
{
AaruConsole.WriteLine($"[bold]{Localization.Core.Standard_Disc_Information}:[/]", AaruConsole.WriteLine($"[bold]{Localization.Core.Standard_Disc_Information}:[/]",
$"\n{Markup.Escape(DiscInformation.Prettify000b(scsiInfo. $"\n{Markup.Escape(DiscInformation.Prettify000b(scsiInfo.
DecodedDiscInformation))}"); DecodedDiscInformation))}");
}
} }
if(scsiInfo.Session != null) if(scsiInfo.Session != null)
@@ -533,8 +599,10 @@ sealed class MediaInfoCommand : Command
scsiInfo.Session); scsiInfo.Session);
if(scsiInfo.DecodedSession.HasValue) if(scsiInfo.DecodedSession.HasValue)
{
AaruConsole.WriteLine($"[bold]{Localization.Core.Session_information}:[/]", AaruConsole.WriteLine($"[bold]{Localization.Core.Session_information}:[/]",
$"\n{Markup.Escape(Session.Prettify(scsiInfo.DecodedSession))}"); $"\n{Markup.Escape(Session.Prettify(scsiInfo.DecodedSession))}");
}
} }
if(scsiInfo.RawToc != null) if(scsiInfo.RawToc != null)
@@ -543,8 +611,10 @@ sealed class MediaInfoCommand : Command
scsiInfo.RawToc); scsiInfo.RawToc);
if(scsiInfo.FullToc.HasValue) if(scsiInfo.FullToc.HasValue)
{
AaruConsole.WriteLine($"[bold]{Localization.Core.Raw_TOC}:[/]", AaruConsole.WriteLine($"[bold]{Localization.Core.Raw_TOC}:[/]",
$"\n{Markup.Escape(FullTOC.Prettify(scsiInfo.RawToc))}"); $"\n{Markup.Escape(FullTOC.Prettify(scsiInfo.RawToc))}");
}
} }
if(scsiInfo.Pma != null) if(scsiInfo.Pma != null)
@@ -562,25 +632,35 @@ sealed class MediaInfoCommand : Command
scsiInfo.CdTextLeadIn); scsiInfo.CdTextLeadIn);
if(scsiInfo.DecodedCdTextLeadIn.HasValue) if(scsiInfo.DecodedCdTextLeadIn.HasValue)
{
AaruConsole.WriteLine($"[bold]{Localization.Core.CD_TEXT_on_Lead_In}:[/]", AaruConsole.WriteLine($"[bold]{Localization.Core.CD_TEXT_on_Lead_In}:[/]",
$"\n{Markup.Escape(CDTextOnLeadIn.Prettify(scsiInfo.DecodedCdTextLeadIn))}"); $"\n{Markup.Escape(CDTextOnLeadIn.Prettify(scsiInfo.DecodedCdTextLeadIn))}");
}
} }
if(!string.IsNullOrEmpty(scsiInfo.Mcn)) if(!string.IsNullOrEmpty(scsiInfo.Mcn))
AaruConsole.WriteLine($"[bold]{Localization.Core.MCN}:[/]", $" {Markup.Escape(scsiInfo.Mcn)}"); AaruConsole.WriteLine($"[bold]{Localization.Core.MCN}:[/]", $" {Markup.Escape(scsiInfo.Mcn)}");
if(scsiInfo.Isrcs != null) if(scsiInfo.Isrcs != null)
{
foreach(KeyValuePair<byte, string> isrc in scsiInfo.Isrcs) foreach(KeyValuePair<byte, string> isrc in scsiInfo.Isrcs)
{
AaruConsole.WriteLine($"[bold]{string.Format(Localization.Core.Tracks_0_ISRC, isrc.Key)}:[/] { AaruConsole.WriteLine($"[bold]{string.Format(Localization.Core.Tracks_0_ISRC, isrc.Key)}:[/] {
Markup.Escape(isrc.Value)}"); Markup.Escape(isrc.Value)}");
}
}
if(scsiInfo.XboxSecuritySector != null) if(scsiInfo.XboxSecuritySector != null)
{
DataFile.WriteTo(MODULE_NAME, outputPrefix, "_xbox_ss.bin", "KREON EXTRACT SS", DataFile.WriteTo(MODULE_NAME, outputPrefix, "_xbox_ss.bin", "KREON EXTRACT SS",
scsiInfo.XboxSecuritySector); scsiInfo.XboxSecuritySector);
}
if(scsiInfo.DecodedXboxSecuritySector.HasValue) if(scsiInfo.DecodedXboxSecuritySector.HasValue)
{
AaruConsole.WriteLine($"[bold]{Localization.Core.Xbox_Security_Sector}:[/]", AaruConsole.WriteLine($"[bold]{Localization.Core.Xbox_Security_Sector}:[/]",
$"\n{Markup.Escape(SS.Prettify(scsiInfo.DecodedXboxSecuritySector))}"); $"\n{Markup.Escape(SS.Prettify(scsiInfo.DecodedXboxSecuritySector))}");
}
if(scsiInfo.XgdInfo != null) if(scsiInfo.XgdInfo != null)
{ {
@@ -612,7 +692,7 @@ sealed class MediaInfoCommand : Command
AaruConsole.Write($"[bold]{Localization.Core.Media_Serial_Number}:[/] "); 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.Write("{0:X2}", scsiInfo.MediaSerialNumber[i]);
AaruConsole.WriteLine(); AaruConsole.WriteLine();
@@ -629,7 +709,7 @@ sealed class MediaInfoCommand : Command
if(tracks != null) 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 supportsPqSubchannel = Dump.SupportsPqSubchannel(dev, null, null, firstLba);
bool supportsRwSubchannel = Dump.SupportsRwSubchannel(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, Dump.SolveTrackPregaps(dev, null, null, tracks, supportsPqSubchannel, supportsRwSubchannel, dbDev,
out bool inexactPositioning, false); 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[t - 1].EndSector = tracks[t].StartSector - 1;
tracks[^1].EndSector = (ulong)lastSector; tracks[^1].EndSector = (ulong)lastSector;
@@ -654,17 +734,21 @@ sealed class MediaInfoCommand : Command
AaruConsole.WriteLine($"[bold]{Localization.Core.Track_calculations}:[/]"); AaruConsole.WriteLine($"[bold]{Localization.Core.Track_calculations}:[/]");
if(inexactPositioning) if(inexactPositioning)
{
AaruConsole.WriteLine($"[yellow]{Localization.Core. AaruConsole.WriteLine($"[yellow]{Localization.Core.
The_drive_has_returned_incorrect_Q_positioning_calculating_pregaps The_drive_has_returned_incorrect_Q_positioning_calculating_pregaps
}[/]"); }[/]");
}
if(firstLba > 0) if(firstLba > 0)
AaruConsole.WriteLine(UI.Hidden_track_starts_at_LBA_0_ends_at_LBA_1, 0, firstLba - 1); AaruConsole.WriteLine(UI.Hidden_track_starts_at_LBA_0_ends_at_LBA_1, 0, firstLba - 1);
foreach(Track track in tracks) foreach(Track track in tracks)
{
AaruConsole. AaruConsole.
WriteLine(UI.Track_0_starts_at_LBA_1_ends_at_LBA_2_has_a_pregap_of_3_sectors_and_is_of_type_4, 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); track.Sequence, track.StartSector, track.EndSector, track.Pregap, track.Type);
}
AaruConsole.WriteLine(); AaruConsole.WriteLine();
AaruConsole.WriteLine($"[bold]{Localization.Core.Offsets}:[/]"); AaruConsole.WriteLine($"[bold]{Localization.Core.Offsets}:[/]");

View File

@@ -51,20 +51,13 @@ sealed class MediaScanCommand : Command
public MediaScanCommand() : base("scan", UI.Media_Scan_Command_Description) public MediaScanCommand() : base("scan", UI.Media_Scan_Command_Description)
{ {
Add(new Option<string>(new[] Add(new Option<string>(new[] { "--mhdd-log", "-m" }, () => null,
{ UI.Write_a_log_of_the_scan_in_the_format_used_by_MHDD));
"--mhdd-log", "-m"
}, () => null, UI.Write_a_log_of_the_scan_in_the_format_used_by_MHDD));
Add(new Option<string>(new[] Add(new Option<string>(new[] { "--ibg-log", "-b" }, () => null,
{ UI.Write_a_log_of_the_scan_in_the_format_used_by_ImgBurn));
"--ibg-log", "-b"
}, () => null, UI.Write_a_log_of_the_scan_in_the_format_used_by_ImgBurn));
Add(new Option<bool>(new[] Add(new Option<bool>(new[] { "--use-buffered-reads" }, () => true, UI.OS_buffered_reads_help));
{
"--use-buffered-reads"
}, () => true, UI.OS_buffered_reads_help));
AddArgument(new Argument<string> AddArgument(new Argument<string>
{ {
@@ -89,30 +82,32 @@ sealed class MediaScanCommand : Command
}); });
AaruConsole.DebugWriteLineEvent += (format, objects) => AaruConsole.DebugWriteLineEvent += (format, objects) =>
{ {
if(objects is null) if(objects is null)
stderrConsole.MarkupLine(format); stderrConsole.MarkupLine(format);
else else
stderrConsole.MarkupLine(format, objects); stderrConsole.MarkupLine(format, objects);
}; };
} }
if(verbose) if(verbose)
{
AaruConsole.WriteEvent += (format, objects) => AaruConsole.WriteEvent += (format, objects) =>
{ {
if(objects is null) if(objects is null)
AnsiConsole.Markup(format); AnsiConsole.Markup(format);
else else
AnsiConsole.Markup(format, objects); AnsiConsole.Markup(format, objects);
}; };
}
Statistics.AddCommand("media-scan"); Statistics.AddCommand("media-scan");
AaruConsole.DebugWriteLine(MODULE_NAME, "--debug={0}", debug); AaruConsole.DebugWriteLine(MODULE_NAME, "--debug={0}", debug);
AaruConsole.DebugWriteLine(MODULE_NAME, "--device={0}", devicePath); AaruConsole.DebugWriteLine(MODULE_NAME, "--device={0}", devicePath);
AaruConsole.DebugWriteLine(MODULE_NAME, "--ibg-log={0}", ibgLog); AaruConsole.DebugWriteLine(MODULE_NAME, "--ibg-log={0}", ibgLog);
AaruConsole.DebugWriteLine(MODULE_NAME, "--mhdd-log={0}", mhddLog); AaruConsole.DebugWriteLine(MODULE_NAME, "--mhdd-log={0}", mhddLog);
AaruConsole.DebugWriteLine(MODULE_NAME, "--verbose={0}", verbose); AaruConsole.DebugWriteLine(MODULE_NAME, "--verbose={0}", verbose);
AaruConsole.DebugWriteLine(MODULE_NAME, "--use-buffered-reads={0}", useBufferedReads); AaruConsole.DebugWriteLine(MODULE_NAME, "--use-buffered-reads={0}", useBufferedReads);
if(devicePath.Length == 2 && if(devicePath.Length == 2 &&
@@ -125,10 +120,10 @@ sealed class MediaScanCommand : Command
ErrorNumber devErrno = ErrorNumber.NoError; ErrorNumber devErrno = ErrorNumber.NoError;
Core.Spectre.ProgressSingleSpinner(ctx => Core.Spectre.ProgressSingleSpinner(ctx =>
{ {
ctx.AddTask(UI.Opening_device).IsIndeterminate(); ctx.AddTask(UI.Opening_device).IsIndeterminate();
dev = Devices.Device.Create(devicePath, out devErrno); dev = Devices.Device.Create(devicePath, out devErrno);
}); });
switch(dev) switch(dev)
{ {
@@ -159,51 +154,47 @@ sealed class MediaScanCommand : Command
AnsiConsole.Progress().AutoClear(true).HideCompleted(true). AnsiConsole.Progress().AutoClear(true).HideCompleted(true).
Columns(new TaskDescriptionColumn(), new ProgressBarColumn(), new PercentageColumn()).Start(ctx => Columns(new TaskDescriptionColumn(), new ProgressBarColumn(), new PercentageColumn()).Start(ctx =>
{ {
scanner.UpdateStatus += text => scanner.UpdateStatus += text => { AaruConsole.WriteLine(Markup.Escape(text)); };
{
AaruConsole.WriteLine(Markup.Escape(text));
};
scanner.StoppingErrorMessage += text => scanner.StoppingErrorMessage += text =>
{ {
AaruConsole.ErrorWriteLine($"[red]{Markup.Escape(text)}[/]"); AaruConsole.
}; ErrorWriteLine($"[red]{Markup.Escape(text)}[/]");
};
scanner.UpdateProgress += (text, current, maximum) => scanner.UpdateProgress += (text, current, maximum) =>
{ {
_progressTask1 ??= ctx.AddTask("Progress"); _progressTask1 ??= ctx.AddTask("Progress");
_progressTask1.Description = Markup.Escape(text); _progressTask1.Description = Markup.Escape(text);
_progressTask1.Value = current; _progressTask1.Value = current;
_progressTask1.MaxValue = maximum; _progressTask1.MaxValue = maximum;
}; };
scanner.PulseProgress += text => scanner.PulseProgress += text =>
{ {
if(_progressTask1 is null) if(_progressTask1 is null)
ctx.AddTask(Markup.Escape(text)).IsIndeterminate(); ctx.AddTask(Markup.Escape(text)).
else IsIndeterminate();
{ else
_progressTask1.Description = Markup.Escape(text); {
_progressTask1.IsIndeterminate = true; _progressTask1.Description = Markup.Escape(text);
} _progressTask1.IsIndeterminate = true;
}; }
};
scanner.InitProgress += () => scanner.InitProgress += () => { _progressTask1 = ctx.AddTask("Progress"); };
{
_progressTask1 = ctx.AddTask("Progress");
};
scanner.EndProgress += () => scanner.EndProgress += () =>
{ {
_progressTask1?.StopTask(); _progressTask1?.StopTask();
_progressTask1 = null; _progressTask1 = null;
}; };
System.Console.CancelKeyPress += (_, e) => System.Console.CancelKeyPress += (_, e) =>
{ {
e.Cancel = true; e.Cancel = true;
scanner.Abort(); scanner.Abort();
}; };
results = scanner.Scan(); results = scanner.Scan();
}); });
@@ -244,8 +235,10 @@ sealed class MediaScanCommand : Command
results.UnreadableSectors.Count)}[/]"); results.UnreadableSectors.Count)}[/]");
if(results.UnreadableSectors.Count > 0) if(results.UnreadableSectors.Count > 0)
{
foreach(ulong bad in results.UnreadableSectors) foreach(ulong bad in results.UnreadableSectors)
AaruConsole.WriteLine(Localization.Core.Sector_0_could_not_be_read, bad); AaruConsole.WriteLine(Localization.Core.Sector_0_could_not_be_read, bad);
}
AaruConsole.WriteLine(); AaruConsole.WriteLine();
@@ -253,9 +246,11 @@ sealed class MediaScanCommand : Command
results.SeekMin < double.MaxValue || results.SeekMin < double.MaxValue ||
results.SeekMax > double.MinValue) results.SeekMax > double.MinValue)
{
AaruConsole. AaruConsole.
WriteLine(Localization.Core.Testing_0_seeks_longest_seek_took_1_ms_fastest_one_took_2_ms_3_ms_average, WriteLine(Localization.Core.Testing_0_seeks_longest_seek_took_1_ms_fastest_one_took_2_ms_3_ms_average,
results.SeekTimes, results.SeekMax, results.SeekMin, results.SeekTotal / 1000); results.SeekTimes, results.SeekMax, results.SeekMin, results.SeekTotal / 1000);
}
dev.Close(); dev.Close();

View File

@@ -72,27 +72,29 @@ sealed class RemoteCommand : Command
}); });
AaruConsole.DebugWriteLineEvent += (format, objects) => AaruConsole.DebugWriteLineEvent += (format, objects) =>
{ {
if(objects is null) if(objects is null)
stderrConsole.MarkupLine(format); stderrConsole.MarkupLine(format);
else else
stderrConsole.MarkupLine(format, objects); stderrConsole.MarkupLine(format, objects);
}; };
} }
if(verbose) if(verbose)
{
AaruConsole.WriteEvent += (format, objects) => AaruConsole.WriteEvent += (format, objects) =>
{ {
if(objects is null) if(objects is null)
AnsiConsole.Markup(format); AnsiConsole.Markup(format);
else else
AnsiConsole.Markup(format, objects); AnsiConsole.Markup(format, objects);
}; };
}
Statistics.AddCommand("remote"); Statistics.AddCommand("remote");
AaruConsole.DebugWriteLine(MODULE_NAME, "--debug={0}", debug); AaruConsole.DebugWriteLine(MODULE_NAME, "--debug={0}", debug);
AaruConsole.DebugWriteLine(MODULE_NAME, "--host={0}", host); AaruConsole.DebugWriteLine(MODULE_NAME, "--host={0}", host);
AaruConsole.DebugWriteLine(MODULE_NAME, "--verbose={0}", verbose); AaruConsole.DebugWriteLine(MODULE_NAME, "--verbose={0}", verbose);
try try

View File

@@ -84,28 +84,28 @@ class MainClass
return Gui.Main.Start(args); return Gui.Main.Start(args);
AaruConsole.WriteLineEvent += (format, objects) => AaruConsole.WriteLineEvent += (format, objects) =>
{ {
if(objects is null) if(objects is null)
AnsiConsole.MarkupLine(format); AnsiConsole.MarkupLine(format);
else else
AnsiConsole.MarkupLine(format, objects); AnsiConsole.MarkupLine(format, objects);
}; };
AaruConsole.WriteEvent += (format, objects) => AaruConsole.WriteEvent += (format, objects) =>
{ {
if(objects is null) if(objects is null)
AnsiConsole.Markup(format); AnsiConsole.Markup(format);
else else
AnsiConsole.Markup(format, objects); AnsiConsole.Markup(format, objects);
}; };
AaruConsole.ErrorWriteLineEvent += (format, objects) => AaruConsole.ErrorWriteLineEvent += (format, objects) =>
{ {
if(objects is null) if(objects is null)
stderrConsole.MarkupLine(format); stderrConsole.MarkupLine(format);
else else
stderrConsole.MarkupLine(format, objects); stderrConsole.MarkupLine(format, objects);
}; };
Settings.Settings.LoadSettings(); Settings.Settings.LoadSettings();
@@ -136,9 +136,11 @@ class MainClass
ExecuteSqlRaw("CREATE TABLE IF NOT EXISTS \"__EFMigrationsHistory\" (\"MigrationId\" TEXT PRIMARY KEY, \"ProductVersion\" TEXT)"); ExecuteSqlRaw("CREATE TABLE IF NOT EXISTS \"__EFMigrationsHistory\" (\"MigrationId\" TEXT PRIMARY KEY, \"ProductVersion\" TEXT)");
foreach(string migration in ctx.Database.GetPendingMigrations()) foreach(string migration in ctx.Database.GetPendingMigrations())
{
ctx.Database. ctx.Database.
ExecuteSqlRaw($"INSERT INTO \"__EFMigrationsHistory\" (MigrationId, ProductVersion) VALUES ('{ ExecuteSqlRaw($"INSERT INTO \"__EFMigrationsHistory\" (MigrationId, ProductVersion) VALUES ('{
migration}', '0.0.0')"); migration}', '0.0.0')");
}
ctx.SaveChanges(); ctx.SaveChanges();
} }
@@ -151,16 +153,18 @@ class MainClass
a.Revision, a.Revision,
a.Bus a.Bus
}).Where(a => a.Count() > 1).Distinct().Select(a => a.Key)) }).Where(a => a.Count() > 1).Distinct().Select(a => a.Key))
{
ctx.RemoveRange(ctx.SeenDevices. ctx.RemoveRange(ctx.SeenDevices.
Where(d => d.Manufacturer == duplicate.Manufacturer && d.Model == duplicate.Model && Where(d => d.Manufacturer == duplicate.Manufacturer && d.Model == duplicate.Model &&
d.Revision == duplicate.Revision && d.Bus == duplicate.Bus).Skip(1)); d.Revision == duplicate.Revision && d.Bus == duplicate.Bus).Skip(1));
}
// Remove nulls // Remove nulls
ctx.RemoveRange(ctx.SeenDevices.Where(d => d.Manufacturer == null && d.Model == null && d.Revision == null)); ctx.RemoveRange(ctx.SeenDevices.Where(d => d.Manufacturer == null && d.Model == null && d.Revision == null));
ctx.SaveChanges(); ctx.SaveChanges();
bool mainDbUpdate = false; var mainDbUpdate = false;
if(!File.Exists(Settings.Settings.MainDbPath)) if(!File.Exists(Settings.Settings.MainDbPath))
{ {
@@ -193,8 +197,8 @@ class MainClass
// GDPR level compliance does not match and there are no arguments or the arguments are neither GUI neither configure. // GDPR level compliance does not match and there are no arguments or the arguments are neither GUI neither configure.
if(Settings.Settings.Current.GdprCompliance < DicSettings.GDPR_LEVEL && if(Settings.Settings.Current.GdprCompliance < DicSettings.GDPR_LEVEL &&
(args.Length < 1 || (args.Length >= 1 && args[0].ToLowerInvariant() != "gui" && (args.Length < 1 || args.Length >= 1 && args[0].ToLowerInvariant() != "gui" &&
args[0].ToLowerInvariant() != "configure"))) args[0].ToLowerInvariant() != "configure"))
new ConfigureCommand().DoConfigure(true); new ConfigureCommand().DoConfigure(true);
Statistics.LoadStats(); Statistics.LoadStats();
@@ -203,20 +207,13 @@ class MainClass
var rootCommand = new RootCommand(); var rootCommand = new RootCommand();
rootCommand.AddGlobalOption(new Option<bool>(new[] rootCommand.AddGlobalOption(new Option<bool>(new[] { "--verbose", "-v" }, () => false,
{ UI.Shows_verbose_output));
"--verbose", "-v"
}, () => false, UI.Shows_verbose_output));
rootCommand.AddGlobalOption(new Option<bool>(new[] rootCommand.AddGlobalOption(new Option<bool>(new[] { "--debug", "-d" }, () => false,
{ UI.Shows_debug_output_from_plugins));
"--debug", "-d"
}, () => false, UI.Shows_debug_output_from_plugins));
Option<bool> pauseOption = new(new[] Option<bool> pauseOption = new(new[] { "--pause" }, () => false, UI.Pauses_before_exiting);
{
"--pause"
}, () => false, UI.Pauses_before_exiting);
rootCommand.AddGlobalOption(pauseOption); rootCommand.AddGlobalOption(pauseOption);

View File

@@ -3,8 +3,8 @@
"Aaru": { "Aaru": {
"commandName": "Project" "commandName": "Project"
}, },
"GUI" : { "GUI": {
"commandName" : "Project", "commandName": "Project",
"commandLineArgs": "gui -d" "commandLineArgs": "gui -d"
} }
} }

View File

@@ -1,17 +1,17 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<mime-info xmlns='http://www.freedesktop.org/standards/shared-mime-info'> <mime-info xmlns='http://www.freedesktop.org/standards/shared-mime-info'>
<mime-type type="application/vnd.aaruformat"> <mime-type type="application/vnd.aaruformat">
<comment>Aaru Image Format</comment> <comment>Aaru Image Format</comment>
<glob pattern="*.dicf"/> <glob pattern="*.dicf"/>
<glob pattern="*.dicformat"/> <glob pattern="*.dicformat"/>
<glob pattern="*.aaruf"/> <glob pattern="*.aaruf"/>
<glob pattern="*.aaruformat"/> <glob pattern="*.aaruformat"/>
<glob pattern="*.aif"/> <glob pattern="*.aif"/>
<alias type="application/x-aaru"/> <alias type="application/x-aaru"/>
<alias type="application/aaru"/> <alias type="application/aaru"/>
<magic> <magic>
<match type="string" offset="0" value="DICMFRMT"/> <match type="string" offset="0" value="DICMFRMT"/>
<match type="string" offset="0" value="AARUFRMT"/> <match type="string" offset="0" value="AARUFRMT"/>
</magic> </magic>
</mime-type> </mime-type>
</mime-info> </mime-info>

View File

@@ -3,76 +3,96 @@
## Added ## Added
### - Adler checksum ### - Adler checksum
- SSSE3 implementation if supported by running host. - SSSE3 implementation if supported by running host.
### - Apple Data Compression algorithm ### - Apple Data Compression algorithm
- Use faster native library if supported by running host. - Use faster native library if supported by running host.
### - Apple RLE compression algorithm ### - Apple RLE compression algorithm
- Use faster native library if supported by running host. - Use faster native library if supported by running host.
### - Apple Universal Disk Image Format ### - Apple Universal Disk Image Format
- Support for LZFSE compressed images (ULFO). - Support for LZFSE compressed images (ULFO).
- Support for XZ compressed images (ULMO). - Support for XZ compressed images (ULMO).
### - Atari Lynx cartridge dumps ### - Atari Lynx cartridge dumps
- Dumping by supported hardware. - Dumping by supported hardware.
- Support by `print`, `convert`, `info`, `entropy`, `checksum`, `compare` and `create sidecar` commands. - Support by `print`, `convert`, `info`, `entropy`, `checksum`, `compare` and `create sidecar` commands.
### - BZIP2 compression algorithm ### - BZIP2 compression algorithm
- Faster non-native implementation. - Faster non-native implementation.
- Use faster native library if supported by running host. - Use faster native library if supported by running host.
### - Console ### - Console
- Use new console system that allows to show colors, tables and progress bars in command line. - Use new console system that allows to show colors, tables and progress bars in command line.
### - CRC32 checksum ### - CRC32 checksum
- ARM specific instructions if supported by running host. - ARM specific instructions if supported by running host.
- PCLMUL implementation if supported by running host. - PCLMUL implementation if supported by running host.
### - CRC64 checksum ### - CRC64 checksum
- PCLMUL implementation if supported by running host. - PCLMUL implementation if supported by running host.
### - Dumping ### - Dumping
- Draw the MHDD log as an image. - Draw the MHDD log as an image.
- For most spiral media (CD/DVD/BD) draw a graph with the dump status. - For most spiral media (CD/DVD/BD) draw a graph with the dump status.
- For non-spiral media draw a block map. - For non-spiral media draw a block map.
### - FLAC compression algorithm ### - FLAC compression algorithm
- Use faster native library if supported by running host. - Use faster native library if supported by running host.
### - LZFSE compression algorithm ### - LZFSE compression algorithm
- Now available if native library is supported by running host. - Now available if native library is supported by running host.
### - LZMA compression algorithm ### - LZMA compression algorithm
- Use faster native library if supported by running host. - Use faster native library if supported by running host.
### - LZIP compression algorithm ### - LZIP compression algorithm
- Use faster native library if supported by running host. - Use faster native library if supported by running host.
### - NES / Famicom cartridge dumps ### - NES / Famicom cartridge dumps
- Dumping by supported hardware. - Dumping by supported hardware.
- Support by `print`, `convert`, `info`, `entropy`, `checksum`, `compare` and `create sidecar` commands. - Support by `print`, `convert`, `info`, `entropy`, `checksum`, `compare` and `create sidecar` commands.
- Support for iNES and NES 2.0 formats - Support for iNES and NES 2.0 formats
### - Nintendo 64 cartridge dumps ### - Nintendo 64 cartridge dumps
- Dumping by supported hardware. - Dumping by supported hardware.
- Support by `print`, `convert`, `info`, `entropy`, `checksum`, `compare` and `create sidecar` commands. - Support by `print`, `convert`, `info`, `entropy`, `checksum`, `compare` and `create sidecar` commands.
- Support for `z64` and `n64` formats. - Support for `z64` and `n64` formats.
### - Nintendo Game Boy cartridge dumps ### - Nintendo Game Boy cartridge dumps
- Dumping by supported hardware. - Dumping by supported hardware.
- Support by `print`, `convert`, `info`, `entropy`, `checksum`, `compare` and `create sidecar` commands. - Support by `print`, `convert`, `info`, `entropy`, `checksum`, `compare` and `create sidecar` commands.
### - Nintendo Game Boy Advance cartridge dumps ### - Nintendo Game Boy Advance cartridge dumps
- Dumping by supported hardware. - Dumping by supported hardware.
- Support by `print`, `convert`, `info`, `entropy`, `checksum`, `compare` and `create sidecar` commands. - Support by `print`, `convert`, `info`, `entropy`, `checksum`, `compare` and `create sidecar` commands.
### - Nintendo Game Boy Color cartridge dumps ### - Nintendo Game Boy Color cartridge dumps
- Dumping by supported hardware. - Dumping by supported hardware.
- Support by `print`, `convert`, `info`, `entropy`, `checksum`, `compare` and `create sidecar` commands. - Support by `print`, `convert`, `info`, `entropy`, `checksum`, `compare` and `create sidecar` commands.
### - Retrode cartridge dumping hardware ### - Retrode cartridge dumping hardware
- Dumping Nintendo 64 cartridges. - Dumping Nintendo 64 cartridges.
- Dumping Nintendo Game Boy cartridges. - Dumping Nintendo Game Boy cartridges.
- Dumping Nintendo Game Boy Advance cartridges. - Dumping Nintendo Game Boy Advance cartridges.
@@ -83,34 +103,42 @@
- Dumping Super Nintendo / Super Famicom cartridges. - Dumping Super Nintendo / Super Famicom cartridges.
### - Sega 32X cartridge dumps ### - Sega 32X cartridge dumps
- Support by `print`, `convert`, `info`, `entropy`, `checksum`, `compare` and `create sidecar` commands. - Support by `print`, `convert`, `info`, `entropy`, `checksum`, `compare` and `create sidecar` commands.
- Dumping by supported hardware. - Dumping by supported hardware.
### - Sega Game Gear cartridge dumps ### - Sega Game Gear cartridge dumps
- Support by `print`, `convert`, `info`, `entropy`, `checksum`, `compare` and `create sidecar` commands. - Support by `print`, `convert`, `info`, `entropy`, `checksum`, `compare` and `create sidecar` commands.
- Dumping by supported hardware. - Dumping by supported hardware.
### - Sega Master System / Mark III cartridge dumps ### - Sega Master System / Mark III cartridge dumps
- Support by `print`, `convert`, `info`, `entropy`, `checksum`, `compare` and `create sidecar` commands. - Support by `print`, `convert`, `info`, `entropy`, `checksum`, `compare` and `create sidecar` commands.
- Dumping by supported hardware. - Dumping by supported hardware.
### - Sega Mega Drive / Genesis cartridge dumps ### - Sega Mega Drive / Genesis cartridge dumps
- Full support for converting between `smd` and `bin` formats. - Full support for converting between `smd` and `bin` formats.
- Support by `print`, `convert`, `info`, `entropy`, `checksum`, `compare` and `create sidecar` commands. - Support by `print`, `convert`, `info`, `entropy`, `checksum`, `compare` and `create sidecar` commands.
- Dumping by supported hardware. - Dumping by supported hardware.
### - Sega Pico cartridge dumps ### - Sega Pico cartridge dumps
- Support by `print`, `convert`, `info`, `entropy`, `checksum`, `compare` and `create sidecar` commands. - Support by `print`, `convert`, `info`, `entropy`, `checksum`, `compare` and `create sidecar` commands.
- Dumping by supported hardware. - Dumping by supported hardware.
### - Super Nintendo / Super Famicom cartridge dumps ### - Super Nintendo / Super Famicom cartridge dumps
- Support by `print`, `convert`, `info`, `entropy`, `checksum`, `compare` and `create sidecar` commands. - Support by `print`, `convert`, `info`, `entropy`, `checksum`, `compare` and `create sidecar` commands.
- Dumping by supported hardware. - Dumping by supported hardware.
### - ZSTD compression algorithm ### - ZSTD compression algorithm
- Now available if native library is supported by running host. - Now available if native library is supported by running host.
## Changes ## Changes
- All used checksums now call a much faster native library if supported. - All used checksums now call a much faster native library if supported.
- CICM metadata XML sidecars are deprecated, new more complete JSON format is used instead. - CICM metadata XML sidecars are deprecated, new more complete JSON format is used instead.
- Remove FreeBSD support code. Use `aaruremote` for dumping devices connected to FreeBSD systems. - Remove FreeBSD support code. Use `aaruremote` for dumping devices connected to FreeBSD systems.
@@ -122,45 +150,57 @@
## Fixed ## Fixed
### - Aaru Image Format ### - Aaru Image Format
- DDT verification when its size on-image is bigger than 1MiB. - DDT verification when its size on-image is bigger than 1MiB.
- Parent block identifier in AaruFormat. - Parent block identifier in AaruFormat.
- Track indexes in when a disc contains a hidden track. - Track indexes in when a disc contains a hidden track.
### - Apple DOS filesystem ### - Apple DOS filesystem
- Calculation of file sizes - Calculation of file sizes
### - Apple Macintosh filesystem ### - Apple Macintosh filesystem
- Calculation of file sizes - Calculation of file sizes
### - BlindWrite 5/6/7 disc images ### - BlindWrite 5/6/7 disc images
- Opening split images in Windows - Opening split images in Windows
### - CDRWin cuesheet disc images ### - CDRWin cuesheet disc images
- Do not report ISRC as present if no tracks contain ISRC data. - Do not report ISRC as present if no tracks contain ISRC data.
### - Device report ### - Device report
- Add workaround for device report the AccessTek/Optorite DD0203 drive. - Add workaround for device report the AccessTek/Optorite DD0203 drive.
### - Devices ### - Devices
- Add transfer size to ATA(PI) IDENTIFY (PACKET) DEVICE commands as required by a recent change in the Linux kernel API. - Add transfer size to ATA(PI) IDENTIFY (PACKET) DEVICE commands as required by a recent change in the Linux kernel API.
### - Dumping ### - Dumping
- Correct offset fixing when trimming or re-reading errored audio sectors. - Correct offset fixing when trimming or re-reading errored audio sectors.
- Do not set INDEX 1 to a value higher than what the TOC already said. - Do not set INDEX 1 to a value higher than what the TOC already said.
### - FAT filesystem ### - FAT filesystem
- Fix that first 2 FAT entries are not considered part of the allocation ones, allocating two more. - Fix that first 2 FAT entries are not considered part of the allocation ones, allocating two more.
- Return current clusters when a file overflows the FAT. - Return current clusters when a file overflows the FAT.
### - ISO9660 filesystem ### - ISO9660 filesystem
- Do not try to interpret an 0-length Continuation Area. - Do not try to interpret an 0-length Continuation Area.
### - SGI Volume Header ### - SGI Volume Header
- Partition types not properly interpreted. - Partition types not properly interpreted.
## Changes ## Changes
- Do not allow dumping or converting to image formats that do not properly support hidden tracks when there is a hidden track in the media. - Do not allow dumping or converting to image formats that do not properly support hidden tracks when there is a hidden
track in the media.
- Update Newtonson.Json dependency due to security issues. - Update Newtonson.Json dependency due to security issues.
# [5.3.1] - 2022-03-06 # [5.3.1] - 2022-03-06
@@ -192,11 +232,13 @@
### - Dumping ### - Dumping
- Fix detecting errors from OS buffered reads in Linux. - Fix detecting errors from OS buffered reads in Linux.
- When dumping an SD/MMC card try to detect if OS buffered reads are failing, and max readable blocks using sequential commands, and downgrade accordingly. Now also detects cards that are totally unreadable. - When dumping an SD/MMC card try to detect if OS buffered reads are failing, and max readable blocks using sequential
commands, and downgrade accordingly. Now also detects cards that are totally unreadable.
### - ISO9660 filesystem ### - ISO9660 filesystem
- Do not break when an ISO9660/HighSierra/CD-i directory spans several sectors if we only have a partial last sector read. - Do not break when an ISO9660/HighSierra/CD-i directory spans several sectors if we only have a partial last sector
read.
- Do not try to decode empty path table in ISO9660/CD-i/HighSierra. - Do not try to decode empty path table in ISO9660/CD-i/HighSierra.
### - Media detection ### - Media detection