mirror of
https://github.com/aaru-dps/Aaru.git
synced 2025-12-16 19:24:25 +00:00
Move optical disc exclusive methods to new interfaces.
This commit is contained in:
@@ -85,7 +85,7 @@ namespace DiscImageChef.Core.Devices.Dumping
|
||||
/// <exception cref="InvalidOperationException">If the resume file is invalid</exception>
|
||||
/// <exception cref="ArgumentOutOfRangeException">If the track type is unknown (never)</exception>
|
||||
internal static void Dump(Device dev, string devicePath,
|
||||
IWritableImage outputPlugin, ushort retryPasses,
|
||||
IWritableOpticalImage outputPlugin, ushort retryPasses,
|
||||
bool force, bool dumpRaw,
|
||||
bool persistent, bool stopOnError,
|
||||
ref MediaType dskType,
|
||||
|
||||
@@ -77,7 +77,7 @@ namespace DiscImageChef.Core.Devices.Dumping
|
||||
/// <param name="formatOptions">Formats to pass to output file plugin</param>
|
||||
/// <exception cref="NotImplementedException">If trying to dump GOD or WOD, or XGDs without a Kreon drive</exception>
|
||||
internal static void Dump(Device dev, string devicePath,
|
||||
IWritableImage outputPlugin, ushort retryPasses,
|
||||
IWritableOpticalImage outputPlugin, ushort retryPasses,
|
||||
bool force, bool dumpRaw,
|
||||
bool persistent, bool stopOnError, ref MediaType dskType,
|
||||
ref Resume resume, ref DumpLog dumpLog,
|
||||
|
||||
@@ -208,16 +208,20 @@ namespace DiscImageChef.Core.Devices.Dumping
|
||||
return;
|
||||
}
|
||||
|
||||
DumpUmd(dev, devicePath, outputPlugin, retryPasses, force, persistent, stopOnError,
|
||||
ref resume, ref dumpLog,
|
||||
encoding, outputPrefix, outputPath, formatOptions, preSidecar, skip, nometadata, notrim);
|
||||
if(outputPlugin is IWritableOpticalImage opticalPlugin)
|
||||
DumpUmd(dev, devicePath, opticalPlugin, retryPasses, force, persistent, stopOnError,
|
||||
ref resume,
|
||||
ref dumpLog, encoding, outputPrefix, outputPath, formatOptions, preSidecar, skip,
|
||||
nometadata,
|
||||
notrim);
|
||||
else DicConsole.ErrorWriteLine("The specified plugin does not support storing optical disc images.");
|
||||
}
|
||||
|
||||
static void DumpUmd(Device dev, string devicePath,
|
||||
IWritableImage outputPlugin, ushort retryPasses, bool force,
|
||||
bool persistent, bool stopOnError,
|
||||
ref Resume resume, ref DumpLog dumpLog,
|
||||
Encoding encoding, string outputPrefix,
|
||||
static void DumpUmd(Device dev, string devicePath,
|
||||
IWritableOpticalImage outputPlugin, ushort retryPasses,
|
||||
bool force, bool persistent,
|
||||
bool stopOnError, ref Resume resume, ref DumpLog dumpLog,
|
||||
Encoding encoding, string outputPrefix,
|
||||
string outputPath,
|
||||
Dictionary<string, string> formatOptions, CICMMetadataType preSidecar,
|
||||
uint skip,
|
||||
|
||||
@@ -283,19 +283,28 @@ namespace DiscImageChef.Core.Devices.Dumping
|
||||
double imageWriteDuration = 0;
|
||||
|
||||
if(opticalDisc)
|
||||
outputPlugin.SetTracks(new List<Track>
|
||||
{
|
||||
new Track
|
||||
{
|
||||
if(outputPlugin is IWritableOpticalImage opticalPlugin)
|
||||
opticalPlugin.SetTracks(new List<Track>
|
||||
{
|
||||
TrackBytesPerSector = (int)blockSize,
|
||||
TrackEndSector = blocks - 1,
|
||||
TrackSequence = 1,
|
||||
TrackRawBytesPerSector = (int)blockSize,
|
||||
TrackSubchannelType = TrackSubchannelType.None,
|
||||
TrackSession = 1,
|
||||
TrackType = TrackType.Data
|
||||
}
|
||||
});
|
||||
new Track
|
||||
{
|
||||
TrackBytesPerSector = (int)blockSize,
|
||||
TrackEndSector = blocks - 1,
|
||||
TrackSequence = 1,
|
||||
TrackRawBytesPerSector = (int)blockSize,
|
||||
TrackSubchannelType = TrackSubchannelType.None,
|
||||
TrackSession = 1,
|
||||
TrackType = TrackType.Data
|
||||
}
|
||||
});
|
||||
else
|
||||
{
|
||||
dumpLog.WriteLine("The specified plugin does not support storing optical disc images..");
|
||||
DicConsole.ErrorWriteLine("The specified plugin does not support storing optical disc images.");
|
||||
return;
|
||||
}
|
||||
}
|
||||
else if(decMode.HasValue)
|
||||
{
|
||||
bool setGeometry = false;
|
||||
|
||||
@@ -209,9 +209,12 @@ namespace DiscImageChef.Core.Devices.Dumping
|
||||
Ssc.Dump(dev, outputPrefix, devicePath, ref resume, ref dumpLog, preSidecar);
|
||||
return;
|
||||
case PeripheralDeviceTypes.MultiMediaDevice:
|
||||
Mmc.Dump(dev, devicePath, outputPlugin, retryPasses, force, dumpRaw, persistent, stopOnError,
|
||||
ref dskType, ref resume, ref dumpLog, dumpFirstTrackPregap, encoding, outputPrefix,
|
||||
outputPath, formatOptions, preSidecar, skip, nometadata, notrim);
|
||||
if(outputPlugin is IWritableOpticalImage opticalPlugin)
|
||||
Mmc.Dump(dev, devicePath, opticalPlugin, retryPasses, force, dumpRaw, persistent, stopOnError,
|
||||
ref dskType, ref resume, ref dumpLog, dumpFirstTrackPregap, encoding, outputPrefix,
|
||||
outputPath, formatOptions, preSidecar, skip, nometadata, notrim);
|
||||
else
|
||||
DicConsole.ErrorWriteLine("The specified plugin does not support storing optical disc images.");
|
||||
return;
|
||||
default:
|
||||
Sbc.Dump(dev, devicePath, outputPlugin, retryPasses, force, dumpRaw, persistent, stopOnError, null,
|
||||
|
||||
@@ -83,7 +83,7 @@ namespace DiscImageChef.Core.Devices.Dumping
|
||||
/// dump
|
||||
/// </exception>
|
||||
internal static void Dump(Device dev, string devicePath,
|
||||
IWritableImage outputPlugin, ushort retryPasses,
|
||||
IWritableOpticalImage outputPlugin, ushort retryPasses,
|
||||
bool force, bool dumpRaw,
|
||||
bool persistent, bool stopOnError,
|
||||
Dictionary<MediaTagType, byte[]> mediaTags, ref MediaType dskType,
|
||||
|
||||
@@ -64,9 +64,15 @@ namespace DiscImageChef.Core
|
||||
{
|
||||
List<EntropyResults> entropyResultses = new List<EntropyResults>();
|
||||
|
||||
if(!(inputFormat is IOpticalMediaImage opticalMediaImage))
|
||||
{
|
||||
DicConsole.ErrorWriteLine("The selected image does not support tracks.");
|
||||
return entropyResultses.ToArray();
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
List<Track> inputTracks = inputFormat.Tracks;
|
||||
List<Track> inputTracks = opticalMediaImage.Tracks;
|
||||
|
||||
InitProgressEvent?.Invoke();
|
||||
|
||||
@@ -93,7 +99,7 @@ namespace DiscImageChef.Core
|
||||
?.Invoke($"Entropying sector {i + 1} of track {currentTrack.TrackSequence}",
|
||||
(long)(currentTrack.TrackEndSector - (i + 1)),
|
||||
(long)trackEntropy.Sectors);
|
||||
byte[] sector = inputFormat.ReadSector(i, currentTrack.TrackSequence);
|
||||
byte[] sector = opticalMediaImage.ReadSector(i, currentTrack.TrackSequence);
|
||||
|
||||
if(duplicatedSectors)
|
||||
{
|
||||
|
||||
@@ -550,46 +550,49 @@ namespace DiscImageChef.Core
|
||||
DicConsole.WriteLine();
|
||||
}
|
||||
|
||||
try
|
||||
if(imageFormat is IOpticalMediaImage opticalImage)
|
||||
{
|
||||
if(imageFormat.Sessions != null && imageFormat.Sessions.Count > 0)
|
||||
try
|
||||
{
|
||||
DicConsole.WriteLine("Image sessions:");
|
||||
DicConsole.WriteLine("{0,-9}{1,-13}{2,-12}{3,-12}{4,-12}", "Session", "First track", "Last track",
|
||||
"Start", "End");
|
||||
DicConsole.WriteLine("=========================================================");
|
||||
foreach(Session session in imageFormat.Sessions)
|
||||
DicConsole.WriteLine("{0,-9}{1,-13}{2,-12}{3,-12}{4,-12}", session.SessionSequence,
|
||||
session.StartTrack, session.EndTrack, session.StartSector,
|
||||
session.EndSector);
|
||||
DicConsole.WriteLine();
|
||||
if(opticalImage.Sessions != null && opticalImage.Sessions.Count > 0)
|
||||
{
|
||||
DicConsole.WriteLine("Image sessions:");
|
||||
DicConsole.WriteLine("{0,-9}{1,-13}{2,-12}{3,-12}{4,-12}", "Session", "First track",
|
||||
"Last track", "Start", "End");
|
||||
DicConsole.WriteLine("=========================================================");
|
||||
foreach(Session session in opticalImage.Sessions)
|
||||
DicConsole.WriteLine("{0,-9}{1,-13}{2,-12}{3,-12}{4,-12}", session.SessionSequence,
|
||||
session.StartTrack, session.EndTrack, session.StartSector,
|
||||
session.EndSector);
|
||||
DicConsole.WriteLine();
|
||||
}
|
||||
}
|
||||
catch
|
||||
{
|
||||
// ignored
|
||||
}
|
||||
}
|
||||
catch
|
||||
{
|
||||
// ignored
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
if(imageFormat.Tracks != null && imageFormat.Tracks.Count > 0)
|
||||
try
|
||||
{
|
||||
DicConsole.WriteLine("Image tracks:");
|
||||
DicConsole.WriteLine("{0,-7}{1,-17}{2,-6}{3,-8}{4,-12}{5,-8}{6,-12}{7,-12}", "Track", "Type", "Bps",
|
||||
"Raw bps", "Subchannel", "Pregap", "Start", "End");
|
||||
DicConsole
|
||||
.WriteLine("=================================================================================");
|
||||
foreach(Track track in imageFormat.Tracks)
|
||||
DicConsole.WriteLine("{0,-7}{1,-17}{2,-6}{3,-8}{4,-12}{5,-8}{6,-12}{7,-12}",
|
||||
track.TrackSequence, track.TrackType, track.TrackBytesPerSector,
|
||||
track.TrackRawBytesPerSector, track.TrackSubchannelType, track.TrackPregap,
|
||||
track.TrackStartSector, track.TrackEndSector);
|
||||
DicConsole.WriteLine();
|
||||
if(opticalImage.Tracks != null && opticalImage.Tracks.Count > 0)
|
||||
{
|
||||
DicConsole.WriteLine("Image tracks:");
|
||||
DicConsole.WriteLine("{0,-7}{1,-17}{2,-6}{3,-8}{4,-12}{5,-8}{6,-12}{7,-12}", "Track", "Type",
|
||||
"Bps", "Raw bps", "Subchannel", "Pregap", "Start", "End");
|
||||
DicConsole
|
||||
.WriteLine("=================================================================================");
|
||||
foreach(Track track in opticalImage.Tracks)
|
||||
DicConsole.WriteLine("{0,-7}{1,-17}{2,-6}{3,-8}{4,-12}{5,-8}{6,-12}{7,-12}",
|
||||
track.TrackSequence, track.TrackType, track.TrackBytesPerSector,
|
||||
track.TrackRawBytesPerSector, track.TrackSubchannelType,
|
||||
track.TrackPregap, track.TrackStartSector, track.TrackEndSector);
|
||||
DicConsole.WriteLine();
|
||||
}
|
||||
}
|
||||
catch
|
||||
{
|
||||
// ignored
|
||||
}
|
||||
}
|
||||
catch
|
||||
{
|
||||
// ignored
|
||||
}
|
||||
|
||||
if(imageFormat.DumpHardware == null) return;
|
||||
|
||||
@@ -57,8 +57,8 @@ namespace DiscImageChef.Core
|
||||
List<ulong> checkedLocations = new List<ulong>();
|
||||
|
||||
// Getting all partitions from device (e.g. tracks)
|
||||
if(image.Info.HasPartitions)
|
||||
foreach(Partition imagePartition in image.Partitions)
|
||||
if(image is IPartitionableMediaImage partitionableImage)
|
||||
foreach(Partition imagePartition in partitionableImage.Partitions)
|
||||
{
|
||||
foreach(IPartition partitionPlugin in plugins.PartPluginsList.Values)
|
||||
if(partitionPlugin.GetInformation(image, out List<Partition> partitions, imagePartition.Start))
|
||||
@@ -131,13 +131,15 @@ namespace DiscImageChef.Core
|
||||
}
|
||||
|
||||
// Be sure that device partitions are not excluded if not mapped by any scheme...
|
||||
if(image.Info.HasPartitions)
|
||||
partitionableImage = image as IPartitionableMediaImage;
|
||||
if(!(partitionableImage is null))
|
||||
{
|
||||
List<ulong> startLocations =
|
||||
childPartitions.Select(detectedPartition => detectedPartition.Start).ToList();
|
||||
|
||||
childPartitions.AddRange(image.Partitions.Where(imagePartition =>
|
||||
!startLocations.Contains(imagePartition.Start)));
|
||||
childPartitions.AddRange(partitionableImage.Partitions.Where(imagePartition =>
|
||||
!startLocations.Contains(imagePartition
|
||||
.Start)));
|
||||
}
|
||||
|
||||
Partition[] childArray = childPartitions
|
||||
|
||||
@@ -62,9 +62,11 @@ 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(IMediaImage image, Guid filterId, string imagePath,
|
||||
FileInfo fi, PluginBase plugins,
|
||||
List<ChecksumType> imgChecksums, ref CICMMetadataType sidecar, Encoding encoding)
|
||||
static void OpticalDisc(IOpticalMediaImage image, Guid filterId,
|
||||
string imagePath, FileInfo fi,
|
||||
PluginBase plugins, List<ChecksumType> imgChecksums,
|
||||
ref CICMMetadataType sidecar,
|
||||
Encoding encoding)
|
||||
{
|
||||
sidecar.OpticalDisc = new[]
|
||||
{
|
||||
|
||||
@@ -37,6 +37,7 @@ using System.Text;
|
||||
using DiscImageChef.CommonTypes;
|
||||
using DiscImageChef.CommonTypes.Enums;
|
||||
using DiscImageChef.CommonTypes.Interfaces;
|
||||
using DiscImageChef.Console;
|
||||
using Schemas;
|
||||
|
||||
namespace DiscImageChef.Core
|
||||
@@ -102,7 +103,16 @@ namespace DiscImageChef.Core
|
||||
switch(image.Info.XmlMediaType)
|
||||
{
|
||||
case XmlMediaType.OpticalDisc:
|
||||
OpticalDisc(image, filterId, imagePath, fi, plugins, imgChecksums, ref sidecar, encoding);
|
||||
if(image is IOpticalMediaImage opticalImage)
|
||||
OpticalDisc(opticalImage, filterId, imagePath, fi, plugins, imgChecksums, ref sidecar,
|
||||
encoding);
|
||||
else
|
||||
{
|
||||
DicConsole
|
||||
.ErrorWriteLine("The specified image says it contains an optical media but at the same time says it does not support them.");
|
||||
DicConsole.ErrorWriteLine("Please open an issue at Github.");
|
||||
}
|
||||
|
||||
break;
|
||||
case XmlMediaType.BlockMedia:
|
||||
BlockMedia(image, filterId, imagePath, fi, plugins, imgChecksums, ref sidecar, encoding);
|
||||
|
||||
Reference in New Issue
Block a user