Merge pull request #564 from darkstar/archive-stuff

Add basic archive support to Aaru
This commit is contained in:
2021-03-05 14:20:21 +00:00
committed by GitHub
14 changed files with 370 additions and 14 deletions

View File

@@ -0,0 +1,113 @@
<?xml version="1.0" encoding="utf-8"?>
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<SchemaVersion>2.0</SchemaVersion>
<ProjectGuid>{282271D0-CCC2-4ED7-BA38-EC06A84BB974}</ProjectGuid>
<OutputType>Library</OutputType>
<RootNamespace>Aaru.Archives</RootNamespace>
<AssemblyName>Aaru.Archives</AssemblyName>
<ReleaseVersion>$(Version)</ReleaseVersion>
<EnableDefaultCompileItems>false</EnableDefaultCompileItems>
<GenerateAssemblyInfo>true</GenerateAssemblyInfo>
<Version>5.2.99.3380-alpha</Version>
<Company>Claunia.com</Company>
<Copyright>Copyright © 2011-2021 Natalia Portillo</Copyright>
<Product>Aaru Data Preservation Suite</Product>
<Title>Aaru.Archives</Title>
<ApplicationVersion>$(Version)</ApplicationVersion>
<TargetFramework>netcoreapp3.1</TargetFramework>
<LangVersion>8</LangVersion>
<Description>Archive implementations used by the Aaru Data Preservation Suite.</Description>
<PackageProjectUrl>https://github.com/aaru-dps/</PackageProjectUrl>
<PackageLicenseExpression>LGPL-2.1-only</PackageLicenseExpression>
<RepositoryUrl>https://github.com/aaru-dps/Aaru.Archives</RepositoryUrl>
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
<NeutralLanguage>en-US</NeutralLanguage>
<GenerateDocumentationFile>true</GenerateDocumentationFile>
<IncludeSymbols>true</IncludeSymbols>
<SymbolPackageFormat>snupkg</SymbolPackageFormat>
<Authors>Natalia Portillo &lt;claunia@claunia.com&gt;</Authors>
</PropertyGroup>
<PropertyGroup>
<NrtRevisionFormat>$(Version)+{chash:8}</NrtRevisionFormat>
<NrtResolveSimpleAttributes>true</NrtResolveSimpleAttributes>
<NrtShowRevision>true</NrtShowRevision>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug</OutputPath>
<DefineConstants>DEBUG;</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<ConsolePause>false</ConsolePause>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<Optimize>true</Optimize>
<OutputPath>bin\Release</OutputPath>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<ConsolePause>false</ConsolePause>
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
</ItemGroup>
<ItemGroup>
<Compile Include="Register.cs" />
</ItemGroup>
<ItemGroup>
<EmbeddedResource Include="..\LICENSE.LGPL">
<Link>LICENSE.LGPL</Link>
</EmbeddedResource>
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Aaru.CommonTypes\Aaru.CommonTypes.csproj" />
<ProjectReference Include="..\Aaru.Console\Aaru.Console.csproj">
<Project>{CCAA7AFE-C094-4D82-A66D-630DE8A3F545}</Project>
<Name>Aaru.Console</Name>
</ProjectReference>
<ProjectReference Include="..\Aaru.Helpers\Aaru.Helpers.csproj">
<Project>{F8BDF57B-1571-4CD0-84B3-B422088D359A}</Project>
<Name>Aaru.Helpers</Name>
</ProjectReference>
</ItemGroup>
<ItemGroup>
<PackageReference Include="SharpCompress" Version="0.24.0" />
<PackageReference Include="Unclassified.NetRevisionTask" Version="0.3.0" />
</ItemGroup>
<ProjectExtensions>
<MonoDevelop>
<Properties>
<Policies>
<TextStylePolicy FileWidth="120" TabWidth="4" IndentWidth="4" RemoveTrailingWhitespace="True" NoTabsAfterNonTabs="False" EolMarker="Native" TabsToSpaces="True" scope="text/x-csharp" />
<CSharpFormattingPolicy IndentBlock="True" IndentBraces="False" IndentSwitchSection="True" IndentSwitchCaseSection="True" LabelPositioning="OneLess" NewLinesForBracesInTypes="True" NewLinesForBracesInMethods="True" NewLinesForBracesInProperties="True" NewLinesForBracesInAccessors="True" NewLinesForBracesInAnonymousMethods="True" NewLinesForBracesInControlBlocks="True" NewLinesForBracesInAnonymousTypes="True" NewLinesForBracesInObjectCollectionArrayInitializers="True" NewLinesForBracesInLambdaExpressionBody="True" NewLineForElse="True" NewLineForCatch="True" NewLineForFinally="True" NewLineForMembersInObjectInit="True" NewLineForMembersInAnonymousTypes="True" NewLineForClausesInQuery="True" SpacingAfterMethodDeclarationName="False" SpaceWithinMethodDeclarationParenthesis="False" SpaceBetweenEmptyMethodDeclarationParentheses="False" SpaceAfterMethodCallName="False" SpaceWithinMethodCallParentheses="False" SpaceBetweenEmptyMethodCallParentheses="False" SpaceWithinExpressionParentheses="False" SpaceWithinCastParentheses="False" SpaceWithinOtherParentheses="False" SpaceAfterCast="False" SpacesIgnoreAroundVariableDeclaration="False" SpaceBeforeOpenSquareBracket="False" SpaceBetweenEmptySquareBrackets="False" SpaceWithinSquareBrackets="False" SpaceAfterColonInBaseTypeDeclaration="True" SpaceAfterComma="True" SpaceAfterDot="False" SpaceAfterSemicolonsInForStatement="True" SpaceBeforeColonInBaseTypeDeclaration="True" SpaceBeforeComma="False" SpaceBeforeDot="False" SpaceBeforeSemicolonsInForStatement="False" SpacingAroundBinaryOperator="Single" WrappingPreserveSingleLine="True" WrappingKeepStatementsOnSingleLine="True" PlaceSystemDirectiveFirst="True" SpaceAfterControlFlowStatementKeyword="False" scope="text/x-csharp" />
<StandardHeader IncludeInNewFiles="True" Text="/***************************************************************************&#xA;Aaru Data Preservation Suite&#xA;----------------------------------------------------------------------------&#xA; &#xA;Filename : ${FileName}&#xA;Author(s) : ${AuthorName} &lt;${AuthorEmail}&gt;&#xA;&#xA;Component : Component&#xA; &#xA;--[ Description ] ----------------------------------------------------------&#xA; &#xA; Description&#xA; &#xA;--[ License ] --------------------------------------------------------------&#xA; &#xA; This library is free software; you can redistribute it and/or modify&#xA; it under the terms of the GNU Lesser General Public License as&#xA; published by the Free Software Foundation; either version 2.1 of the&#xA; License, or (at your option) any later version.&#xA;&#xA; This library is distributed in the hope that it will be useful, but&#xA; WITHOUT ANY WARRANTY; without even the implied warranty of&#xA; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU&#xA; Lesser General Public License for more details.&#xA;&#xA; You should have received a copy of the GNU Lesser General Public&#xA; License along with this library; if not, see &lt;http://www.gnu.org/licenses/&gt;.&#xA;&#xA;----------------------------------------------------------------------------&#xA;Copyright © 2011-${Year} ${CopyrightHolder}&#xA;****************************************************************************/" />
</Policies>
</Properties>
</MonoDevelop>
</ProjectExtensions>
<PropertyGroup Condition="$(TargetFramework.StartsWith('net4')) and '$(OS)' == 'Unix'">
<!-- When compiling .NET SDK 2.0 projects targeting .NET 4.x on Mono using 'dotnet build' you -->
<!-- have to teach MSBuild where the Mono copy of the reference asssemblies is -->
<!-- Look in the standard install locations -->
<BaseFrameworkPathOverrideForMono Condition="'$(BaseFrameworkPathOverrideForMono)' == '' AND EXISTS('/Library/Frameworks/Mono.framework/Versions/Current/lib/mono')">/Library/Frameworks/Mono.framework/Versions/Current/lib/mono</BaseFrameworkPathOverrideForMono>
<BaseFrameworkPathOverrideForMono Condition="'$(BaseFrameworkPathOverrideForMono)' == '' AND EXISTS('/usr/lib/mono')">/usr/lib/mono</BaseFrameworkPathOverrideForMono>
<BaseFrameworkPathOverrideForMono Condition="'$(BaseFrameworkPathOverrideForMono)' == '' AND EXISTS('/usr/local/lib/mono')">/usr/local/lib/mono</BaseFrameworkPathOverrideForMono>
<!-- If we found Mono reference assemblies, then use them -->
<FrameworkPathOverride Condition="'$(BaseFrameworkPathOverrideForMono)' != '' AND '$(TargetFramework)' == 'net40'">$(BaseFrameworkPathOverrideForMono)/4.0-api</FrameworkPathOverride>
<FrameworkPathOverride Condition="'$(BaseFrameworkPathOverrideForMono)' != '' AND '$(TargetFramework)' == 'net45'">$(BaseFrameworkPathOverrideForMono)/4.5-api</FrameworkPathOverride>
<FrameworkPathOverride Condition="'$(BaseFrameworkPathOverrideForMono)' != '' AND '$(TargetFramework)' == 'net451'">$(BaseFrameworkPathOverrideForMono)/4.5.1-api</FrameworkPathOverride>
<FrameworkPathOverride Condition="'$(BaseFrameworkPathOverrideForMono)' != '' AND '$(TargetFramework)' == 'net452'">$(BaseFrameworkPathOverrideForMono)/4.5.2-api</FrameworkPathOverride>
<FrameworkPathOverride Condition="'$(BaseFrameworkPathOverrideForMono)' != '' AND '$(TargetFramework)' == 'net46'">$(BaseFrameworkPathOverrideForMono)/4.6-api</FrameworkPathOverride>
<FrameworkPathOverride Condition="'$(BaseFrameworkPathOverrideForMono)' != '' AND '$(TargetFramework)' == 'net461'">$(BaseFrameworkPathOverrideForMono)/4.6.1-api</FrameworkPathOverride>
<FrameworkPathOverride Condition="'$(BaseFrameworkPathOverrideForMono)' != '' AND '$(TargetFramework)' == 'net462'">$(BaseFrameworkPathOverrideForMono)/4.6.2-api</FrameworkPathOverride>
<FrameworkPathOverride Condition="'$(BaseFrameworkPathOverrideForMono)' != '' AND '$(TargetFramework)' == 'net47'">$(BaseFrameworkPathOverrideForMono)/4.7-api</FrameworkPathOverride>
<FrameworkPathOverride Condition="'$(BaseFrameworkPathOverrideForMono)' != '' AND '$(TargetFramework)' == 'net471'">$(BaseFrameworkPathOverrideForMono)/4.7.1-api</FrameworkPathOverride>
<EnableFrameworkPathOverride Condition="'$(BaseFrameworkPathOverrideForMono)' != ''">true</EnableFrameworkPathOverride>
<!-- Add the Facades directory. Not sure how else to do this. Necessary at least for .NET 4.5 -->
<AssemblySearchPaths Condition="'$(BaseFrameworkPathOverrideForMono)' != ''">$(FrameworkPathOverride)/Facades;$(AssemblySearchPaths)</AssemblySearchPaths>
</PropertyGroup>
</Project>

75
Aaru.Archives/Register.cs Normal file
View File

@@ -0,0 +1,75 @@
// /***************************************************************************
// Aaru Data Preservation Suite
// ----------------------------------------------------------------------------
//
// Filename : Register.cs
// Author(s) : Michael Drüing <michael@drueing.de>
// Natalia Portillo <claunia@claunia.com>
//
// Component : Core algorithms.
//
// --[ Description ] ----------------------------------------------------------
//
// Registers all plugins in this assembly.
//
// --[ License ] --------------------------------------------------------------
//
// Permission is hereby granted, free of charge, to any person obtaining a
// copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
//
// The above copyright notice and this permission notice shall be included
// in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
// CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
// TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
// SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
// ----------------------------------------------------------------------------
// Copyright © 2021 Michael Drüing
// Copyright © 2011-2021 Natalia Portillo
// ****************************************************************************/
using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using Aaru.CommonTypes.Interfaces;
namespace Aaru.Archives
{
public sealed class Register : IPluginRegister
{
public List<Type> GetAllChecksumPlugins() => null;
public List<Type> GetAllFilesystemPlugins() => null;
public List<Type> GetAllFilterPlugins() => null;
public List<Type> GetAllFloppyImagePlugins() => null;
public List<Type> GetAllMediaImagePlugins() => null;
public List<Type> GetAllPartitionPlugins() => null;
public List<Type> GetAllReadOnlyFilesystemPlugins() => null;
public List<Type> GetAllWritableFloppyImagePlugins() => null;
public List<Type> GetAllWritableImagePlugins() => null;
public List<Type> GetAllArchivePlugins() => Assembly.GetExecutingAssembly().GetTypes().
Where(t => t.GetInterfaces().
Contains(typeof(IArchive
))).Where(t => t.IsClass).
ToList();
}
}

View File

@@ -144,6 +144,7 @@
<Compile Include="Logging\DumpLog.cs" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Aaru.Archives\Aaru.Archives.csproj" />
<ProjectReference Include="..\Aaru.Console\Aaru.Console.csproj">
<Project>{ccaa7afe-c094-4d82-a66d-630de8a3f545}</Project>
<Name>Aaru.Console</Name>

View File

@@ -49,12 +49,14 @@ namespace Aaru.Core
IPluginRegister filesystemsRegister = new Aaru.Filesystems.Register();
IPluginRegister filtersRegister = new Filters.Register();
IPluginRegister partitionsRegister = new Aaru.Partitions.Register();
IPluginRegister archiveRegister = new Aaru.Archives.Register();
instance.AddPlugins(checksumRegister);
instance.AddPlugins(imagesRegister);
instance.AddPlugins(filesystemsRegister);
instance.AddPlugins(filtersRegister);
instance.AddPlugins(partitionsRegister);
instance.AddPlugins(archiveRegister);
return instance;
}

View File

@@ -70,5 +70,7 @@ namespace Aaru.Filesystems
public List<Type> GetAllWritableFloppyImagePlugins() => null;
public List<Type> GetAllWritableImagePlugins() => null;
public List<Type> GetAllArchivePlugins() => null;
}
}

View File

@@ -65,5 +65,7 @@ namespace Aaru.Filters
public List<Type> GetAllWritableFloppyImagePlugins() => null;
public List<Type> GetAllWritableImagePlugins() => null;
public List<Type> GetAllArchivePlugins() => null;
}
}

View File

@@ -76,5 +76,7 @@ namespace Aaru.DiscImages
Where(t => t.GetInterfaces().
Contains(typeof(IWritableImage))).
Where(t => t.IsClass).ToList();
public List<Type> GetAllArchivePlugins() => null;
}
}

View File

@@ -66,5 +66,7 @@ namespace Aaru.Partitions
public List<Type> GetAllWritableFloppyImagePlugins() => null;
public List<Type> GetAllWritableImagePlugins() => null;
public List<Type> GetAllArchivePlugins() => null;
}
}

View File

@@ -34,17 +34,19 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Aaru.Database", "Aaru.Datab
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Aaru.Dto", "Aaru.Dto\Aaru.Dto.csproj", "{F4399FF5-9BD0-475A-9EA7-3DAE45291FE2}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Aaru.Gui", "Aaru.Gui\Aaru.Gui.csproj", "{18C4C44D-2562-4B6D-8181-32D7EA067D96}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Aaru.Gui", "Aaru.Gui\Aaru.Gui.csproj", "{18C4C44D-2562-4B6D-8181-32D7EA067D96}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CUETools.Codecs", "cuetools.net\CUETools.Codecs\CUETools.Codecs.csproj", "{D1F69B02-A6A4-4EF2-A916-815BACC18F71}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "CUETools.Codecs", "cuetools.net\CUETools.Codecs\CUETools.Codecs.csproj", "{D1F69B02-A6A4-4EF2-A916-815BACC18F71}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Aaru.Tests", "Aaru.Tests\Aaru.Tests.csproj", "{B2A2CCF8-150D-4A00-BCB5-1B0CBCFA95D5}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Aaru.Tests", "Aaru.Tests\Aaru.Tests.csproj", "{B2A2CCF8-150D-4A00-BCB5-1B0CBCFA95D5}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Aaru.Tests.Devices", "Aaru.Tests.Devices\Aaru.Tests.Devices.csproj", "{A40662EB-D202-46A4-AB41-9C32ADE6D6B5}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Aaru.Tests.Devices", "Aaru.Tests.Devices\Aaru.Tests.Devices.csproj", "{A40662EB-D202-46A4-AB41-9C32ADE6D6B5}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CUETools.Codecs.Flake", "cuetools.net\CUETools.Codecs.Flake\CUETools.Codecs.Flake.csproj", "{69FAC887-A3DE-4C23-84A5-9C5F64E4C3E1}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "CUETools.Codecs.Flake", "cuetools.net\CUETools.Codecs.Flake\CUETools.Codecs.Flake.csproj", "{69FAC887-A3DE-4C23-84A5-9C5F64E4C3E1}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Aaru.Decryption", "Aaru.Decryption\Aaru.Decryption.csproj", "{B609D333-80C5-4503-BF46-8B9B91F04E97}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Aaru.Decryption", "Aaru.Decryption\Aaru.Decryption.csproj", "{B609D333-80C5-4503-BF46-8B9B91F04E97}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Aaru.Archives", "Aaru.Archives\Aaru.Archives.csproj", "{282271D0-CCC2-4ED7-BA38-EC06A84BB974}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
@@ -230,6 +232,14 @@ Global
{B609D333-80C5-4503-BF46-8B9B91F04E97}.Release|Any CPU.Build.0 = Release|Any CPU
{B609D333-80C5-4503-BF46-8B9B91F04E97}.Release|x86.ActiveCfg = Release|Any CPU
{B609D333-80C5-4503-BF46-8B9B91F04E97}.Release|x86.Build.0 = Release|Any CPU
{282271D0-CCC2-4ED7-BA38-EC06A84BB974}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{282271D0-CCC2-4ED7-BA38-EC06A84BB974}.Debug|Any CPU.Build.0 = Debug|Any CPU
{282271D0-CCC2-4ED7-BA38-EC06A84BB974}.Debug|x86.ActiveCfg = Debug|Any CPU
{282271D0-CCC2-4ED7-BA38-EC06A84BB974}.Debug|x86.Build.0 = Debug|Any CPU
{282271D0-CCC2-4ED7-BA38-EC06A84BB974}.Release|Any CPU.ActiveCfg = Release|Any CPU
{282271D0-CCC2-4ED7-BA38-EC06A84BB974}.Release|Any CPU.Build.0 = Release|Any CPU
{282271D0-CCC2-4ED7-BA38-EC06A84BB974}.Release|x86.ActiveCfg = Release|Any CPU
{282271D0-CCC2-4ED7-BA38-EC06A84BB974}.Release|x86.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE

View File

@@ -84,6 +84,8 @@
<Compile Include="Commands\Media\MediaFamily.cs" />
<Compile Include="Commands\Media\Info.cs" />
<Compile Include="Commands\Media\Scan.cs" />
<Compile Include="Commands\Archive\ArchiveFamily.cs" />
<Compile Include="Commands\Archive\Info.cs" />
<Compile Include="Commands\Remote.cs" />
<Compile Include="Main.cs" />
<Compile Include="Commands\Configure.cs" />

View File

@@ -0,0 +1,48 @@
// /***************************************************************************
// Aaru Data Preservation Suite
// ----------------------------------------------------------------------------
//
// Filename : ArchiveFamily.cs
// Author(s) : Michael Drüing <michael@drueing.de>
//
// Component : Commands.
//
// --[ Description ] ----------------------------------------------------------
//
// Implements the 'archive' command family.
//
// --[ License ] --------------------------------------------------------------
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as
// published by the Free Software Foundation, either version 3 of the
// License, or (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
//
// ----------------------------------------------------------------------------
// Copyright © 2021 Michael Drüing
// Copyright © 2011-2021 Natalia Portillo
// ****************************************************************************/
using System.CommandLine;
namespace Aaru.Commands.Archive
{
internal sealed class ArchiveFamily : Command
{
internal ArchiveFamily() : base("archive",
"Commands to manage archive files")
{
AddAlias("arc");
AddCommand(new ArchiveInfoCommand());
}
}
}

View File

@@ -0,0 +1,81 @@
// /***************************************************************************
// Aaru Data Preservation Suite
// ----------------------------------------------------------------------------
//
// Filename : Info.cs
// Author(s) : Michael Drüing <michael@drueing.de>
//
// Component : Commands.
//
// --[ Description ] ----------------------------------------------------------
//
// Implements the 'info' command.
//
// --[ License ] --------------------------------------------------------------
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as
// published by the Free Software Foundation, either version 3 of the
// License, or (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
//
// ----------------------------------------------------------------------------
// Copyright © 2021 Michael Drüing
// Copyright © 2011-2021 Natalia Portillo
// ****************************************************************************/
using System;
using System.CommandLine;
using System.CommandLine.Invocation;
using Aaru.CommonTypes;
using Aaru.CommonTypes.Enums;
using Aaru.CommonTypes.Interfaces;
using Aaru.Console;
using Aaru.Core;
namespace Aaru.Commands.Archive
{
internal sealed class ArchiveInfoCommand : Command
{
public ArchiveInfoCommand() : base("info",
"Identifies an archive file and shows information about it.")
{
AddArgument(new Argument<string>
{
Arity = ArgumentArity.ExactlyOne,
Description = "Archive file path",
Name = "archive-path"
});
Handler = CommandHandler.Create(GetType().GetMethod(nameof(Invoke)));
}
public static int Invoke(bool debug, bool verbose, string imagePath)
{
MainClass.PrintCopyright();
if(debug)
AaruConsole.DebugWriteLineEvent += System.Console.Error.WriteLine;
if(verbose)
AaruConsole.VerboseWriteLineEvent += System.Console.WriteLine;
Statistics.AddCommand("archive-info");
AaruConsole.DebugWriteLine("Analyze command", "--debug={0}", debug);
AaruConsole.DebugWriteLine("Analyze command", "--input={0}", imagePath);
AaruConsole.DebugWriteLine("Analyze command", "--verbose={0}", verbose);
/* TODO: This is just a stub for now */
return (int)ErrorNumber.NoError;
}
}
}

View File

@@ -147,6 +147,20 @@ namespace Aaru.Commands
else
AaruConsole.WriteLine(kvp.Value.Name);
AaruConsole.WriteLine();
AaruConsole.WriteLine("Supported archive formats ({0}):",
plugins.Archives.Count);
if(verbose)
AaruConsole.VerboseWriteLine("GUID\t\t\t\t\tPlugin");
foreach(KeyValuePair<string, IArchive> kvp in plugins.Archives)
if(verbose)
AaruConsole.VerboseWriteLine("{0}\t{1}", kvp.Value.Id, kvp.Value.Name);
else
AaruConsole.WriteLine(kvp.Value.Name);
return (int)ErrorNumber.NoError;
}
}

View File

@@ -43,6 +43,7 @@ using Aaru.Commands.Device;
using Aaru.Commands.Filesystem;
using Aaru.Commands.Image;
using Aaru.Commands.Media;
using Aaru.Commands.Archive;
using Aaru.Console;
using Aaru.Core;
using Aaru.Database;
@@ -185,6 +186,7 @@ namespace Aaru
rootCommand.AddCommand(new FilesystemFamily());
rootCommand.AddCommand(new ImageFamily());
rootCommand.AddCommand(new MediaFamily());
rootCommand.AddCommand(new ArchiveFamily());
rootCommand.AddCommand(new ConfigureCommand(false, false));
rootCommand.AddCommand(new FormatsCommand());