🎨Converted all plugin types to interfaces.

This commit is contained in:
2017-12-26 06:05:12 +00:00
parent a002253fa4
commit f66a0bdd42
295 changed files with 9499 additions and 10414 deletions

View File

@@ -469,10 +469,10 @@ namespace DiscImageChef.Core.Devices.Dumping
(double)blockSize * (double)(blocks + 1) / 1024 / (totalChkDuration / 1000));
PluginBase plugins = new PluginBase();
plugins.RegisterAllPlugins(encoding);
plugins.RegisterAllPlugins();
FiltersList filtersList = new FiltersList();
Filter inputFilter = filtersList.GetFilter(outputPrefix + ".bin");
IFilter inputFilter = filtersList.GetFilter(outputPrefix + ".bin");
if(inputFilter == null)
{
@@ -480,7 +480,7 @@ namespace DiscImageChef.Core.Devices.Dumping
return;
}
ImagePlugin imageFormat = ImageFormat.Detect(inputFilter);
IMediaImage imageFormat = ImageFormat.Detect(inputFilter);
PartitionType[] xmlFileSysInfo = null;
try { if(!imageFormat.OpenImage(inputFilter)) imageFormat = null; }
@@ -513,15 +513,15 @@ namespace DiscImageChef.Core.Devices.Dumping
i, partitions[i].Start, partitions[i].End, partitions[i].Type,
partitions[i].Scheme);
foreach(Filesystem plugin in plugins.PluginsList.Values)
foreach(IFilesystem plugin in plugins.PluginsList.Values)
try
{
if(!plugin.Identify(imageFormat, partitions[i])) continue;
plugin.GetInformation(imageFormat, partitions[i], out _);
lstFs.Add(plugin.XmlFSType);
Statistics.AddFilesystem(plugin.XmlFSType.Type);
dumpLog.WriteLine("Filesystem {0} found.", plugin.XmlFSType.Type);
plugin.GetInformation(imageFormat, partitions[i], out _, encoding);
lstFs.Add(plugin.XmlFsType);
Statistics.AddFilesystem(plugin.XmlFsType.Type);
dumpLog.WriteLine("Filesystem {0} found.", plugin.XmlFsType.Type);
}
#pragma warning disable RECS0022 // A catch clause that catches System.Exception and has an empty body
catch
@@ -548,15 +548,15 @@ namespace DiscImageChef.Core.Devices.Dumping
Size = blocks * blockSize
};
foreach(Filesystem plugin in plugins.PluginsList.Values)
foreach(IFilesystem plugin in plugins.PluginsList.Values)
try
{
if(!plugin.Identify(imageFormat, wholePart)) continue;
plugin.GetInformation(imageFormat, wholePart, out _);
lstFs.Add(plugin.XmlFSType);
Statistics.AddFilesystem(plugin.XmlFSType.Type);
dumpLog.WriteLine("Filesystem {0} found.", plugin.XmlFSType.Type);
plugin.GetInformation(imageFormat, wholePart, out _, encoding);
lstFs.Add(plugin.XmlFsType);
Statistics.AddFilesystem(plugin.XmlFsType.Type);
dumpLog.WriteLine("Filesystem {0} found.", plugin.XmlFsType.Type);
}
#pragma warning disable RECS0022 // A catch clause that catches System.Exception and has an empty body
catch

View File

@@ -594,9 +594,9 @@ namespace DiscImageChef.Core.Devices.Dumping
(double)blockSize * (double)(blocks + 1) / 1024 / (totalChkDuration / 1000));
PluginBase plugins = new PluginBase();
plugins.RegisterAllPlugins(encoding);
plugins.RegisterAllPlugins();
FiltersList filtersList = new FiltersList();
Filter inputFilter = filtersList.GetFilter(outputPrefix + outputExtension);
IFilter inputFilter = filtersList.GetFilter(outputPrefix + outputExtension);
if(inputFilter == null)
{
@@ -604,7 +604,7 @@ namespace DiscImageChef.Core.Devices.Dumping
return;
}
ImagePlugin imageFormat = ImageFormat.Detect(inputFilter);
IMediaImage imageFormat = ImageFormat.Detect(inputFilter);
PartitionType[] xmlFileSysInfo = null;
try { if(!imageFormat.OpenImage(inputFilter)) imageFormat = null; }
@@ -636,17 +636,17 @@ namespace DiscImageChef.Core.Devices.Dumping
i, partitions[i].Start, partitions[i].End, partitions[i].Type,
partitions[i].Scheme);
foreach(Filesystem plugin in plugins.PluginsList.Values)
foreach(IFilesystem plugin in plugins.PluginsList.Values)
try
{
if(!plugin.Identify(imageFormat, partitions[i])) continue;
plugin.GetInformation(imageFormat, partitions[i], out _);
lstFs.Add(plugin.XmlFSType);
Statistics.AddFilesystem(plugin.XmlFSType.Type);
dumpLog.WriteLine("Filesystem {0} found.", plugin.XmlFSType.Type);
plugin.GetInformation(imageFormat, partitions[i], out _, encoding);
lstFs.Add(plugin.XmlFsType);
Statistics.AddFilesystem(plugin.XmlFsType.Type);
dumpLog.WriteLine("Filesystem {0} found.", plugin.XmlFsType.Type);
switch(plugin.XmlFSType.Type)
switch(plugin.XmlFsType.Type)
{
case "Opera":
dskType = MediaType.ThreeDO;
@@ -682,17 +682,17 @@ namespace DiscImageChef.Core.Devices.Dumping
Partition wholePart =
new Partition {Name = "Whole device", Length = blocks, Size = blocks * blockSize};
foreach(Filesystem plugin in plugins.PluginsList.Values)
foreach(IFilesystem plugin in plugins.PluginsList.Values)
try
{
if(!plugin.Identify(imageFormat, wholePart)) continue;
plugin.GetInformation(imageFormat, wholePart, out _);
lstFs.Add(plugin.XmlFSType);
Statistics.AddFilesystem(plugin.XmlFSType.Type);
dumpLog.WriteLine("Filesystem {0} found.", plugin.XmlFSType.Type);
plugin.GetInformation(imageFormat, wholePart, out _, encoding);
lstFs.Add(plugin.XmlFsType);
Statistics.AddFilesystem(plugin.XmlFsType.Type);
dumpLog.WriteLine("Filesystem {0} found.", plugin.XmlFsType.Type);
switch(plugin.XmlFSType.Type)
switch(plugin.XmlFsType.Type)
{
case "Opera":
dskType = MediaType.ThreeDO;

View File

@@ -451,10 +451,10 @@ namespace DiscImageChef.Core.Devices.Dumping
(double)blockSize * (double)(blocks + 1) / 1024 / (totalChkDuration / 1000));
PluginBase plugins = new PluginBase();
plugins.RegisterAllPlugins(encoding);
plugins.RegisterAllPlugins();
FiltersList filtersList = new FiltersList();
Filter inputFilter = filtersList.GetFilter(outputPrefix + ".bin");
IFilter inputFilter = filtersList.GetFilter(outputPrefix + ".bin");
if(inputFilter == null)
{
@@ -462,7 +462,7 @@ namespace DiscImageChef.Core.Devices.Dumping
return;
}
ImagePlugin imageFormat = ImageFormat.Detect(inputFilter);
IMediaImage imageFormat = ImageFormat.Detect(inputFilter);
PartitionType[] xmlFileSysInfo = null;
try { if(!imageFormat.OpenImage(inputFilter)) imageFormat = null; }
@@ -494,15 +494,15 @@ namespace DiscImageChef.Core.Devices.Dumping
i, partitions[i].Start, partitions[i].End, partitions[i].Type,
partitions[i].Scheme);
foreach(Filesystem plugin in plugins.PluginsList.Values)
foreach(IFilesystem plugin in plugins.PluginsList.Values)
try
{
if(!plugin.Identify(imageFormat, partitions[i])) continue;
plugin.GetInformation(imageFormat, partitions[i], out _);
lstFs.Add(plugin.XmlFSType);
Statistics.AddFilesystem(plugin.XmlFSType.Type);
dumpLog.WriteLine("Filesystem {0} found.", plugin.XmlFSType.Type);
plugin.GetInformation(imageFormat, partitions[i], out _, encoding);
lstFs.Add(plugin.XmlFsType);
Statistics.AddFilesystem(plugin.XmlFsType.Type);
dumpLog.WriteLine("Filesystem {0} found.", plugin.XmlFsType.Type);
}
#pragma warning disable RECS0022 // A catch clause that catches System.Exception and has an empty body
catch
@@ -525,15 +525,15 @@ namespace DiscImageChef.Core.Devices.Dumping
Partition wholePart =
new Partition {Name = "Whole device", Length = blocks, Size = blocks * blockSize};
foreach(Filesystem plugin in plugins.PluginsList.Values)
foreach(IFilesystem plugin in plugins.PluginsList.Values)
try
{
if(!plugin.Identify(imageFormat, wholePart)) continue;
plugin.GetInformation(imageFormat, wholePart, out _);
lstFs.Add(plugin.XmlFSType);
Statistics.AddFilesystem(plugin.XmlFSType.Type);
dumpLog.WriteLine("Filesystem {0} found.", plugin.XmlFSType.Type);
plugin.GetInformation(imageFormat, wholePart, out _, encoding);
lstFs.Add(plugin.XmlFsType);
Statistics.AddFilesystem(plugin.XmlFsType.Type);
dumpLog.WriteLine("Filesystem {0} found.", plugin.XmlFsType.Type);
}
#pragma warning disable RECS0022 // A catch clause that catches System.Exception and has an empty body
catch

View File

@@ -794,9 +794,9 @@ namespace DiscImageChef.Core.Devices.Dumping
(double)BLOCK_SIZE * (double)(blocks + 1) / 1024 / (totalChkDuration / 1000));
PluginBase plugins = new PluginBase();
plugins.RegisterAllPlugins(encoding);
plugins.RegisterAllPlugins();
FiltersList filtersList = new FiltersList();
Filter inputFilter = filtersList.GetFilter(outputPrefix + ".iso");
IFilter inputFilter = filtersList.GetFilter(outputPrefix + ".iso");
if(inputFilter == null)
{
@@ -804,7 +804,7 @@ namespace DiscImageChef.Core.Devices.Dumping
return;
}
ImagePlugin imageFormat = ImageFormat.Detect(inputFilter);
IMediaImage imageFormat = ImageFormat.Detect(inputFilter);
PartitionType[] xmlFileSysInfo = null;
try { if(!imageFormat.OpenImage(inputFilter)) imageFormat = null; }
@@ -836,17 +836,17 @@ namespace DiscImageChef.Core.Devices.Dumping
i, partitions[i].Start, partitions[i].End, partitions[i].Type,
partitions[i].Scheme);
foreach(Filesystem plugin in plugins.PluginsList.Values)
foreach(IFilesystem plugin in plugins.PluginsList.Values)
try
{
if(!plugin.Identify(imageFormat, partitions[i])) continue;
plugin.GetInformation(imageFormat, partitions[i], out _);
lstFs.Add(plugin.XmlFSType);
Statistics.AddFilesystem(plugin.XmlFSType.Type);
dumpLog.WriteLine("Filesystem {0} found.", plugin.XmlFSType.Type);
plugin.GetInformation(imageFormat, partitions[i], out _, encoding);
lstFs.Add(plugin.XmlFsType);
Statistics.AddFilesystem(plugin.XmlFsType.Type);
dumpLog.WriteLine("Filesystem {0} found.", plugin.XmlFsType.Type);
switch(plugin.XmlFSType.Type)
switch(plugin.XmlFsType.Type)
{
case "Opera":
dskType = MediaType.ThreeDO;
@@ -882,17 +882,17 @@ namespace DiscImageChef.Core.Devices.Dumping
Partition wholePart =
new Partition {Name = "Whole device", Length = blocks, Size = blocks * BLOCK_SIZE};
foreach(Filesystem plugin in plugins.PluginsList.Values)
foreach(IFilesystem plugin in plugins.PluginsList.Values)
try
{
if(!plugin.Identify(imageFormat, wholePart)) continue;
plugin.GetInformation(imageFormat, wholePart, out _);
lstFs.Add(plugin.XmlFSType);
Statistics.AddFilesystem(plugin.XmlFSType.Type);
dumpLog.WriteLine("Filesystem {0} found.", plugin.XmlFSType.Type);
plugin.GetInformation(imageFormat, wholePart, out _, encoding);
lstFs.Add(plugin.XmlFsType);
Statistics.AddFilesystem(plugin.XmlFsType.Type);
dumpLog.WriteLine("Filesystem {0} found.", plugin.XmlFsType.Type);
switch(plugin.XmlFSType.Type)
switch(plugin.XmlFsType.Type)
{
case "Opera":
dskType = MediaType.ThreeDO;

View File

@@ -46,7 +46,7 @@ namespace DiscImageChef.Core
/// <param name="imagePlugin">Media image</param>
/// <param name="idPlugins">List of plugins recognizing the filesystem</param>
/// <param name="partition">Partition</param>
public static void Identify(ImagePlugin imagePlugin, out List<string> idPlugins, Partition partition)
public static void Identify(IMediaImage imagePlugin, out List<string> idPlugins, Partition partition)
{
PluginBase plugins = new PluginBase();
plugins.RegisterAllPlugins();

View File

@@ -45,18 +45,18 @@ namespace DiscImageChef.Core
/// </summary>
/// <param name="imageFilter">Filter</param>
/// <returns>Detected image plugin</returns>
public static ImagePlugin Detect(Filter imageFilter)
public static IMediaImage Detect(IFilter imageFilter)
{
try
{
PluginBase plugins = new PluginBase();
plugins.RegisterAllPlugins();
ImagePlugin imageFormat = null;
IMediaImage imageFormat = null;
// Check all but RAW plugin
foreach(ImagePlugin imageplugin in plugins.ImagePluginsList.Values.Where(imageplugin =>
imageplugin.PluginUuid !=
foreach(IMediaImage imageplugin in plugins.ImagePluginsList.Values.Where(imageplugin =>
imageplugin.Id !=
new
Guid("12345678-AAAA-BBBB-CCCC-123456789000"))
)
@@ -77,8 +77,8 @@ namespace DiscImageChef.Core
if(imageFormat != null) return imageFormat;
// Check only RAW plugin
foreach(ImagePlugin imageplugin in plugins.ImagePluginsList.Values.Where(imageplugin =>
imageplugin.PluginUuid ==
foreach(IMediaImage imageplugin in plugins.ImagePluginsList.Values.Where(imageplugin =>
imageplugin.Id ==
new
Guid("12345678-AAAA-BBBB-CCCC-123456789000"))
)

View File

@@ -49,7 +49,7 @@ namespace DiscImageChef.Core
/// </summary>
/// <param name="image">Image</param>
/// <returns>List of found partitions</returns>
public static List<Partition> GetAll(ImagePlugin image)
public static List<Partition> GetAll(IMediaImage image)
{
PluginBase plugins = new PluginBase();
plugins.RegisterAllPlugins();
@@ -58,10 +58,10 @@ namespace DiscImageChef.Core
List<ulong> checkedLocations = new List<ulong>();
// Getting all partitions from device (e.g. tracks)
if(image.ImageInfo.HasPartitions)
if(image.Info.HasPartitions)
foreach(Partition imagePartition in image.Partitions)
{
foreach(PartitionPlugin partitionPlugin in plugins.PartPluginsList.Values)
foreach(IPartition partitionPlugin in plugins.PartPluginsList.Values)
if(partitionPlugin.GetInformation(image, out List<Partition> partitions, imagePartition.Start))
{
foundPartitions.AddRange(partitions);
@@ -74,7 +74,7 @@ namespace DiscImageChef.Core
// Getting all partitions at start of device
else
{
foreach(PartitionPlugin partitionPlugin in plugins.PartPluginsList.Values)
foreach(IPartition partitionPlugin in plugins.PartPluginsList.Values)
if(partitionPlugin.GetInformation(image, out List<Partition> partitions, 0))
{
foundPartitions.AddRange(partitions);
@@ -95,7 +95,7 @@ namespace DiscImageChef.Core
List<Partition> childs = new List<Partition>();
foreach(PartitionPlugin partitionPlugin in plugins.PartPluginsList.Values)
foreach(IPartition partitionPlugin in plugins.PartPluginsList.Values)
{
DicConsole.DebugWriteLine("Partitions", "Trying {0} @ {1}", partitionPlugin.Name,
foundPartitions[0].Start);
@@ -130,7 +130,7 @@ namespace DiscImageChef.Core
}
// Be sure that device partitions are not excluded if not mapped by any scheme...
if(image.ImageInfo.HasPartitions)
if(image.Info.HasPartitions)
{
List<ulong> startLocations =
childPartitions.Select(detectedPartition => detectedPartition.Start).ToList();

View File

@@ -32,6 +32,7 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using System.Text;
using DiscImageChef.Console;
@@ -49,86 +50,75 @@ namespace DiscImageChef.Core
/// <summary>
/// List of all media image plugins
/// </summary>
public SortedDictionary<string, ImagePlugin> ImagePluginsList;
public SortedDictionary<string, IMediaImage> ImagePluginsList;
/// <summary>
/// List of all partition plugins
/// </summary>
public SortedDictionary<string, PartitionPlugin> PartPluginsList;
public SortedDictionary<string, IPartition> PartPluginsList;
/// <summary>
/// List of all filesystem plugins
/// </summary>
public SortedDictionary<string, Filesystem> PluginsList;
public SortedDictionary<string, IFilesystem> PluginsList;
/// <summary>
/// Initializes the plugins lists
/// </summary>
public PluginBase()
{
PluginsList = new SortedDictionary<string, Filesystem>();
PartPluginsList = new SortedDictionary<string, PartitionPlugin>();
ImagePluginsList = new SortedDictionary<string, ImagePlugin>();
PluginsList = new SortedDictionary<string, IFilesystem>();
PartPluginsList = new SortedDictionary<string, IPartition>();
ImagePluginsList = new SortedDictionary<string, IMediaImage>();
}
/// <summary>
/// Fills the plugins lists
/// </summary>
/// <param name="encoding">Which encoding to pass to plugins</param>
public void RegisterAllPlugins(Encoding encoding = null)
public void RegisterAllPlugins()
{
Assembly assembly = Assembly.GetAssembly(typeof(ImagePlugin));
Assembly assembly = Assembly.GetAssembly(typeof(IMediaImage));
foreach(Type type in assembly.GetTypes())
foreach(Type type in assembly.GetTypes().Where(t => t.GetInterfaces().Contains(typeof(IMediaImage))))
try
{
if(!type.IsSubclassOf(typeof(ImagePlugin))) continue;
ImagePlugin plugin = (ImagePlugin)type.GetConstructor(Type.EmptyTypes)?.Invoke(new object[] { });
IMediaImage plugin = (IMediaImage)type.GetConstructor(Type.EmptyTypes)?.Invoke(new object[] { });
RegisterImagePlugin(plugin);
}
catch(Exception exception) { DicConsole.ErrorWriteLine("Exception {0}", exception); }
assembly = Assembly.GetAssembly(typeof(PartitionPlugin));
assembly = Assembly.GetAssembly(typeof(IPartition));
foreach(Type type in assembly.GetTypes())
foreach(Type type in assembly.GetTypes().Where(t => t.GetInterfaces().Contains(typeof(IPartition))))
try
{
if(!type.IsSubclassOf(typeof(PartitionPlugin))) continue;
PartitionPlugin plugin =
(PartitionPlugin)type.GetConstructor(Type.EmptyTypes)?.Invoke(new object[] { });
IPartition plugin =
(IPartition)type.GetConstructor(Type.EmptyTypes)?.Invoke(new object[] { });
RegisterPartPlugin(plugin);
}
catch(Exception exception) { DicConsole.ErrorWriteLine("Exception {0}", exception); }
assembly = Assembly.GetAssembly(typeof(Filesystem));
assembly = Assembly.GetAssembly(typeof(IFilesystem));
foreach(Type type in assembly.GetTypes())
foreach(Type type in assembly.GetTypes().Where(t => t.GetInterfaces().Contains(typeof(IFilesystem))))
try
{
if(!type.IsSubclassOf(typeof(Filesystem))) continue;
Filesystem plugin;
if(encoding != null)
plugin = (Filesystem)type.GetConstructor(new[] {encoding.GetType()})
?.Invoke(new object[] {encoding});
else plugin = (Filesystem)type.GetConstructor(Type.EmptyTypes)?.Invoke(new object[] { });
IFilesystem plugin = (IFilesystem)type.GetConstructor(Type.EmptyTypes)?.Invoke(new object[] { });
RegisterPlugin(plugin);
}
catch(Exception exception) { DicConsole.ErrorWriteLine("Exception {0}", exception); }
}
void RegisterImagePlugin(ImagePlugin plugin)
void RegisterImagePlugin(IMediaImage plugin)
{
if(!ImagePluginsList.ContainsKey(plugin.Name.ToLower()))
ImagePluginsList.Add(plugin.Name.ToLower(), plugin);
}
void RegisterPlugin(Filesystem plugin)
void RegisterPlugin(IFilesystem plugin)
{
if(!PluginsList.ContainsKey(plugin.Name.ToLower())) PluginsList.Add(plugin.Name.ToLower(), plugin);
}
void RegisterPartPlugin(PartitionPlugin partplugin)
void RegisterPartPlugin(IPartition partplugin)
{
if(!PartPluginsList.ContainsKey(partplugin.Name.ToLower()))
PartPluginsList.Add(partplugin.Name.ToLower(), partplugin);

View File

@@ -33,6 +33,7 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Text;
using DiscImageChef.DiscImages;
using Schemas;
@@ -51,8 +52,8 @@ namespace DiscImageChef.Core
/// <param name="plugins">Image plugins</param>
/// <param name="imgChecksums">List of image checksums</param>
/// <param name="sidecar">Metadata sidecar</param>
static void AudioMedia(ImagePlugin image, Guid filterId, string imagePath, FileInfo fi, PluginBase plugins,
List<ChecksumType> imgChecksums, ref CICMMetadataType sidecar)
static void AudioMedia(IMediaImage image, Guid filterId, string imagePath, FileInfo fi, PluginBase plugins,
List<ChecksumType> imgChecksums, ref CICMMetadataType sidecar, Encoding encoding)
{
sidecar.AudioMedia = new[]
{
@@ -67,14 +68,14 @@ namespace DiscImageChef.Core
Value = Path.GetFileName(imagePath)
},
Size = fi.Length,
Sequence = new SequenceType {MediaTitle = image.ImageInfo.MediaTitle}
Sequence = new SequenceType {MediaTitle = image.Info.MediaTitle}
}
};
if(image.ImageInfo.MediaSequence != 0 && image.ImageInfo.LastMediaSequence != 0)
if(image.Info.MediaSequence != 0 && image.Info.LastMediaSequence != 0)
{
sidecar.AudioMedia[0].Sequence.MediaSequence = image.ImageInfo.MediaSequence;
sidecar.AudioMedia[0].Sequence.TotalMedia = image.ImageInfo.LastMediaSequence;
sidecar.AudioMedia[0].Sequence.MediaSequence = image.Info.MediaSequence;
sidecar.AudioMedia[0].Sequence.TotalMedia = image.Info.LastMediaSequence;
}
else
{

View File

@@ -34,6 +34,7 @@ using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using DiscImageChef.CommonTypes;
using DiscImageChef.Console;
using DiscImageChef.Decoders.ATA;
@@ -60,8 +61,8 @@ namespace DiscImageChef.Core
/// <param name="plugins">Image plugins</param>
/// <param name="imgChecksums">List of image checksums</param>
/// <param name="sidecar">Metadata sidecar</param>
static void BlockMedia(ImagePlugin image, Guid filterId, string imagePath, FileInfo fi, PluginBase plugins,
List<ChecksumType> imgChecksums, ref CICMMetadataType sidecar)
static void BlockMedia(IMediaImage image, Guid filterId, string imagePath, FileInfo fi, PluginBase plugins,
List<ChecksumType> imgChecksums, ref CICMMetadataType sidecar, Encoding encoding)
{
sidecar.BlockMedia = new[]
{
@@ -76,14 +77,14 @@ namespace DiscImageChef.Core
Value = Path.GetFileName(imagePath)
},
Size = fi.Length,
Sequence = new SequenceType {MediaTitle = image.ImageInfo.MediaTitle}
Sequence = new SequenceType {MediaTitle = image.Info.MediaTitle}
}
};
if(image.ImageInfo.MediaSequence != 0 && image.ImageInfo.LastMediaSequence != 0)
if(image.Info.MediaSequence != 0 && image.Info.LastMediaSequence != 0)
{
sidecar.BlockMedia[0].Sequence.MediaSequence = image.ImageInfo.MediaSequence;
sidecar.BlockMedia[0].Sequence.TotalMedia = image.ImageInfo.LastMediaSequence;
sidecar.BlockMedia[0].Sequence.MediaSequence = image.Info.MediaSequence;
sidecar.BlockMedia[0].Sequence.TotalMedia = image.Info.LastMediaSequence;
}
else
{
@@ -91,7 +92,7 @@ namespace DiscImageChef.Core
sidecar.BlockMedia[0].Sequence.TotalMedia = 1;
}
foreach(MediaTagType tagType in image.ImageInfo.ReadableMediaTags)
foreach(MediaTagType tagType in image.Info.ReadableMediaTags)
switch(tagType)
{
case MediaTagType.ATAPI_IDENTIFY:
@@ -242,7 +243,7 @@ namespace DiscImageChef.Core
}
// If there is only one track, and it's the same as the image file (e.g. ".iso" files), don't re-checksum.
if(image.PluginUuid == new Guid("12345678-AAAA-BBBB-CCCC-123456789000") &&
if(image.Id == new Guid("12345678-AAAA-BBBB-CCCC-123456789000") &&
filterId == new Guid("12345678-AAAA-BBBB-CCCC-123456789000"))
sidecar.BlockMedia[0].ContentChecksums = sidecar.BlockMedia[0].Checksums;
else
@@ -253,7 +254,7 @@ namespace DiscImageChef.Core
//goto skipImageChecksum;
uint sectorsToRead = 512;
ulong sectors = image.ImageInfo.Sectors;
ulong sectors = image.Info.Sectors;
ulong doneSectors = 0;
InitProgress2();
@@ -287,17 +288,17 @@ namespace DiscImageChef.Core
EndProgress2();
}
MediaType.MediaTypeToString(image.ImageInfo.MediaType, out string dskType, out string dskSubType);
MediaType.MediaTypeToString(image.Info.MediaType, out string dskType, out string dskSubType);
sidecar.BlockMedia[0].DiskType = dskType;
sidecar.BlockMedia[0].DiskSubType = dskSubType;
Statistics.AddMedia(image.ImageInfo.MediaType, false);
Statistics.AddMedia(image.Info.MediaType, false);
sidecar.BlockMedia[0].Dimensions = Dimensions.DimensionsFromMediaType(image.ImageInfo.MediaType);
sidecar.BlockMedia[0].Dimensions = Dimensions.DimensionsFromMediaType(image.Info.MediaType);
sidecar.BlockMedia[0].LogicalBlocks = (long)image.ImageInfo.Sectors;
sidecar.BlockMedia[0].LogicalBlockSize = (int)image.ImageInfo.SectorSize;
sidecar.BlockMedia[0].LogicalBlocks = (long)image.Info.Sectors;
sidecar.BlockMedia[0].LogicalBlockSize = (int)image.Info.SectorSize;
// TODO: Detect it
sidecar.BlockMedia[0].PhysicalBlockSize = (int)image.ImageInfo.SectorSize;
sidecar.BlockMedia[0].PhysicalBlockSize = (int)image.Info.SectorSize;
UpdateStatus("Checking filesystems...");
@@ -321,14 +322,14 @@ namespace DiscImageChef.Core
};
List<FileSystemType> lstFs = new List<FileSystemType>();
foreach(Filesystem plugin in plugins.PluginsList.Values)
foreach(IFilesystem plugin in plugins.PluginsList.Values)
try
{
if(!plugin.Identify(image, partitions[i])) continue;
plugin.GetInformation(image, partitions[i], out _);
lstFs.Add(plugin.XmlFSType);
Statistics.AddFilesystem(plugin.XmlFSType.Type);
plugin.GetInformation(image, partitions[i], out _, encoding);
lstFs.Add(plugin.XmlFsType);
Statistics.AddFilesystem(plugin.XmlFsType.Type);
}
#pragma warning disable RECS0022 // A catch clause that catches System.Exception and has an empty body
catch
@@ -345,26 +346,26 @@ namespace DiscImageChef.Core
sidecar.BlockMedia[0].FileSystemInformation[0] = new PartitionType
{
StartSector = 0,
EndSector = (int)(image.ImageInfo.Sectors - 1)
EndSector = (int)(image.Info.Sectors - 1)
};
Partition wholePart = new Partition
{
Name = "Whole device",
Length = image.ImageInfo.Sectors,
Size = image.ImageInfo.Sectors * image.ImageInfo.SectorSize
Length = image.Info.Sectors,
Size = image.Info.Sectors * image.Info.SectorSize
};
List<FileSystemType> lstFs = new List<FileSystemType>();
foreach(Filesystem plugin in plugins.PluginsList.Values)
foreach(IFilesystem plugin in plugins.PluginsList.Values)
try
{
if(!plugin.Identify(image, wholePart)) continue;
plugin.GetInformation(image, wholePart, out _);
lstFs.Add(plugin.XmlFSType);
Statistics.AddFilesystem(plugin.XmlFSType.Type);
plugin.GetInformation(image, wholePart, out _, encoding);
lstFs.Add(plugin.XmlFsType);
Statistics.AddFilesystem(plugin.XmlFsType.Type);
}
#pragma warning disable RECS0022 // A catch clause that catches System.Exception and has an empty body
catch
@@ -376,17 +377,17 @@ namespace DiscImageChef.Core
if(lstFs.Count > 0) sidecar.BlockMedia[0].FileSystemInformation[0].FileSystems = lstFs.ToArray();
}
if(image.ImageInfo.Cylinders > 0 && image.ImageInfo.Heads > 0 && image.ImageInfo.SectorsPerTrack > 0)
if(image.Info.Cylinders > 0 && image.Info.Heads > 0 && image.Info.SectorsPerTrack > 0)
{
sidecar.BlockMedia[0].CylindersSpecified = true;
sidecar.BlockMedia[0].HeadsSpecified = true;
sidecar.BlockMedia[0].SectorsPerTrackSpecified = true;
sidecar.BlockMedia[0].Cylinders = image.ImageInfo.Cylinders;
sidecar.BlockMedia[0].Heads = image.ImageInfo.Heads;
sidecar.BlockMedia[0].SectorsPerTrack = image.ImageInfo.SectorsPerTrack;
sidecar.BlockMedia[0].Cylinders = image.Info.Cylinders;
sidecar.BlockMedia[0].Heads = image.Info.Heads;
sidecar.BlockMedia[0].SectorsPerTrack = image.Info.SectorsPerTrack;
}
if(image.ImageInfo.ReadableMediaTags.Contains(MediaTagType.ATA_IDENTIFY))
if(image.Info.ReadableMediaTags.Contains(MediaTagType.ATA_IDENTIFY))
{
Identify.IdentifyDevice? ataId = Identify.Decode(image.ReadDiskTag(MediaTagType.ATA_IDENTIFY));
if(ataId.HasValue)
@@ -414,7 +415,7 @@ namespace DiscImageChef.Core
// TODO: This is more of a hack, redo it planned for >4.0
string trkFormat = null;
switch(image.ImageInfo.MediaType)
switch(image.Info.MediaType)
{
case CommonTypes.MediaType.Apple32SS:
case CommonTypes.MediaType.Apple32DS:
@@ -541,14 +542,14 @@ namespace DiscImageChef.Core
ZZZNoFilter scpFilter = new ZZZNoFilter();
scpFilter.Open(scpFilePath);
if(image.ImageInfo.Heads <= 2 && scpImage.IdentifyImage(scpFilter))
if(image.Info.Heads <= 2 && scpImage.IdentifyImage(scpFilter))
{
try { scpImage.OpenImage(scpFilter); }
catch(NotImplementedException) { }
if(image.ImageInfo.Heads == 2 && scpImage.Header.heads == 0 || image.ImageInfo.Heads == 1 &&
if(image.Info.Heads == 2 && scpImage.Header.heads == 0 || image.Info.Heads == 1 &&
(scpImage.Header.heads == 1 || scpImage.Header.heads == 2))
if(scpImage.Header.end + 1 >= image.ImageInfo.Cylinders)
if(scpImage.Header.end + 1 >= image.Info.Cylinders)
{
List<BlockTrackType> scpBlockTrackTypes = new List<BlockTrackType>();
long currentSector = 0;
@@ -558,8 +559,8 @@ namespace DiscImageChef.Core
{
BlockTrackType scpBlockTrackType = new BlockTrackType
{
Cylinder = t / image.ImageInfo.Heads,
Head = t % image.ImageInfo.Heads,
Cylinder = t / image.Info.Heads,
Head = t % image.Info.Heads,
Image = new ImageType
{
format = scpImage.ImageFormat,
@@ -568,13 +569,13 @@ namespace DiscImageChef.Core
}
};
if(scpBlockTrackType.Cylinder < image.ImageInfo.Cylinders)
if(scpBlockTrackType.Cylinder < image.Info.Cylinders)
{
scpBlockTrackType.StartSector = currentSector;
currentSector += image.ImageInfo.SectorsPerTrack;
currentSector += image.Info.SectorsPerTrack;
scpBlockTrackType.EndSector = currentSector - 1;
scpBlockTrackType.Sectors = image.ImageInfo.SectorsPerTrack;
scpBlockTrackType.BytesPerSector = (int)image.ImageInfo.SectorSize;
scpBlockTrackType.Sectors = image.Info.SectorsPerTrack;
scpBlockTrackType.BytesPerSector = (int)image.Info.SectorSize;
scpBlockTrackType.Format = trkFormat;
}
@@ -598,11 +599,11 @@ namespace DiscImageChef.Core
else
DicConsole
.ErrorWriteLine("SuperCardPro image do not contain same number of tracks ({0}) than disk image ({1}), ignoring...",
scpImage.Header.end + 1, image.ImageInfo.Cylinders);
scpImage.Header.end + 1, image.Info.Cylinders);
else
DicConsole
.ErrorWriteLine("SuperCardPro image do not contain same number of heads ({0}) than disk image ({1}), ignoring...",
2, image.ImageInfo.Heads);
2, image.Info.Heads);
}
}
#endregion
@@ -630,24 +631,24 @@ namespace DiscImageChef.Core
KryoFlux kfImage = new KryoFlux();
ZZZNoFilter kfFilter = new ZZZNoFilter();
kfFilter.Open(kfFile);
if(image.ImageInfo.Heads <= 2 && kfImage.IdentifyImage(kfFilter))
if(image.Info.Heads <= 2 && kfImage.IdentifyImage(kfFilter))
{
try { kfImage.OpenImage(kfFilter); }
catch(NotImplementedException) { }
if(kfImage.ImageInfo.Heads == image.ImageInfo.Heads)
if(kfImage.ImageInfo.Cylinders >= image.ImageInfo.Cylinders)
if(kfImage.Info.Heads == image.Info.Heads)
if(kfImage.Info.Cylinders >= image.Info.Cylinders)
{
List<BlockTrackType> kfBlockTrackTypes = new List<BlockTrackType>();
long currentSector = 0;
foreach(KeyValuePair<byte, Filter> kvp in kfImage.tracks)
foreach(KeyValuePair<byte, IFilter> kvp in kfImage.tracks)
{
BlockTrackType kfBlockTrackType = new BlockTrackType
{
Cylinder = kvp.Key / image.ImageInfo.Heads,
Head = kvp.Key % image.ImageInfo.Heads,
Cylinder = kvp.Key / image.Info.Heads,
Head = kvp.Key % image.Info.Heads,
Image = new ImageType
{
format = kfImage.ImageFormat,
@@ -660,13 +661,13 @@ namespace DiscImageChef.Core
}
};
if(kfBlockTrackType.Cylinder < image.ImageInfo.Cylinders)
if(kfBlockTrackType.Cylinder < image.Info.Cylinders)
{
kfBlockTrackType.StartSector = currentSector;
currentSector += image.ImageInfo.SectorsPerTrack;
currentSector += image.Info.SectorsPerTrack;
kfBlockTrackType.EndSector = currentSector - 1;
kfBlockTrackType.Sectors = image.ImageInfo.SectorsPerTrack;
kfBlockTrackType.BytesPerSector = (int)image.ImageInfo.SectorSize;
kfBlockTrackType.Sectors = image.Info.SectorsPerTrack;
kfBlockTrackType.BytesPerSector = (int)image.Info.SectorSize;
kfBlockTrackType.Format = trkFormat;
}
@@ -686,11 +687,11 @@ namespace DiscImageChef.Core
else
DicConsole
.ErrorWriteLine("KryoFlux image do not contain same number of tracks ({0}) than disk image ({1}), ignoring...",
kfImage.ImageInfo.Cylinders, image.ImageInfo.Cylinders);
kfImage.Info.Cylinders, image.Info.Cylinders);
else
DicConsole
.ErrorWriteLine("KryoFluximage do not contain same number of heads ({0}) than disk image ({1}), ignoring...",
kfImage.ImageInfo.Heads, image.ImageInfo.Heads);
kfImage.Info.Heads, image.Info.Heads);
}
}
#endregion
@@ -710,8 +711,8 @@ namespace DiscImageChef.Core
try { dfiImage.OpenImage(dfiFilter); }
catch(NotImplementedException) { }
if(image.ImageInfo.Heads == dfiImage.ImageInfo.Heads)
if(dfiImage.ImageInfo.Cylinders >= image.ImageInfo.Cylinders)
if(image.Info.Heads == dfiImage.Info.Heads)
if(dfiImage.Info.Cylinders >= image.Info.Cylinders)
{
List<BlockTrackType> dfiBlockTrackTypes = new List<BlockTrackType>();
long currentSector = 0;
@@ -721,18 +722,18 @@ namespace DiscImageChef.Core
{
BlockTrackType dfiBlockTrackType = new BlockTrackType
{
Cylinder = t / image.ImageInfo.Heads,
Head = t % image.ImageInfo.Heads,
Cylinder = t / image.Info.Heads,
Head = t % image.Info.Heads,
Image = new ImageType {format = dfiImage.ImageFormat, Value = Path.GetFileName(dfiFilePath)}
};
if(dfiBlockTrackType.Cylinder < image.ImageInfo.Cylinders)
if(dfiBlockTrackType.Cylinder < image.Info.Cylinders)
{
dfiBlockTrackType.StartSector = currentSector;
currentSector += image.ImageInfo.SectorsPerTrack;
currentSector += image.Info.SectorsPerTrack;
dfiBlockTrackType.EndSector = currentSector - 1;
dfiBlockTrackType.Sectors = image.ImageInfo.SectorsPerTrack;
dfiBlockTrackType.BytesPerSector = (int)image.ImageInfo.SectorSize;
dfiBlockTrackType.Sectors = image.Info.SectorsPerTrack;
dfiBlockTrackType.BytesPerSector = (int)image.Info.SectorSize;
dfiBlockTrackType.Format = trkFormat;
}
@@ -756,11 +757,11 @@ namespace DiscImageChef.Core
else
DicConsole
.ErrorWriteLine("DiscFerret image do not contain same number of tracks ({0}) than disk image ({1}), ignoring...",
dfiImage.ImageInfo.Cylinders, image.ImageInfo.Cylinders);
dfiImage.Info.Cylinders, image.Info.Cylinders);
else
DicConsole
.ErrorWriteLine("DiscFerret image do not contain same number of heads ({0}) than disk image ({1}), ignoring...",
dfiImage.ImageInfo.Heads, image.ImageInfo.Heads);
dfiImage.Info.Heads, image.Info.Heads);
#endregion
// TODO: Implement support for getting CHS from SCSI mode pages

View File

@@ -33,6 +33,7 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Text;
using DiscImageChef.DiscImages;
using Schemas;
@@ -51,8 +52,8 @@ namespace DiscImageChef.Core
/// <param name="plugins">Image plugins</param>
/// <param name="imgChecksums">List of image checksums</param>
/// <param name="sidecar">Metadata sidecar</param>
static void LinearMedia(ImagePlugin image, Guid filterId, string imagePath, FileInfo fi, PluginBase plugins,
List<ChecksumType> imgChecksums, ref CICMMetadataType sidecar)
static void LinearMedia(IMediaImage image, Guid filterId, string imagePath, FileInfo fi, PluginBase plugins,
List<ChecksumType> imgChecksums, ref CICMMetadataType sidecar, Encoding encoding)
{
sidecar.LinearMedia = new[]
{

View File

@@ -33,6 +33,7 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Text;
using DiscImageChef.CommonTypes;
using DiscImageChef.Decoders.CD;
using DiscImageChef.Decoders.DVD;
@@ -57,8 +58,8 @@ namespace DiscImageChef.Core
/// <param name="plugins">Image plugins</param>
/// <param name="imgChecksums">List of image checksums</param>
/// <param name="sidecar">Metadata sidecar</param>
static void OpticalDisc(ImagePlugin image, Guid filterId, string imagePath, FileInfo fi, PluginBase plugins,
List<ChecksumType> imgChecksums, ref CICMMetadataType sidecar)
static void OpticalDisc(IMediaImage image, Guid filterId, string imagePath, FileInfo fi, PluginBase plugins,
List<ChecksumType> imgChecksums, ref CICMMetadataType sidecar, Encoding encoding)
{
sidecar.OpticalDisc = new[]
{
@@ -73,14 +74,14 @@ namespace DiscImageChef.Core
Value = Path.GetFileName(imagePath)
},
Size = fi.Length,
Sequence = new SequenceType {MediaTitle = image.ImageInfo.MediaTitle}
Sequence = new SequenceType {MediaTitle = image.Info.MediaTitle}
}
};
if(image.ImageInfo.MediaSequence != 0 && image.ImageInfo.LastMediaSequence != 0)
if(image.Info.MediaSequence != 0 && image.Info.LastMediaSequence != 0)
{
sidecar.OpticalDisc[0].Sequence.MediaSequence = image.ImageInfo.MediaSequence;
sidecar.OpticalDisc[0].Sequence.TotalMedia = image.ImageInfo.LastMediaSequence;
sidecar.OpticalDisc[0].Sequence.MediaSequence = image.Info.MediaSequence;
sidecar.OpticalDisc[0].Sequence.TotalMedia = image.Info.LastMediaSequence;
}
else
{
@@ -88,9 +89,9 @@ namespace DiscImageChef.Core
sidecar.OpticalDisc[0].Sequence.TotalMedia = 1;
}
MediaType dskType = image.ImageInfo.MediaType;
MediaType dskType = image.Info.MediaType;
foreach(MediaTagType tagType in image.ImageInfo.ReadableMediaTags)
foreach(MediaTagType tagType in image.Info.ReadableMediaTags)
switch(tagType)
{
case MediaTagType.CD_ATIP:
@@ -341,7 +342,7 @@ namespace DiscImageChef.Core
ulong doneSectors = 0;
// If there is only one track, and it's the same as the image file (e.g. ".iso" files), don't re-checksum.
if(image.PluginUuid == new Guid("12345678-AAAA-BBBB-CCCC-123456789000") &&
if(image.Id == new Guid("12345678-AAAA-BBBB-CCCC-123456789000") &&
// Only if filter is none...
(filterId == new Guid("12345678-AAAA-BBBB-CCCC-123456789000") ||
// ...or AppleDouble
@@ -483,16 +484,16 @@ namespace DiscImageChef.Core
};
List<FileSystemType> lstFs = new List<FileSystemType>();
foreach(Filesystem plugin in plugins.PluginsList.Values)
foreach(IFilesystem plugin in plugins.PluginsList.Values)
try
{
if(!plugin.Identify(image, partitions[i])) continue;
plugin.GetInformation(image, partitions[i], out _);
lstFs.Add(plugin.XmlFSType);
Statistics.AddFilesystem(plugin.XmlFSType.Type);
plugin.GetInformation(image, partitions[i], out _, encoding);
lstFs.Add(plugin.XmlFsType);
Statistics.AddFilesystem(plugin.XmlFsType.Type);
switch(plugin.XmlFSType.Type)
switch(plugin.XmlFsType.Type)
{
case "Opera":
dskType = MediaType.ThreeDO;
@@ -535,16 +536,16 @@ namespace DiscImageChef.Core
Size = (ulong)xmlTrk.Size,
Sequence = (ulong)xmlTrk.Sequence.TrackNumber
};
foreach(Filesystem plugin in plugins.PluginsList.Values)
foreach(IFilesystem plugin in plugins.PluginsList.Values)
try
{
if(!plugin.Identify(image, xmlPart)) continue;
plugin.GetInformation(image, xmlPart, out _);
lstFs.Add(plugin.XmlFSType);
Statistics.AddFilesystem(plugin.XmlFSType.Type);
plugin.GetInformation(image, xmlPart, out _, encoding);
lstFs.Add(plugin.XmlFsType);
Statistics.AddFilesystem(plugin.XmlFsType.Type);
switch(plugin.XmlFSType.Type)
switch(plugin.XmlFsType.Type)
{
case "Opera":
dskType = MediaType.ThreeDO;
@@ -593,23 +594,23 @@ namespace DiscImageChef.Core
sidecar.OpticalDisc[0].DiscSubType = dscSubType;
Statistics.AddMedia(dskType, false);
if(!string.IsNullOrEmpty(image.ImageInfo.DriveManufacturer) ||
!string.IsNullOrEmpty(image.ImageInfo.DriveModel) ||
!string.IsNullOrEmpty(image.ImageInfo.DriveFirmwareRevision) ||
!string.IsNullOrEmpty(image.ImageInfo.DriveSerialNumber))
if(!string.IsNullOrEmpty(image.Info.DriveManufacturer) ||
!string.IsNullOrEmpty(image.Info.DriveModel) ||
!string.IsNullOrEmpty(image.Info.DriveFirmwareRevision) ||
!string.IsNullOrEmpty(image.Info.DriveSerialNumber))
sidecar.OpticalDisc[0].DumpHardwareArray = new[]
{
new DumpHardwareType
{
Extents = new[] {new ExtentType {Start = 0, End = image.ImageInfo.Sectors}},
Manufacturer = image.ImageInfo.DriveManufacturer,
Model = image.ImageInfo.DriveModel,
Firmware = image.ImageInfo.DriveFirmwareRevision,
Serial = image.ImageInfo.DriveSerialNumber,
Extents = new[] {new ExtentType {Start = 0, End = image.Info.Sectors}},
Manufacturer = image.Info.DriveManufacturer,
Model = image.Info.DriveModel,
Firmware = image.Info.DriveFirmwareRevision,
Serial = image.Info.DriveSerialNumber,
Software = new SoftwareType
{
Name = image.ImageInfo.Application,
Version = image.ImageInfo.ApplicationVersion
Name = image.Info.Application,
Version = image.Info.ApplicationVersion
}
}
};

View File

@@ -49,11 +49,11 @@ namespace DiscImageChef.Core
/// <param name="filterId">Filter uuid</param>
/// <param name="encoding">Encoding for analysis</param>
/// <returns>The metadata sidecar</returns>
public static CICMMetadataType Create(ImagePlugin image, string imagePath, Guid filterId, Encoding encoding)
public static CICMMetadataType Create(IMediaImage image, string imagePath, Guid filterId, Encoding encoding)
{
CICMMetadataType sidecar = new CICMMetadataType();
PluginBase plugins = new PluginBase();
plugins.RegisterAllPlugins(encoding);
plugins.RegisterAllPlugins();
FileInfo fi = new FileInfo(imagePath);
FileStream fs = new FileStream(imagePath, FileMode.Open, FileAccess.Read);
@@ -93,19 +93,19 @@ namespace DiscImageChef.Core
List<ChecksumType> imgChecksums = imgChkWorker.End();
switch(image.ImageInfo.XmlMediaType)
switch(image.Info.XmlMediaType)
{
case XmlMediaType.OpticalDisc:
OpticalDisc(image, filterId, imagePath, fi, plugins, imgChecksums, ref sidecar);
OpticalDisc(image, filterId, imagePath, fi, plugins, imgChecksums, ref sidecar, encoding);
break;
case XmlMediaType.BlockMedia:
BlockMedia(image, filterId, imagePath, fi, plugins, imgChecksums, ref sidecar);
BlockMedia(image, filterId, imagePath, fi, plugins, imgChecksums, ref sidecar, encoding);
break;
case XmlMediaType.LinearMedia:
LinearMedia(image, filterId, imagePath, fi, plugins, imgChecksums, ref sidecar);
LinearMedia(image, filterId, imagePath, fi, plugins, imgChecksums, ref sidecar, encoding);
break;
case XmlMediaType.AudioMedia:
AudioMedia(image, filterId, imagePath, fi, plugins, imgChecksums, ref sidecar);
AudioMedia(image, filterId, imagePath, fi, plugins, imgChecksums, ref sidecar, encoding);
break;
}