mirror of
https://github.com/aaru-dps/Aaru.git
synced 2025-12-16 19:24:25 +00:00
Move most of PluginBase logic into Aaru.Commontypes.
This commit is contained in:
Submodule Aaru.Checksums updated: 6cf148e849...7e91888aca
Submodule Aaru.CommonTypes updated: 50e0b8071f...d626697942
@@ -51,7 +51,8 @@ public static class Filesystems
|
|||||||
public static void Identify(IMediaImage imagePlugin, out List<string> idPlugins, Partition partition,
|
public static void Identify(IMediaImage imagePlugin, out List<string> idPlugins, Partition partition,
|
||||||
bool getGuid = false)
|
bool getGuid = false)
|
||||||
{
|
{
|
||||||
PluginBase plugins = PluginBase.Singleton;
|
PluginBase.Init();
|
||||||
|
PluginRegister plugins = PluginRegister.Singleton;
|
||||||
|
|
||||||
idPlugins = new List<string>();
|
idPlugins = new List<string>();
|
||||||
|
|
||||||
|
|||||||
@@ -31,6 +31,7 @@
|
|||||||
// ****************************************************************************/
|
// ****************************************************************************/
|
||||||
|
|
||||||
using System;
|
using System;
|
||||||
|
using Aaru.CommonTypes;
|
||||||
using Aaru.CommonTypes.Interfaces;
|
using Aaru.CommonTypes.Interfaces;
|
||||||
using Aaru.Console;
|
using Aaru.Console;
|
||||||
|
|
||||||
@@ -48,7 +49,8 @@ public static class ImageFormat
|
|||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
PluginBase plugins = PluginBase.Singleton;
|
PluginBase.Init();
|
||||||
|
PluginRegister plugins = PluginRegister.Singleton;
|
||||||
|
|
||||||
IBaseImage imageFormat = null;
|
IBaseImage imageFormat = null;
|
||||||
|
|
||||||
|
|||||||
@@ -50,7 +50,8 @@ public static class Partitions
|
|||||||
/// <returns>List of found partitions</returns>
|
/// <returns>List of found partitions</returns>
|
||||||
public static List<Partition> GetAll(IMediaImage image)
|
public static List<Partition> GetAll(IMediaImage image)
|
||||||
{
|
{
|
||||||
PluginBase plugins = PluginBase.Singleton;
|
PluginBase.Init();
|
||||||
|
PluginRegister plugins = PluginRegister.Singleton;
|
||||||
List<Partition> foundPartitions = new();
|
List<Partition> foundPartitions = new();
|
||||||
List<Partition> childPartitions = new();
|
List<Partition> childPartitions = new();
|
||||||
List<ulong> checkedLocations = new();
|
List<ulong> checkedLocations = new();
|
||||||
|
|||||||
@@ -30,173 +30,28 @@
|
|||||||
// Copyright © 2011-2023 Natalia Portillo
|
// Copyright © 2011-2023 Natalia Portillo
|
||||||
// ****************************************************************************/
|
// ****************************************************************************/
|
||||||
|
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Diagnostics.CodeAnalysis;
|
using System.Diagnostics.CodeAnalysis;
|
||||||
using System.Linq;
|
using Aaru.Checksums;
|
||||||
|
using Aaru.CommonTypes;
|
||||||
using Aaru.CommonTypes.Interfaces;
|
using Aaru.CommonTypes.Interfaces;
|
||||||
using Aaru.DiscImages;
|
|
||||||
using Microsoft.Extensions.DependencyInjection;
|
|
||||||
|
|
||||||
namespace Aaru.Core;
|
namespace Aaru.Core;
|
||||||
|
|
||||||
/// <summary>Plugin base operations</summary>
|
/// <summary>Plugin base operations</summary>
|
||||||
[SuppressMessage("ReSharper", "UnusedMember.Global")]
|
[SuppressMessage("ReSharper", "UnusedMember.Global")]
|
||||||
public sealed class PluginBase
|
public static class PluginBase
|
||||||
{
|
{
|
||||||
static PluginBase _instance;
|
public static void Init()
|
||||||
|
|
||||||
/// <summary>List of all archive formats</summary>
|
|
||||||
public readonly SortedDictionary<string, Type> Archives;
|
|
||||||
/// <summary>List of byte addressable image plugins</summary>
|
|
||||||
public readonly SortedDictionary<string, Type> ByteAddressableImages;
|
|
||||||
/// <summary>List of all filesystem plugins</summary>
|
|
||||||
public readonly SortedDictionary<string, Type> Filesystems;
|
|
||||||
/// <summary>List of filter plugins</summary>
|
|
||||||
public readonly SortedDictionary<string, Type> Filters;
|
|
||||||
/// <summary>List of floppy image plugins</summary>
|
|
||||||
public readonly SortedDictionary<string, Type> FloppyImages;
|
|
||||||
/// <summary>List of all media image plugins</summary>
|
|
||||||
public readonly SortedDictionary<string, Type> MediaImages;
|
|
||||||
/// <summary>List of all partition plugins</summary>
|
|
||||||
public readonly SortedDictionary<string, Type> Partitions;
|
|
||||||
/// <summary>List of read-only filesystem plugins</summary>
|
|
||||||
public readonly SortedDictionary<string, Type> ReadOnlyFilesystems;
|
|
||||||
/// <summary>List of writable floppy image plugins</summary>
|
|
||||||
public readonly SortedDictionary<string, Type> WritableFloppyImages;
|
|
||||||
/// <summary>List of writable media image plugins</summary>
|
|
||||||
public readonly SortedDictionary<string, Type> WritableImages;
|
|
||||||
IServiceProvider _serviceProvider;
|
|
||||||
IServiceCollection _services;
|
|
||||||
|
|
||||||
PluginBase()
|
|
||||||
{
|
{
|
||||||
Filesystems = new SortedDictionary<string, Type>();
|
PluginRegister.Singleton.InitPlugins(new List<IPluginRegister>
|
||||||
ReadOnlyFilesystems = new SortedDictionary<string, Type>();
|
|
||||||
Partitions = new SortedDictionary<string, Type>();
|
|
||||||
MediaImages = new SortedDictionary<string, Type>();
|
|
||||||
WritableImages = new SortedDictionary<string, Type>();
|
|
||||||
Filters = new SortedDictionary<string, Type>();
|
|
||||||
FloppyImages = new SortedDictionary<string, Type>();
|
|
||||||
WritableFloppyImages = new SortedDictionary<string, Type>();
|
|
||||||
Archives = new SortedDictionary<string, Type>();
|
|
||||||
ByteAddressableImages = new SortedDictionary<string, Type>();
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>List of all checksums formats</summary>
|
|
||||||
public SortedDictionary<string, IChecksum> Checksums
|
|
||||||
{
|
{
|
||||||
get
|
new Register(),
|
||||||
{
|
new Filters.Register(),
|
||||||
SortedDictionary<string, IChecksum> checksums = new();
|
new DiscImages.Register(),
|
||||||
foreach(IChecksum plugin in _serviceProvider.GetServices<IChecksum>())
|
new Aaru.Filesystems.Register(),
|
||||||
checksums.Add(plugin.Name.ToLower(), plugin);
|
new Aaru.Partitions.Register(),
|
||||||
|
new Archives.Register()
|
||||||
return checksums;
|
});
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>Gets a singleton with all the known plugins</summary>
|
|
||||||
public static PluginBase Singleton
|
|
||||||
{
|
|
||||||
get
|
|
||||||
{
|
|
||||||
if(_instance != null)
|
|
||||||
return _instance;
|
|
||||||
|
|
||||||
_instance = new PluginBase
|
|
||||||
{
|
|
||||||
_services = new ServiceCollection()
|
|
||||||
};
|
|
||||||
|
|
||||||
IPluginRegister imagesRegister = new Register();
|
|
||||||
IPluginRegister filesystemsRegister = new Aaru.Filesystems.Register();
|
|
||||||
IPluginRegister filtersRegister = new Filters.Register();
|
|
||||||
IPluginRegister partitionsRegister = new Aaru.Partitions.Register();
|
|
||||||
IPluginRegister archiveRegister = new Archives.Register();
|
|
||||||
|
|
||||||
_instance.AddPlugins(new Checksums.Register());
|
|
||||||
_instance.AddPlugins(imagesRegister);
|
|
||||||
_instance.AddPlugins(filesystemsRegister);
|
|
||||||
_instance.AddPlugins(filtersRegister);
|
|
||||||
_instance.AddPlugins(partitionsRegister);
|
|
||||||
_instance.AddPlugins(archiveRegister);
|
|
||||||
|
|
||||||
_instance._serviceProvider = _instance._services.BuildServiceProvider();
|
|
||||||
|
|
||||||
return _instance;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>Adds plugins to the central plugin register</summary>
|
|
||||||
/// <param name="pluginRegister">Plugin register</param>
|
|
||||||
void AddPlugins(IPluginRegister pluginRegister)
|
|
||||||
{
|
|
||||||
pluginRegister.RegisterChecksumPlugins(_services);
|
|
||||||
|
|
||||||
foreach(Type type in pluginRegister.GetAllFilesystemPlugins() ?? Enumerable.Empty<Type>())
|
|
||||||
{
|
|
||||||
if(Activator.CreateInstance(type) is IFilesystem plugin && !Filesystems.ContainsKey(plugin.Name.ToLower()))
|
|
||||||
Filesystems.Add(plugin.Name.ToLower(), type);
|
|
||||||
}
|
|
||||||
|
|
||||||
foreach(Type type in pluginRegister.GetAllFilterPlugins() ?? Enumerable.Empty<Type>())
|
|
||||||
{
|
|
||||||
if(Activator.CreateInstance(type) is IFilter plugin && !Filters.ContainsKey(plugin.Name.ToLower()))
|
|
||||||
Filters.Add(plugin.Name.ToLower(), type);
|
|
||||||
}
|
|
||||||
|
|
||||||
foreach(Type type in pluginRegister.GetAllFloppyImagePlugins() ?? Enumerable.Empty<Type>())
|
|
||||||
{
|
|
||||||
if(Activator.CreateInstance(type) is IFloppyImage plugin &&
|
|
||||||
!FloppyImages.ContainsKey(plugin.Name.ToLower()))
|
|
||||||
FloppyImages.Add(plugin.Name.ToLower(), type);
|
|
||||||
}
|
|
||||||
|
|
||||||
foreach(Type type in pluginRegister.GetAllMediaImagePlugins() ?? Enumerable.Empty<Type>())
|
|
||||||
{
|
|
||||||
if(Activator.CreateInstance(type) is IMediaImage plugin && !MediaImages.ContainsKey(plugin.Name.ToLower()))
|
|
||||||
MediaImages.Add(plugin.Name.ToLower(), type);
|
|
||||||
}
|
|
||||||
|
|
||||||
foreach(Type type in pluginRegister.GetAllPartitionPlugins() ?? Enumerable.Empty<Type>())
|
|
||||||
{
|
|
||||||
if(Activator.CreateInstance(type) is IPartition plugin && !Partitions.ContainsKey(plugin.Name.ToLower()))
|
|
||||||
Partitions.Add(plugin.Name.ToLower(), type);
|
|
||||||
}
|
|
||||||
|
|
||||||
foreach(Type type in pluginRegister.GetAllReadOnlyFilesystemPlugins() ?? Enumerable.Empty<Type>())
|
|
||||||
{
|
|
||||||
if(Activator.CreateInstance(type) is IReadOnlyFilesystem plugin &&
|
|
||||||
!ReadOnlyFilesystems.ContainsKey(plugin.Name.ToLower()))
|
|
||||||
ReadOnlyFilesystems.Add(plugin.Name.ToLower(), type);
|
|
||||||
}
|
|
||||||
|
|
||||||
foreach(Type type in pluginRegister.GetAllWritableFloppyImagePlugins() ?? Enumerable.Empty<Type>())
|
|
||||||
{
|
|
||||||
if(Activator.CreateInstance(type) is IWritableFloppyImage plugin &&
|
|
||||||
!WritableFloppyImages.ContainsKey(plugin.Name.ToLower()))
|
|
||||||
WritableFloppyImages.Add(plugin.Name.ToLower(), type);
|
|
||||||
}
|
|
||||||
|
|
||||||
foreach(Type type in pluginRegister.GetAllWritableImagePlugins() ?? Enumerable.Empty<Type>())
|
|
||||||
{
|
|
||||||
if(Activator.CreateInstance(type) is IBaseWritableImage plugin &&
|
|
||||||
!WritableImages.ContainsKey(plugin.Name.ToLower()))
|
|
||||||
WritableImages.Add(plugin.Name.ToLower(), type);
|
|
||||||
}
|
|
||||||
|
|
||||||
foreach(Type type in pluginRegister.GetAllArchivePlugins() ?? Enumerable.Empty<Type>())
|
|
||||||
{
|
|
||||||
if(Activator.CreateInstance(type) is IArchive plugin && !Archives.ContainsKey(plugin.Name.ToLower()))
|
|
||||||
Archives.Add(plugin.Name.ToLower(), type);
|
|
||||||
}
|
|
||||||
|
|
||||||
foreach(Type type in pluginRegister.GetAllByteAddressablePlugins() ?? Enumerable.Empty<Type>())
|
|
||||||
{
|
|
||||||
if(Activator.CreateInstance(type) is IByteAddressableImage plugin &&
|
|
||||||
!ByteAddressableImages.ContainsKey(plugin.Name.ToLower()))
|
|
||||||
ByteAddressableImages.Add(plugin.Name.ToLower(), type);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -34,6 +34,7 @@ using System;
|
|||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
|
using Aaru.CommonTypes;
|
||||||
using Aaru.CommonTypes.AaruMetadata;
|
using Aaru.CommonTypes.AaruMetadata;
|
||||||
using Aaru.CommonTypes.Interfaces;
|
using Aaru.CommonTypes.Interfaces;
|
||||||
|
|
||||||
@@ -53,7 +54,7 @@ public sealed partial class Sidecar
|
|||||||
/// <param name="imgChecksums">List of image checksums</param>
|
/// <param name="imgChecksums">List of image checksums</param>
|
||||||
/// <param name="sidecar">Metadata sidecar</param>
|
/// <param name="sidecar">Metadata sidecar</param>
|
||||||
/// <param name="encoding">Encoding to be used for filesystem plugins</param>
|
/// <param name="encoding">Encoding to be used for filesystem plugins</param>
|
||||||
static void AudioMedia(IBaseImage image, Guid filterId, string imagePath, FileInfo fi, PluginBase plugins,
|
static void AudioMedia(IBaseImage image, Guid filterId, string imagePath, FileInfo fi, PluginRegister plugins,
|
||||||
List<CommonTypes.AaruMetadata.Checksum> imgChecksums, ref Metadata sidecar,
|
List<CommonTypes.AaruMetadata.Checksum> imgChecksums, ref Metadata sidecar,
|
||||||
Encoding encoding)
|
Encoding encoding)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -35,10 +35,10 @@ using System.Collections.Generic;
|
|||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
|
using Aaru.CommonTypes;
|
||||||
using Aaru.CommonTypes.AaruMetadata;
|
using Aaru.CommonTypes.AaruMetadata;
|
||||||
using Aaru.CommonTypes.Enums;
|
using Aaru.CommonTypes.Enums;
|
||||||
using Aaru.CommonTypes.Interfaces;
|
using Aaru.CommonTypes.Interfaces;
|
||||||
using Aaru.CommonTypes.Metadata;
|
|
||||||
using Aaru.CommonTypes.Structs.Devices.ATA;
|
using Aaru.CommonTypes.Structs.Devices.ATA;
|
||||||
using Aaru.Console;
|
using Aaru.Console;
|
||||||
using Aaru.Decoders.PCMCIA;
|
using Aaru.Decoders.PCMCIA;
|
||||||
@@ -47,10 +47,9 @@ using Aaru.Filters;
|
|||||||
using Aaru.Helpers;
|
using Aaru.Helpers;
|
||||||
using Directory = System.IO.Directory;
|
using Directory = System.IO.Directory;
|
||||||
using File = System.IO.File;
|
using File = System.IO.File;
|
||||||
|
using MediaType = Aaru.CommonTypes.Metadata.MediaType;
|
||||||
using Partition = Aaru.CommonTypes.Partition;
|
using Partition = Aaru.CommonTypes.Partition;
|
||||||
using Pcmcia = Aaru.CommonTypes.AaruMetadata.Pcmcia;
|
|
||||||
using Tuple = Aaru.Decoders.PCMCIA.Tuple;
|
using Tuple = Aaru.Decoders.PCMCIA.Tuple;
|
||||||
using Usb = Aaru.CommonTypes.AaruMetadata.Usb;
|
|
||||||
|
|
||||||
namespace Aaru.Core;
|
namespace Aaru.Core;
|
||||||
|
|
||||||
@@ -65,7 +64,7 @@ public sealed partial class Sidecar
|
|||||||
/// <param name="imgChecksums">List of image checksums</param>
|
/// <param name="imgChecksums">List of image checksums</param>
|
||||||
/// <param name="sidecar">Metadata sidecar</param>
|
/// <param name="sidecar">Metadata sidecar</param>
|
||||||
/// <param name="encoding">Encoding to be used for filesystem plugins</param>
|
/// <param name="encoding">Encoding to be used for filesystem plugins</param>
|
||||||
void BlockMedia(IMediaImage image, Guid filterId, string imagePath, FileInfo fi, PluginBase plugins,
|
void BlockMedia(IMediaImage image, Guid filterId, string imagePath, FileInfo fi, PluginRegister plugins,
|
||||||
List<CommonTypes.AaruMetadata.Checksum> imgChecksums, ref Metadata sidecar, Encoding encoding)
|
List<CommonTypes.AaruMetadata.Checksum> imgChecksums, ref Metadata sidecar, Encoding encoding)
|
||||||
{
|
{
|
||||||
if(_aborted)
|
if(_aborted)
|
||||||
|
|||||||
@@ -34,6 +34,7 @@ using System;
|
|||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
|
using Aaru.CommonTypes;
|
||||||
using Aaru.CommonTypes.AaruMetadata;
|
using Aaru.CommonTypes.AaruMetadata;
|
||||||
using Aaru.CommonTypes.Interfaces;
|
using Aaru.CommonTypes.Interfaces;
|
||||||
|
|
||||||
@@ -54,7 +55,7 @@ public sealed partial class Sidecar
|
|||||||
/// <param name="sidecar">Metadata sidecar</param>
|
/// <param name="sidecar">Metadata sidecar</param>
|
||||||
/// <param name="encoding">Encoding to be used for filesystem plugins</param>
|
/// <param name="encoding">Encoding to be used for filesystem plugins</param>
|
||||||
static void LinearMedia(IByteAddressableImage image, Guid filterId, string imagePath, FileInfo fi,
|
static void LinearMedia(IByteAddressableImage image, Guid filterId, string imagePath, FileInfo fi,
|
||||||
PluginBase plugins, List<CommonTypes.AaruMetadata.Checksum> imgChecksums,
|
PluginRegister plugins, List<CommonTypes.AaruMetadata.Checksum> imgChecksums,
|
||||||
ref Metadata sidecar, Encoding encoding) => sidecar.LinearMedias = new List<LinearMedia>
|
ref Metadata sidecar, Encoding encoding) => sidecar.LinearMedias = new List<LinearMedia>
|
||||||
{
|
{
|
||||||
new()
|
new()
|
||||||
|
|||||||
@@ -61,7 +61,7 @@ public sealed partial class Sidecar
|
|||||||
/// <param name="imgChecksums">List of image checksums</param>
|
/// <param name="imgChecksums">List of image checksums</param>
|
||||||
/// <param name="sidecar">Metadata sidecar</param>
|
/// <param name="sidecar">Metadata sidecar</param>
|
||||||
/// <param name="encoding">Encoding to be used for filesystem plugins</param>
|
/// <param name="encoding">Encoding to be used for filesystem plugins</param>
|
||||||
void OpticalDisc(IOpticalMediaImage image, Guid filterId, string imagePath, FileInfo fi, PluginBase plugins,
|
void OpticalDisc(IOpticalMediaImage image, Guid filterId, string imagePath, FileInfo fi, PluginRegister plugins,
|
||||||
List<CommonTypes.AaruMetadata.Checksum> imgChecksums, ref Metadata sidecar, Encoding encoding)
|
List<CommonTypes.AaruMetadata.Checksum> imgChecksums, ref Metadata sidecar, Encoding encoding)
|
||||||
{
|
{
|
||||||
if(_aborted)
|
if(_aborted)
|
||||||
|
|||||||
@@ -34,6 +34,7 @@ using System;
|
|||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
|
using Aaru.CommonTypes;
|
||||||
using Aaru.CommonTypes.AaruMetadata;
|
using Aaru.CommonTypes.AaruMetadata;
|
||||||
using Aaru.CommonTypes.Enums;
|
using Aaru.CommonTypes.Enums;
|
||||||
using Aaru.CommonTypes.Interfaces;
|
using Aaru.CommonTypes.Interfaces;
|
||||||
@@ -52,7 +53,7 @@ public sealed partial class Sidecar
|
|||||||
readonly IBaseImage _image;
|
readonly IBaseImage _image;
|
||||||
readonly string _imagePath;
|
readonly string _imagePath;
|
||||||
readonly Checksum _imgChkWorker;
|
readonly Checksum _imgChkWorker;
|
||||||
readonly PluginBase _plugins;
|
readonly PluginRegister _plugins;
|
||||||
bool _aborted;
|
bool _aborted;
|
||||||
FileStream _fs;
|
FileStream _fs;
|
||||||
Metadata _sidecar;
|
Metadata _sidecar;
|
||||||
@@ -60,7 +61,8 @@ public sealed partial class Sidecar
|
|||||||
/// <summary>Initializes a new instance of this class</summary>
|
/// <summary>Initializes a new instance of this class</summary>
|
||||||
public Sidecar()
|
public Sidecar()
|
||||||
{
|
{
|
||||||
_plugins = PluginBase.Singleton;
|
PluginBase.Init();
|
||||||
|
_plugins = PluginRegister.Singleton;
|
||||||
_imgChkWorker = new Checksum();
|
_imgChkWorker = new Checksum();
|
||||||
_aborted = false;
|
_aborted = false;
|
||||||
|
|
||||||
@@ -75,12 +77,14 @@ public sealed partial class Sidecar
|
|||||||
/// <param name="encoding">Encoding for analysis</param>
|
/// <param name="encoding">Encoding for analysis</param>
|
||||||
public Sidecar(IBaseImage image, string imagePath, Guid filterId, Encoding encoding)
|
public Sidecar(IBaseImage image, string imagePath, Guid filterId, Encoding encoding)
|
||||||
{
|
{
|
||||||
|
PluginBase.Init();
|
||||||
|
|
||||||
_image = image;
|
_image = image;
|
||||||
_imagePath = imagePath;
|
_imagePath = imagePath;
|
||||||
_filterId = filterId;
|
_filterId = filterId;
|
||||||
_encoding = encoding;
|
_encoding = encoding;
|
||||||
_sidecar = image.AaruMetadata ?? new Metadata();
|
_sidecar = image.AaruMetadata ?? new Metadata();
|
||||||
_plugins = PluginBase.Singleton;
|
_plugins = PluginRegister.Singleton;
|
||||||
_fi = new FileInfo(imagePath);
|
_fi = new FileInfo(imagePath);
|
||||||
_fs = new FileStream(imagePath, FileMode.Open, FileAccess.Read);
|
_fs = new FileStream(imagePath, FileMode.Open, FileAccess.Read);
|
||||||
_imgChkWorker = new Checksum();
|
_imgChkWorker = new Checksum();
|
||||||
|
|||||||
@@ -34,6 +34,7 @@ using System;
|
|||||||
using System.Collections.ObjectModel;
|
using System.Collections.ObjectModel;
|
||||||
using System.Reactive;
|
using System.Reactive;
|
||||||
using System.Reflection;
|
using System.Reflection;
|
||||||
|
using Aaru.CommonTypes;
|
||||||
using Aaru.CommonTypes.Interfaces;
|
using Aaru.CommonTypes.Interfaces;
|
||||||
using Aaru.Core;
|
using Aaru.Core;
|
||||||
using Aaru.Gui.Models;
|
using Aaru.Gui.Models;
|
||||||
@@ -60,9 +61,10 @@ public sealed class PluginsViewModel : ViewModelBase
|
|||||||
FloppyImages = new ObservableCollection<PluginModel>();
|
FloppyImages = new ObservableCollection<PluginModel>();
|
||||||
WritableFloppyImages = new ObservableCollection<PluginModel>();
|
WritableFloppyImages = new ObservableCollection<PluginModel>();
|
||||||
CloseCommand = ReactiveCommand.Create(ExecuteCloseCommand);
|
CloseCommand = ReactiveCommand.Create(ExecuteCloseCommand);
|
||||||
|
PluginBase.Init();
|
||||||
|
|
||||||
// TODO: Takes too much time
|
// TODO: Takes too much time
|
||||||
foreach(Type filterType in PluginBase.Singleton.Filters.Values)
|
foreach(Type filterType in PluginRegister.Singleton.Filters.Values)
|
||||||
{
|
{
|
||||||
if(Activator.CreateInstance(filterType) is not IFilter filter)
|
if(Activator.CreateInstance(filterType) is not IFilter filter)
|
||||||
continue;
|
continue;
|
||||||
@@ -76,7 +78,7 @@ public sealed class PluginsViewModel : ViewModelBase
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach(Type imageType in PluginBase.Singleton.FloppyImages.Values)
|
foreach(Type imageType in PluginRegister.Singleton.FloppyImages.Values)
|
||||||
{
|
{
|
||||||
if(Activator.CreateInstance(imageType) is not IFloppyImage floppyImage)
|
if(Activator.CreateInstance(imageType) is not IFloppyImage floppyImage)
|
||||||
continue;
|
continue;
|
||||||
@@ -90,7 +92,7 @@ public sealed class PluginsViewModel : ViewModelBase
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach(Type imageType in PluginBase.Singleton.MediaImages.Values)
|
foreach(Type imageType in PluginRegister.Singleton.MediaImages.Values)
|
||||||
{
|
{
|
||||||
if(Activator.CreateInstance(imageType) is not IMediaImage mediaImage)
|
if(Activator.CreateInstance(imageType) is not IMediaImage mediaImage)
|
||||||
continue;
|
continue;
|
||||||
@@ -104,7 +106,7 @@ public sealed class PluginsViewModel : ViewModelBase
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach(Type partitionType in PluginBase.Singleton.Partitions.Values)
|
foreach(Type partitionType in PluginRegister.Singleton.Partitions.Values)
|
||||||
{
|
{
|
||||||
if(Activator.CreateInstance(partitionType) is not IPartition partition)
|
if(Activator.CreateInstance(partitionType) is not IPartition partition)
|
||||||
continue;
|
continue;
|
||||||
@@ -118,7 +120,7 @@ public sealed class PluginsViewModel : ViewModelBase
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach(Type filesystem in PluginBase.Singleton.Filesystems.Values)
|
foreach(Type filesystem in PluginRegister.Singleton.Filesystems.Values)
|
||||||
{
|
{
|
||||||
if(Activator.CreateInstance(filesystem) is not IFilesystem fs)
|
if(Activator.CreateInstance(filesystem) is not IFilesystem fs)
|
||||||
continue;
|
continue;
|
||||||
@@ -132,7 +134,7 @@ public sealed class PluginsViewModel : ViewModelBase
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach(Type readOnlyFilesystem in PluginBase.Singleton.ReadOnlyFilesystems.Values)
|
foreach(Type readOnlyFilesystem in PluginRegister.Singleton.ReadOnlyFilesystems.Values)
|
||||||
{
|
{
|
||||||
if(Activator.CreateInstance(readOnlyFilesystem) is not IReadOnlyFilesystem fs)
|
if(Activator.CreateInstance(readOnlyFilesystem) is not IReadOnlyFilesystem fs)
|
||||||
continue;
|
continue;
|
||||||
@@ -146,7 +148,7 @@ public sealed class PluginsViewModel : ViewModelBase
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach(Type imageType in PluginBase.Singleton.WritableFloppyImages.Values)
|
foreach(Type imageType in PluginRegister.Singleton.WritableFloppyImages.Values)
|
||||||
{
|
{
|
||||||
if(Activator.CreateInstance(imageType) is not IWritableFloppyImage writableFloppyImage)
|
if(Activator.CreateInstance(imageType) is not IWritableFloppyImage writableFloppyImage)
|
||||||
continue;
|
continue;
|
||||||
@@ -160,7 +162,7 @@ public sealed class PluginsViewModel : ViewModelBase
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach(Type baseWritableImageType in PluginBase.Singleton.WritableImages.Values)
|
foreach(Type baseWritableImageType in PluginRegister.Singleton.WritableImages.Values)
|
||||||
{
|
{
|
||||||
if(Activator.CreateInstance(baseWritableImageType) is not IWritableImage writableImage)
|
if(Activator.CreateInstance(baseWritableImageType) is not IWritableImage writableImage)
|
||||||
continue;
|
continue;
|
||||||
|
|||||||
@@ -41,6 +41,7 @@ using System.Text;
|
|||||||
using System.Text.Json;
|
using System.Text.Json;
|
||||||
using System.Threading;
|
using System.Threading;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
using Aaru.CommonTypes;
|
||||||
using Aaru.CommonTypes.AaruMetadata;
|
using Aaru.CommonTypes.AaruMetadata;
|
||||||
using Aaru.CommonTypes.Enums;
|
using Aaru.CommonTypes.Enums;
|
||||||
using Aaru.CommonTypes.Interfaces;
|
using Aaru.CommonTypes.Interfaces;
|
||||||
@@ -172,7 +173,8 @@ public sealed class ImageConvertViewModel : ViewModelBase
|
|||||||
DriveSerialNumberVisible = !string.IsNullOrWhiteSpace(inputFormat.Info.DriveSerialNumber);
|
DriveSerialNumberVisible = !string.IsNullOrWhiteSpace(inputFormat.Info.DriveSerialNumber);
|
||||||
DriveFirmwareRevisionVisible = !string.IsNullOrWhiteSpace(inputFormat.Info.DriveFirmwareRevision);
|
DriveFirmwareRevisionVisible = !string.IsNullOrWhiteSpace(inputFormat.Info.DriveFirmwareRevision);
|
||||||
|
|
||||||
PluginBase plugins = PluginBase.Singleton;
|
PluginBase.Init();
|
||||||
|
PluginRegister plugins = PluginRegister.Singleton;
|
||||||
|
|
||||||
foreach(Type pluginType in plugins.WritableImages.Values)
|
foreach(Type pluginType in plugins.WritableImages.Values)
|
||||||
{
|
{
|
||||||
@@ -1385,11 +1387,13 @@ public sealed class ImageConvertViewModel : ViewModelBase
|
|||||||
if(trackFlags.Count > 0)
|
if(trackFlags.Count > 0)
|
||||||
{
|
{
|
||||||
foreach(KeyValuePair<byte, byte> flags in trackFlags)
|
foreach(KeyValuePair<byte, byte> flags in trackFlags)
|
||||||
|
{
|
||||||
outputOptical.WriteSectorTag(new[]
|
outputOptical.WriteSectorTag(new[]
|
||||||
{
|
{
|
||||||
flags.Value
|
flags.Value
|
||||||
}, flags.Key, SectorTagType.CdTrackFlags);
|
}, flags.Key, SectorTagType.CdTrackFlags);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if(mcn != null)
|
if(mcn != null)
|
||||||
outputOptical.WriteMediaTag(Encoding.UTF8.GetBytes(mcn), MediaTagType.CD_MCN);
|
outputOptical.WriteMediaTag(Encoding.UTF8.GetBytes(mcn), MediaTagType.CD_MCN);
|
||||||
|
|||||||
@@ -609,7 +609,8 @@ public sealed class MainWindowViewModel : ViewModelBase
|
|||||||
var checkRaw = false;
|
var checkRaw = false;
|
||||||
List<string> idPlugins;
|
List<string> idPlugins;
|
||||||
Type pluginType;
|
Type pluginType;
|
||||||
PluginBase plugins = PluginBase.Singleton;
|
PluginBase.Init();
|
||||||
|
PluginRegister plugins = PluginRegister.Singleton;
|
||||||
|
|
||||||
if(partitions.Count == 0)
|
if(partitions.Count == 0)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -42,6 +42,7 @@ using System.Text.Json;
|
|||||||
using System.Threading;
|
using System.Threading;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using System.Xml.Serialization;
|
using System.Xml.Serialization;
|
||||||
|
using Aaru.CommonTypes;
|
||||||
using Aaru.CommonTypes.AaruMetadata;
|
using Aaru.CommonTypes.AaruMetadata;
|
||||||
using Aaru.CommonTypes.Enums;
|
using Aaru.CommonTypes.Enums;
|
||||||
using Aaru.CommonTypes.Interfaces;
|
using Aaru.CommonTypes.Interfaces;
|
||||||
@@ -167,7 +168,8 @@ public sealed class MediaDumpViewModel : ViewModelBase
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
PluginBase plugins = PluginBase.Singleton;
|
PluginBase.Init();
|
||||||
|
PluginRegister plugins = PluginRegister.Singleton;
|
||||||
|
|
||||||
foreach(Type pluginType in plugins.WritableImages.Values)
|
foreach(Type pluginType in plugins.WritableImages.Values)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -135,7 +135,8 @@ public abstract class BlockMediaImageTest : BaseMediaImageTest
|
|||||||
public void Contents()
|
public void Contents()
|
||||||
{
|
{
|
||||||
Environment.CurrentDirectory = DataFolder;
|
Environment.CurrentDirectory = DataFolder;
|
||||||
PluginBase plugins = PluginBase.Singleton;
|
PluginBase.Init();
|
||||||
|
PluginRegister plugins = PluginRegister.Singleton;
|
||||||
|
|
||||||
Assert.Multiple(() =>
|
Assert.Multiple(() =>
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -199,7 +199,8 @@ public abstract class OpticalMediaImageTest : BaseMediaImageTest
|
|||||||
|
|
||||||
for(var i = 0; i < track.FileSystems.Length; i++)
|
for(var i = 0; i < track.FileSystems.Length; i++)
|
||||||
{
|
{
|
||||||
PluginBase plugins = PluginBase.Singleton;
|
PluginBase.Init();
|
||||||
|
PluginRegister plugins = PluginRegister.Singleton;
|
||||||
bool found = plugins.Filesystems.TryGetValue(idPlugins[i], out Type pluginType);
|
bool found = plugins.Filesystems.TryGetValue(idPlugins[i], out Type pluginType);
|
||||||
|
|
||||||
// ReSharper disable once ConditionIsAlwaysTrueOrFalse
|
// ReSharper disable once ConditionIsAlwaysTrueOrFalse
|
||||||
|
|||||||
@@ -46,7 +46,8 @@ public abstract class FsExtractHashIssueTest
|
|||||||
if(Encoding != null)
|
if(Encoding != null)
|
||||||
encodingClass = Claunia.Encoding.Encoding.GetEncoding(Encoding);
|
encodingClass = Claunia.Encoding.Encoding.GetEncoding(Encoding);
|
||||||
|
|
||||||
PluginBase plugins = PluginBase.Singleton;
|
PluginBase.Init();
|
||||||
|
PluginRegister plugins = PluginRegister.Singleton;
|
||||||
|
|
||||||
var imageFormat = ImageFormat.Detect(inputFilter) as IMediaImage;
|
var imageFormat = ImageFormat.Detect(inputFilter) as IMediaImage;
|
||||||
|
|
||||||
|
|||||||
@@ -40,7 +40,8 @@ public abstract class FsExtractIssueTest
|
|||||||
if(Encoding != null)
|
if(Encoding != null)
|
||||||
encodingClass = Claunia.Encoding.Encoding.GetEncoding(Encoding);
|
encodingClass = Claunia.Encoding.Encoding.GetEncoding(Encoding);
|
||||||
|
|
||||||
PluginBase plugins = PluginBase.Singleton;
|
PluginBase.Init();
|
||||||
|
PluginRegister plugins = PluginRegister.Singleton;
|
||||||
|
|
||||||
var imageFormat = ImageFormat.Detect(inputFilter) as IMediaImage;
|
var imageFormat = ImageFormat.Detect(inputFilter) as IMediaImage;
|
||||||
|
|
||||||
|
|||||||
@@ -179,7 +179,8 @@ sealed class ExtractFilesCommand : Command
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
PluginBase plugins = PluginBase.Singleton;
|
PluginBase.Init();
|
||||||
|
PluginRegister plugins = PluginRegister.Singleton;
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -154,7 +154,8 @@ sealed class FilesystemInfoCommand : Command
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
PluginBase plugins = PluginBase.Singleton;
|
PluginBase.Init();
|
||||||
|
PluginRegister plugins = PluginRegister.Singleton;
|
||||||
|
|
||||||
var checkRaw = false;
|
var checkRaw = false;
|
||||||
|
|
||||||
|
|||||||
@@ -168,7 +168,8 @@ sealed class LsCommand : Command
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
PluginBase plugins = PluginBase.Singleton;
|
PluginBase.Init();
|
||||||
|
PluginRegister plugins = PluginRegister.Singleton;
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -35,6 +35,7 @@ using System.Collections.Generic;
|
|||||||
using System.CommandLine;
|
using System.CommandLine;
|
||||||
using System.CommandLine.NamingConventionBinder;
|
using System.CommandLine.NamingConventionBinder;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
using Aaru.CommonTypes;
|
||||||
using Aaru.CommonTypes.Enums;
|
using Aaru.CommonTypes.Enums;
|
||||||
using Aaru.CommonTypes.Interfaces;
|
using Aaru.CommonTypes.Interfaces;
|
||||||
using Aaru.Console;
|
using Aaru.Console;
|
||||||
@@ -87,7 +88,8 @@ sealed class ListOptionsCommand : Command
|
|||||||
AaruConsole.DebugWriteLine(MODULE_NAME, "--verbose={0}", verbose);
|
AaruConsole.DebugWriteLine(MODULE_NAME, "--verbose={0}", verbose);
|
||||||
Statistics.AddCommand("list-options");
|
Statistics.AddCommand("list-options");
|
||||||
|
|
||||||
PluginBase plugins = PluginBase.Singleton;
|
PluginBase.Init();
|
||||||
|
PluginRegister plugins = PluginRegister.Singleton;
|
||||||
|
|
||||||
AaruConsole.WriteLine(UI.Read_only_filesystems_options);
|
AaruConsole.WriteLine(UI.Read_only_filesystems_options);
|
||||||
|
|
||||||
|
|||||||
@@ -88,7 +88,8 @@ sealed class FormatsCommand : Command
|
|||||||
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.Init();
|
||||||
|
PluginRegister plugins = PluginRegister.Singleton;
|
||||||
var filtersList = new FiltersList();
|
var filtersList = new FiltersList();
|
||||||
|
|
||||||
Table table = new()
|
Table table = new()
|
||||||
|
|||||||
@@ -449,7 +449,8 @@ sealed class ConvertImageCommand : Command
|
|||||||
return (int)ErrorNumber.FileExists;
|
return (int)ErrorNumber.FileExists;
|
||||||
}
|
}
|
||||||
|
|
||||||
PluginBase plugins = PluginBase.Singleton;
|
PluginBase.Init();
|
||||||
|
PluginRegister plugins = PluginRegister.Singleton;
|
||||||
IMediaImage inputFormat = null;
|
IMediaImage inputFormat = null;
|
||||||
IBaseImage baseImage = null;
|
IBaseImage baseImage = null;
|
||||||
|
|
||||||
|
|||||||
@@ -35,6 +35,7 @@ using System.Collections.Generic;
|
|||||||
using System.CommandLine;
|
using System.CommandLine;
|
||||||
using System.CommandLine.NamingConventionBinder;
|
using System.CommandLine.NamingConventionBinder;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
using Aaru.CommonTypes;
|
||||||
using Aaru.CommonTypes.Enums;
|
using Aaru.CommonTypes.Enums;
|
||||||
using Aaru.CommonTypes.Interfaces;
|
using Aaru.CommonTypes.Interfaces;
|
||||||
using Aaru.Console;
|
using Aaru.Console;
|
||||||
@@ -87,7 +88,8 @@ sealed class ListOptionsCommand : Command
|
|||||||
AaruConsole.DebugWriteLine(MODULE_NAME, "--verbose={0}", verbose);
|
AaruConsole.DebugWriteLine(MODULE_NAME, "--verbose={0}", verbose);
|
||||||
Statistics.AddCommand("list-options");
|
Statistics.AddCommand("list-options");
|
||||||
|
|
||||||
PluginBase plugins = PluginBase.Singleton;
|
PluginBase.Init();
|
||||||
|
PluginRegister plugins = PluginRegister.Singleton;
|
||||||
|
|
||||||
AaruConsole.WriteLine(UI.Read_Write_media_images_options);
|
AaruConsole.WriteLine(UI.Read_Write_media_images_options);
|
||||||
|
|
||||||
|
|||||||
@@ -35,6 +35,7 @@ using System.Collections.Generic;
|
|||||||
using System.CommandLine;
|
using System.CommandLine;
|
||||||
using System.CommandLine.NamingConventionBinder;
|
using System.CommandLine.NamingConventionBinder;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
using Aaru.CommonTypes;
|
||||||
using Aaru.CommonTypes.Enums;
|
using Aaru.CommonTypes.Enums;
|
||||||
using Aaru.CommonTypes.Interfaces;
|
using Aaru.CommonTypes.Interfaces;
|
||||||
using Aaru.Console;
|
using Aaru.Console;
|
||||||
@@ -86,7 +87,8 @@ sealed class ListNamespacesCommand : Command
|
|||||||
AaruConsole.DebugWriteLine(MODULE_NAME, "--verbose={0}", verbose);
|
AaruConsole.DebugWriteLine(MODULE_NAME, "--verbose={0}", verbose);
|
||||||
Statistics.AddCommand("list-namespaces");
|
Statistics.AddCommand("list-namespaces");
|
||||||
|
|
||||||
PluginBase plugins = PluginBase.Singleton;
|
PluginBase.Init();
|
||||||
|
PluginRegister plugins = PluginRegister.Singleton;
|
||||||
|
|
||||||
foreach(KeyValuePair<string, Type> kvp in plugins.ReadOnlyFilesystems)
|
foreach(KeyValuePair<string, Type> kvp in plugins.ReadOnlyFilesystems)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -42,6 +42,7 @@ using System.Text;
|
|||||||
using System.Text.Json;
|
using System.Text.Json;
|
||||||
using System.Threading;
|
using System.Threading;
|
||||||
using System.Xml.Serialization;
|
using System.Xml.Serialization;
|
||||||
|
using Aaru.CommonTypes;
|
||||||
using Aaru.CommonTypes.AaruMetadata;
|
using Aaru.CommonTypes.AaruMetadata;
|
||||||
using Aaru.CommonTypes.Enums;
|
using Aaru.CommonTypes.Enums;
|
||||||
using Aaru.CommonTypes.Interfaces;
|
using Aaru.CommonTypes.Interfaces;
|
||||||
@@ -369,7 +370,8 @@ sealed class DumpMediaCommand : Command
|
|||||||
if(isResponse)
|
if(isResponse)
|
||||||
eject = true;
|
eject = true;
|
||||||
|
|
||||||
PluginBase plugins = PluginBase.Singleton;
|
PluginBase.Init();
|
||||||
|
PluginRegister plugins = PluginRegister.Singleton;
|
||||||
List<IBaseWritableImage> candidates = new();
|
List<IBaseWritableImage> candidates = new();
|
||||||
string extension = Path.GetExtension(outputPath);
|
string extension = Path.GetExtension(outputPath);
|
||||||
|
|
||||||
@@ -638,7 +640,7 @@ sealed class DumpMediaCommand : Command
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
plugins = PluginBase.Singleton;
|
plugins = PluginRegister.Singleton;
|
||||||
candidates = new List<IBaseWritableImage>();
|
candidates = new List<IBaseWritableImage>();
|
||||||
|
|
||||||
// Try extension
|
// Try extension
|
||||||
|
|||||||
Reference in New Issue
Block a user