mirror of
https://github.com/aaru-dps/Aaru.git
synced 2025-12-16 19:24:25 +00:00
Add filesystem namespaces.
This commit is contained in:
1
.idea/.idea.DiscImageChef/.idea/contentModel.xml
generated
1
.idea/.idea.DiscImageChef/.idea/contentModel.xml
generated
@@ -38,6 +38,7 @@
|
||||
<e p="ImageInfo.cs" t="Include" />
|
||||
<e p="ListDevices.cs" t="Include" />
|
||||
<e p="ListEncodings.cs" t="Include" />
|
||||
<e p="ListNamespaces.cs" t="Include" />
|
||||
<e p="ListOptions.cs" t="Include" />
|
||||
<e p="Ls.cs" t="Include" />
|
||||
<e p="MediaInfo.cs" t="Include" />
|
||||
|
||||
@@ -54,6 +54,8 @@ namespace DiscImageChef.CommonTypes.Interfaces
|
||||
/// </summary>
|
||||
IEnumerable<(string name, Type type, string description)> SupportedOptions { get; }
|
||||
|
||||
Dictionary<string, string> Namespaces { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Initializates whatever internal structures the filesystem plugin needs to be able to read files and directories
|
||||
/// from the filesystem.
|
||||
@@ -62,8 +64,9 @@ namespace DiscImageChef.CommonTypes.Interfaces
|
||||
/// <param name="partition"></param>
|
||||
/// <param name="encoding">Which encoding to use for this filesystem.</param>
|
||||
/// <param name="options">Dictionary of key=value pairs containing options to pass to the filesystem</param>
|
||||
Errno Mount(IMediaImage imagePlugin, Partition partition, Encoding encoding,
|
||||
Dictionary<string, string> options);
|
||||
/// <param name="namespace">Filename namespace</param>
|
||||
Errno Mount(IMediaImage imagePlugin, Partition partition, Encoding encoding, Dictionary<string, string> options,
|
||||
string @namespace);
|
||||
|
||||
/// <summary>
|
||||
/// Frees all internal structures created by
|
||||
|
||||
@@ -61,6 +61,8 @@ namespace DiscImageChef.Filesystems.AppleDOS
|
||||
public IEnumerable<(string name, Type type, string description)> SupportedOptions =>
|
||||
new (string name, Type type, string description)[] { };
|
||||
|
||||
public Dictionary<string, string> Namespaces => null;
|
||||
|
||||
static Dictionary<string, string> GetDefaultOptions() =>
|
||||
new Dictionary<string, string> {{"debug", false.ToString()}};
|
||||
|
||||
|
||||
@@ -48,7 +48,7 @@ namespace DiscImageChef.Filesystems.AppleDOS
|
||||
/// Mounts an Apple DOS filesystem
|
||||
/// </summary>
|
||||
public Errno Mount(IMediaImage imagePlugin, Partition partition, Encoding encoding,
|
||||
Dictionary<string, string> options)
|
||||
Dictionary<string, string> options, string @namespace)
|
||||
{
|
||||
device = imagePlugin;
|
||||
start = partition.Start;
|
||||
|
||||
@@ -72,6 +72,8 @@ namespace DiscImageChef.Filesystems.AppleMFS
|
||||
public IEnumerable<(string name, Type type, string description)> SupportedOptions =>
|
||||
new (string name, Type type, string description)[] { };
|
||||
|
||||
public Dictionary<string, string> Namespaces => null;
|
||||
|
||||
static Dictionary<string, string> GetDefaultOptions() =>
|
||||
new Dictionary<string, string> {{"debug", false.ToString()}};
|
||||
}
|
||||
|
||||
@@ -45,7 +45,7 @@ namespace DiscImageChef.Filesystems.AppleMFS
|
||||
public partial class AppleMFS
|
||||
{
|
||||
public Errno Mount(IMediaImage imagePlugin, Partition partition, Encoding encoding,
|
||||
Dictionary<string, string> options)
|
||||
Dictionary<string, string> options, string @namespace)
|
||||
{
|
||||
device = imagePlugin;
|
||||
partitionStart = partition.Start;
|
||||
|
||||
@@ -112,6 +112,7 @@ namespace DiscImageChef.Filesystems.CPM
|
||||
/// If <see cref="Identify" /> thinks this is a CP/M filesystem, this is the definition for it
|
||||
/// </summary>
|
||||
CpmDefinition workingDefinition;
|
||||
IReadOnlyFilesystem readOnlyFilesystemImplementation;
|
||||
|
||||
public FileSystemType XmlFsType { get; private set; }
|
||||
public Encoding Encoding { get; private set; }
|
||||
@@ -122,6 +123,8 @@ namespace DiscImageChef.Filesystems.CPM
|
||||
public IEnumerable<(string name, Type type, string description)> SupportedOptions =>
|
||||
new (string name, Type type, string description)[] { };
|
||||
|
||||
public Dictionary<string, string> Namespaces => null;
|
||||
|
||||
static Dictionary<string, string> GetDefaultOptions() =>
|
||||
new Dictionary<string, string> {{"debug", false.ToString()}};
|
||||
}
|
||||
|
||||
@@ -51,7 +51,7 @@ namespace DiscImageChef.Filesystems.CPM
|
||||
partial class CPM
|
||||
{
|
||||
public Errno Mount(IMediaImage imagePlugin, Partition partition, Encoding encoding,
|
||||
Dictionary<string, string> options)
|
||||
Dictionary<string, string> options, string @namespace)
|
||||
{
|
||||
device = imagePlugin;
|
||||
this.partition = partition;
|
||||
|
||||
@@ -81,6 +81,8 @@ namespace DiscImageChef.Filesystems.FATX
|
||||
public IEnumerable<(string name, Type type, string description)> SupportedOptions =>
|
||||
new (string name, Type type, string description)[] { };
|
||||
|
||||
public Dictionary<string, string> Namespaces => null;
|
||||
|
||||
static Dictionary<string, string> GetDefaultOptions() =>
|
||||
new Dictionary<string, string> {{"debug", false.ToString()}};
|
||||
}
|
||||
|
||||
@@ -47,7 +47,7 @@ namespace DiscImageChef.Filesystems.FATX
|
||||
public partial class XboxFatPlugin
|
||||
{
|
||||
public Errno Mount(IMediaImage imagePlugin, Partition partition, Encoding encoding,
|
||||
Dictionary<string, string> options)
|
||||
Dictionary<string, string> options, string @namespace)
|
||||
{
|
||||
Encoding = Encoding.GetEncoding("iso-8859-15");
|
||||
littleEndian = true;
|
||||
|
||||
@@ -61,6 +61,13 @@ namespace DiscImageChef.Filesystems.LisaFS
|
||||
public IEnumerable<(string name, Type type, string description)> SupportedOptions =>
|
||||
new (string name, Type type, string description)[] { };
|
||||
|
||||
public Dictionary<string, string> Namespaces =>
|
||||
new Dictionary<string, string>
|
||||
{
|
||||
{"workshop", "Filenames as shown by the Lisa Pascal Workshop (default)"},
|
||||
{"office", "Filenames as shown by the Lisa Office System (not yet implemented)"}
|
||||
};
|
||||
|
||||
static Dictionary<string, string> GetDefaultOptions() =>
|
||||
new Dictionary<string, string> {{"debug", false.ToString()}};
|
||||
|
||||
|
||||
@@ -50,7 +50,7 @@ namespace DiscImageChef.Filesystems.LisaFS
|
||||
/// Mounts an Apple Lisa filesystem
|
||||
/// </summary>
|
||||
public Errno Mount(IMediaImage imagePlugin, Partition partition, Encoding encoding,
|
||||
Dictionary<string, string> options)
|
||||
Dictionary<string, string> options, string @namespace)
|
||||
{
|
||||
try
|
||||
{
|
||||
|
||||
@@ -45,7 +45,7 @@ namespace DiscImageChef.Filesystems.UCSDPascal
|
||||
public partial class PascalPlugin
|
||||
{
|
||||
public Errno Mount(IMediaImage imagePlugin, Partition partition, Encoding encoding,
|
||||
Dictionary<string, string> options)
|
||||
Dictionary<string, string> options, string @namespace)
|
||||
{
|
||||
device = imagePlugin;
|
||||
Encoding = encoding ?? new Apple2();
|
||||
|
||||
@@ -77,6 +77,8 @@ namespace DiscImageChef.Filesystems.UCSDPascal
|
||||
public IEnumerable<(string name, Type type, string description)> SupportedOptions =>
|
||||
new (string name, Type type, string description)[] { };
|
||||
|
||||
public Dictionary<string, string> Namespaces => null;
|
||||
|
||||
static Dictionary<string, string> GetDefaultOptions() =>
|
||||
new Dictionary<string, string> {{"debug", false.ToString()}};
|
||||
}
|
||||
|
||||
@@ -336,7 +336,7 @@ namespace DiscImageChef.Gui.Forms
|
||||
{
|
||||
Errno error =
|
||||
fsPlugin.Mount(imageFormat, partition, null,
|
||||
new Dictionary<string, string>());
|
||||
new Dictionary<string, string>(), null);
|
||||
|
||||
if(error != Errno.NoError) fsPlugin = null;
|
||||
}
|
||||
@@ -395,9 +395,8 @@ namespace DiscImageChef.Gui.Forms
|
||||
|
||||
if(fsPlugin != null)
|
||||
{
|
||||
Errno error =
|
||||
fsPlugin.Mount(imageFormat, wholePart, null,
|
||||
new Dictionary<string, string>());
|
||||
Errno error = fsPlugin.Mount(imageFormat, wholePart, null,
|
||||
new Dictionary<string, string>(), null);
|
||||
|
||||
if(error != Errno.NoError) fsPlugin = null;
|
||||
}
|
||||
|
||||
@@ -67,7 +67,7 @@ namespace DiscImageChef.Tests.Filesystems
|
||||
Size = image.Info.Sectors * image.Info.SectorSize
|
||||
};
|
||||
|
||||
Errno error = fs.Mount(image, wholePart, null, null);
|
||||
Errno error = fs.Mount(image, wholePart, null, null, null);
|
||||
Assert.AreEqual(Errno.NoError, error);
|
||||
}
|
||||
|
||||
@@ -269,7 +269,7 @@ namespace DiscImageChef.Tests.Filesystems
|
||||
List<Partition> partitions = Core.Partitions.GetAll(image);
|
||||
Assert.AreEqual(2, partitions.Count);
|
||||
dataPartition = partitions[1];
|
||||
Errno error = fs.Mount(image, dataPartition, null, null);
|
||||
Errno error = fs.Mount(image, dataPartition, null, null, null);
|
||||
Assert.AreEqual(Errno.NoError, error);
|
||||
}
|
||||
|
||||
|
||||
@@ -50,6 +50,7 @@ namespace DiscImageChef.Commands
|
||||
string encodingName;
|
||||
bool extractXattrs;
|
||||
string inputFile;
|
||||
string @namespace;
|
||||
string outputDir;
|
||||
string pluginOptions;
|
||||
bool showHelp;
|
||||
@@ -74,6 +75,7 @@ namespace DiscImageChef.Commands
|
||||
s => outputDir = s
|
||||
},
|
||||
{"xattrs|x", "Extract extended attributes if present.", b => extractXattrs = b != null},
|
||||
{"namespace|n=", "Namespace to use for filenames.", s => @namespace = s},
|
||||
{"help|h|?", "Show this message and exit.", v => showHelp = v != null}
|
||||
};
|
||||
}
|
||||
@@ -230,7 +232,7 @@ namespace DiscImageChef.Commands
|
||||
.GetConstructor(Type.EmptyTypes)
|
||||
?.Invoke(new object[] { });
|
||||
|
||||
error = fs.Mount(imageFormat, partitions[i], encoding, parsedOptions);
|
||||
error = fs.Mount(imageFormat, partitions[i], encoding, parsedOptions, @namespace);
|
||||
if(error == Errno.NoError)
|
||||
{
|
||||
string volumeName =
|
||||
@@ -254,7 +256,7 @@ namespace DiscImageChef.Commands
|
||||
IReadOnlyFilesystem fs = (IReadOnlyFilesystem)plugin
|
||||
.GetType().GetConstructor(Type.EmptyTypes)
|
||||
?.Invoke(new object[] { });
|
||||
error = fs.Mount(imageFormat, partitions[i], encoding, parsedOptions);
|
||||
error = fs.Mount(imageFormat, partitions[i], encoding, parsedOptions, @namespace);
|
||||
if(error == Errno.NoError)
|
||||
{
|
||||
string volumeName = string.IsNullOrEmpty(fs.XmlFsType.VolumeName)
|
||||
@@ -290,7 +292,7 @@ namespace DiscImageChef.Commands
|
||||
IReadOnlyFilesystem fs = (IReadOnlyFilesystem)plugin
|
||||
.GetType().GetConstructor(Type.EmptyTypes)
|
||||
?.Invoke(new object[] { });
|
||||
error = fs.Mount(imageFormat, wholePart, encoding, parsedOptions);
|
||||
error = fs.Mount(imageFormat, wholePart, encoding, parsedOptions, @namespace);
|
||||
if(error == Errno.NoError)
|
||||
{
|
||||
string volumeName = string.IsNullOrEmpty(fs.XmlFsType.VolumeName)
|
||||
@@ -310,7 +312,7 @@ namespace DiscImageChef.Commands
|
||||
DicConsole.WriteLine($"Identified by {plugin.Name}.");
|
||||
IReadOnlyFilesystem fs =
|
||||
(IReadOnlyFilesystem)plugin.GetType().GetConstructor(Type.EmptyTypes)?.Invoke(new object[] { });
|
||||
error = fs.Mount(imageFormat, wholePart, encoding, parsedOptions);
|
||||
error = fs.Mount(imageFormat, wholePart, encoding, parsedOptions, @namespace);
|
||||
if(error == Errno.NoError)
|
||||
{
|
||||
string volumeName = string.IsNullOrEmpty(fs.XmlFsType.VolumeName)
|
||||
|
||||
103
DiscImageChef/Commands/ListNamespaces.cs
Normal file
103
DiscImageChef/Commands/ListNamespaces.cs
Normal file
@@ -0,0 +1,103 @@
|
||||
// /***************************************************************************
|
||||
// The Disc Image Chef
|
||||
// ----------------------------------------------------------------------------
|
||||
//
|
||||
// Filename : ListOptions.cs
|
||||
// Author(s) : Natalia Portillo <claunia@claunia.com>
|
||||
//
|
||||
// Component : Verbs.
|
||||
//
|
||||
// --[ Description ] ----------------------------------------------------------
|
||||
//
|
||||
// Lists all options supported by read-only filesystems.
|
||||
//
|
||||
// --[ 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 © 2011-2019 Natalia Portillo
|
||||
// ****************************************************************************/
|
||||
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using DiscImageChef.CommonTypes;
|
||||
using DiscImageChef.CommonTypes.Enums;
|
||||
using DiscImageChef.CommonTypes.Interfaces;
|
||||
using DiscImageChef.Console;
|
||||
using DiscImageChef.Core;
|
||||
using Mono.Options;
|
||||
|
||||
namespace DiscImageChef.Commands
|
||||
{
|
||||
class ListNamespacesCommand : Command
|
||||
{
|
||||
bool showHelp;
|
||||
|
||||
public ListNamespacesCommand() : base("list-namespaces",
|
||||
"Lists all namespaces supported by read-only filesystems.")
|
||||
{
|
||||
Options = new OptionSet
|
||||
{
|
||||
$"{MainClass.AssemblyTitle} {MainClass.AssemblyVersion?.InformationalVersion}",
|
||||
$"{MainClass.AssemblyCopyright}",
|
||||
"",
|
||||
$"usage: DiscImageChef {Name}",
|
||||
"",
|
||||
Help,
|
||||
{"help|h|?", "Show this message and exit.", v => showHelp = v != null}
|
||||
};
|
||||
}
|
||||
|
||||
public override int Invoke(IEnumerable<string> arguments)
|
||||
{
|
||||
List<string> extra = Options.Parse(arguments);
|
||||
|
||||
if(showHelp)
|
||||
{
|
||||
Options.WriteOptionDescriptions(CommandSet.Out);
|
||||
return (int)ErrorNumber.HelpRequested;
|
||||
}
|
||||
|
||||
MainClass.PrintCopyright();
|
||||
if(MainClass.Debug) DicConsole.DebugWriteLineEvent += System.Console.Error.WriteLine;
|
||||
if(MainClass.Verbose) DicConsole.VerboseWriteLineEvent += System.Console.WriteLine;
|
||||
|
||||
if(extra.Count > 0)
|
||||
{
|
||||
DicConsole.ErrorWriteLine("Too many arguments.");
|
||||
return (int)ErrorNumber.UnexpectedArgumentCount;
|
||||
}
|
||||
|
||||
DicConsole.DebugWriteLine("List-Namespaces command", "--debug={0}", MainClass.Debug);
|
||||
DicConsole.DebugWriteLine("List-Namespaces command", "--verbose={0}", MainClass.Verbose);
|
||||
Statistics.AddCommand("list-namespaces");
|
||||
|
||||
PluginBase plugins = GetPluginBase.Instance;
|
||||
|
||||
foreach(KeyValuePair<string, IReadOnlyFilesystem> kvp in plugins.ReadOnlyFilesystems)
|
||||
{
|
||||
if(kvp.Value.Namespaces is null) continue;
|
||||
|
||||
DicConsole.WriteLine("\tNamespaces for {0}:", kvp.Value.Name);
|
||||
DicConsole.WriteLine("\t\t{0,-16} {1,-16}", "Namespace", "Description");
|
||||
foreach(KeyValuePair<string, string> @namespace in kvp.Value.Namespaces.OrderBy(t => t.Key))
|
||||
DicConsole.WriteLine("\t\t{0,-16} {1,-16}", @namespace.Key, @namespace.Value);
|
||||
DicConsole.WriteLine();
|
||||
}
|
||||
|
||||
return (int)ErrorNumber.NoError;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -49,6 +49,7 @@ namespace DiscImageChef.Commands
|
||||
string encodingName;
|
||||
string inputFile;
|
||||
bool longFormat;
|
||||
string @namespace;
|
||||
string pluginOptions;
|
||||
bool showHelp;
|
||||
|
||||
@@ -68,7 +69,8 @@ namespace DiscImageChef.Commands
|
||||
"options|O=", "Comma separated name=value pairs of options to pass to filesystem plugin.",
|
||||
s => pluginOptions = s
|
||||
},
|
||||
{"help|h|?", "Show this message and exit.", v => showHelp = v != null}
|
||||
{"namespace|n=", "Namespace to use for filenames.", s => @namespace = s},
|
||||
{"help|h|?", "Show this message and exit.", v => showHelp = v != null}
|
||||
};
|
||||
}
|
||||
|
||||
@@ -215,7 +217,7 @@ namespace DiscImageChef.Commands
|
||||
|
||||
if(fs == null) continue;
|
||||
|
||||
error = fs.Mount(imageFormat, partitions[i], encoding, parsedOptions);
|
||||
error = fs.Mount(imageFormat, partitions[i], encoding, parsedOptions, @namespace);
|
||||
if(error == Errno.NoError)
|
||||
{
|
||||
ListFilesInDir("/", fs);
|
||||
@@ -238,7 +240,7 @@ namespace DiscImageChef.Commands
|
||||
?.Invoke(new object[] { });
|
||||
if(fs == null) continue;
|
||||
|
||||
error = fs.Mount(imageFormat, partitions[i], encoding, parsedOptions);
|
||||
error = fs.Mount(imageFormat, partitions[i], encoding, parsedOptions, @namespace);
|
||||
if(error == Errno.NoError)
|
||||
{
|
||||
ListFilesInDir("/", fs);
|
||||
@@ -272,7 +274,7 @@ namespace DiscImageChef.Commands
|
||||
?.Invoke(new object[] { });
|
||||
if(fs == null) continue;
|
||||
|
||||
error = fs.Mount(imageFormat, wholePart, encoding, parsedOptions);
|
||||
error = fs.Mount(imageFormat, wholePart, encoding, parsedOptions, @namespace);
|
||||
if(error == Errno.NoError)
|
||||
{
|
||||
ListFilesInDir("/", fs);
|
||||
@@ -293,7 +295,7 @@ namespace DiscImageChef.Commands
|
||||
.GetType().GetConstructor(Type.EmptyTypes)?.Invoke(new object[] { });
|
||||
if(fs != null)
|
||||
{
|
||||
error = fs.Mount(imageFormat, wholePart, encoding, parsedOptions);
|
||||
error = fs.Mount(imageFormat, wholePart, encoding, parsedOptions, @namespace);
|
||||
if(error == Errno.NoError)
|
||||
{
|
||||
ListFilesInDir("/", fs);
|
||||
|
||||
@@ -55,6 +55,7 @@
|
||||
<Compile Include="Commands\ConvertImage.cs" />
|
||||
<Compile Include="Commands\Gui.cs" />
|
||||
<Compile Include="Commands\ImageInfo.cs" />
|
||||
<Compile Include="Commands\ListNamespaces.cs" />
|
||||
<Compile Include="Commands\ListOptions.cs" />
|
||||
<Compile Include="Commands\Update.cs" />
|
||||
<Compile Include="Main.cs" />
|
||||
|
||||
@@ -135,6 +135,7 @@ namespace DiscImageChef
|
||||
currentPlatform == PlatformID.Win32NT) commands.Add(new ListDevicesCommand());
|
||||
|
||||
commands.Add(new ListEncodingsCommand());
|
||||
commands.Add(new ListNamespacesCommand());
|
||||
commands.Add(new ListOptionsCommand());
|
||||
commands.Add(new LsCommand());
|
||||
|
||||
|
||||
Reference in New Issue
Block a user