mirror of
https://github.com/aaru-dps/Aaru.git
synced 2025-12-16 19:24:25 +00:00
* README.md: * DiscImageChef.sln: * DiscImageChef/Commands/Ls.cs: * DiscImageChef.Filters/GZip.cs: * DiscImageChef.DiscImages/BLU.cs: * DiscImageChef.DiscImages/VHD.cs: * DiscImageChef.DiscImages/VDI.cs: * DiscImageChef.DiscImages/QED.cs: * DiscImageChef.DiscImages/DIM.cs: * DiscImageChef.DiscImages/GDI.cs: * DiscImageChef.Filters/Filter.cs: * DiscImageChef/Commands/Decode.cs: * DiscImageChef.DiscImages/QCOW.cs: * DiscImageChef.Filters/Filters.cs: * DiscImageChef/Core/Statistics.cs: * DiscImageChef.DiscImages/VHDX.cs: * DiscImageChef.DiscImages/Nero.cs: * DiscImageChef/Commands/Verify.cs: * DiscImageChef.DiscImages/UDIF.cs: * DiscImageChef/Commands/Compare.cs: * DiscImageChef/Commands/Analyze.cs: * DiscImageChef.DiscImages/QCOW2.cs: * DiscImageChef/Commands/Entropy.cs: * DiscImageChef/Commands/Formats.cs: * DiscImageChef/Commands/PrintHex.cs: * DiscImageChef.DiscImages/VMware.cs: * DiscImageChef.Settings/Settings.cs: * DiscImageChef/DetectImageFormat.cs: * DiscImageChef/DiscImageChef.csproj: * DiscImageChef.DiscImages/CDRDAO.cs: * DiscImageChef.DiscImages/CPCDSK.cs: * DiscImageChef/Commands/Checksum.cs: * DiscImageChef.DiscImages/CopyQM.cs: * DiscImageChef.DiscImages/CDRWin.cs: * DiscImageChef/Commands/Configure.cs: * DiscImageChef/Commands/DumpMedia.cs: * DiscImageChef/Commands/Statistics.cs: * DiscImageChef.Filters/ZZZNoFilter.cs: * DiscImageChef.DiscImages/TeleDisk.cs: * DiscImageChef.DiscImages/Apple2MG.cs: * DiscImageChef.Filters/OffsetStream.cs: * DiscImageChef.DiscImages/Parallels.cs: * DiscImageChef/Commands/ExtractFiles.cs: * DiscImageChef.DiscImages/DiskCopy42.cs: * DiscImageChef.DiscImages/Alcohol120.cs: * DiscImageChef.DiscImages/ZZZRawImage.cs: * DiscImageChef/Commands/CreateSidecar.cs: * DiscImageChef.DiscImages/ImagePlugin.cs: * DiscImageChef.DiscImages/BlindWrite5.cs: * DiscImageChef.DiscImages/BlindWrite4.cs: * DiscImageChef.Filters/ForcedSeekStream.cs: * DiscImageChef.Filters/Properties/AssemblyInfo.cs: * DiscImageChef.Filters/DiscImageChef.Filters.csproj: * DiscImageChef.DiscImages/DiscImageChef.DiscImages.csproj: Added filters. * DiscImageChef.Filesystems/CPM/Info.cs: Do not throw identification exceptions. * DiscImageChef/Plugins.cs: Sorted plugins lists.
92 lines
3.2 KiB
C#
92 lines
3.2 KiB
C#
// /***************************************************************************
|
|
// The Disc Image Chef
|
|
// ----------------------------------------------------------------------------
|
|
//
|
|
// Filename : Filters.cs
|
|
// Author(s) : Natalia Portillo <claunia@claunia.com>
|
|
//
|
|
// Component : Filters.
|
|
//
|
|
// --[ Description ] ----------------------------------------------------------
|
|
//
|
|
// Enumerates all filters and instantiates the correct one.
|
|
//
|
|
// --[ License ] --------------------------------------------------------------
|
|
//
|
|
// This library is free software; you can redistribute it and/or modify
|
|
// it under the terms of the GNU Lesser General Public License as
|
|
// published by the Free Software Foundation; either version 2.1 of the
|
|
// License, or (at your option) any later version.
|
|
//
|
|
// This library 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
|
|
// Lesser General Public License for more details.
|
|
//
|
|
// You should have received a copy of the GNU Lesser General Public
|
|
// License along with this library; if not, see <http://www.gnu.org/licenses/>.
|
|
//
|
|
// ----------------------------------------------------------------------------
|
|
// Copyright © 2011-2016 Natalia Portillo
|
|
// ****************************************************************************/
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Reflection;
|
|
using DiscImageChef.Console;
|
|
|
|
namespace DiscImageChef.Filters
|
|
{
|
|
public class FiltersList
|
|
{
|
|
public SortedDictionary<string, Filter> filtersList;
|
|
|
|
public FiltersList()
|
|
{
|
|
Assembly assembly = Assembly.GetAssembly(typeof(Filter));
|
|
filtersList = new SortedDictionary<string, Filter>();
|
|
|
|
foreach(Type type in assembly.GetTypes())
|
|
{
|
|
try
|
|
{
|
|
if(type.IsSubclassOf(typeof(Filter)))
|
|
{
|
|
Filter filter = (Filter)type.GetConstructor(Type.EmptyTypes).Invoke(new object[] { });
|
|
if(!filtersList.ContainsKey(filter.Name.ToLower()))
|
|
{
|
|
filtersList.Add(filter.Name.ToLower(), filter);
|
|
}
|
|
}
|
|
}
|
|
catch(Exception exception)
|
|
{
|
|
DicConsole.ErrorWriteLine("Exception {0}", exception);
|
|
}
|
|
}
|
|
}
|
|
|
|
public Filter GetFilter(string path)
|
|
{
|
|
foreach(Filter filter in filtersList.Values)
|
|
{
|
|
if(filter.Identify(path))
|
|
{
|
|
Filter foundFilter = (Filter)filter.GetType().GetConstructor(Type.EmptyTypes).Invoke(new object[] { });
|
|
foundFilter.Open(path);
|
|
|
|
if(foundFilter.IsOpened())
|
|
return foundFilter;
|
|
}
|
|
}
|
|
|
|
return null;
|
|
}
|
|
|
|
public SortedDictionary<string, Filter> GetFiltersList()
|
|
{
|
|
return filtersList;
|
|
}
|
|
}
|
|
}
|
|
|