Move all dumpers to Dump class.

This commit is contained in:
2019-04-19 18:54:25 +01:00
parent 2b771e6761
commit 138830652d
11 changed files with 159 additions and 157 deletions

View File

@@ -61,7 +61,7 @@ namespace DiscImageChef.Core.Devices.Dumping
/// Implement dumping Compact Discs
/// </summary>
// TODO: Barcode and pregaps
static class CompactDisc
partial class Dump
{
/// <summary>
/// Dumps a compact disc
@@ -85,7 +85,7 @@ namespace DiscImageChef.Core.Devices.Dumping
/// <exception cref="NotImplementedException">If trying to dump scrambled sectors</exception>
/// <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,
internal void CompactDisc(Device dev, string devicePath,
IWritableOpticalImage outputPlugin, ushort retryPasses,
bool force, bool dumpRaw,
bool persistent, bool stopOnError,
@@ -1826,7 +1826,7 @@ namespace DiscImageChef.Core.Devices.Dumping
foreach(KeyValuePair<MediaTagType, byte[]> tag in mediaTags)
if(outputPlugin.SupportedMediaTags.Contains(tag.Key))
Mmc.AddMediaTagToSidecar(outputPath, tag, ref sidecar);
AddMediaTagToSidecar(outputPath, tag, ref sidecar);
DicConsole.WriteLine("Writing metadata sidecar");

View File

@@ -54,7 +54,7 @@ namespace DiscImageChef.Core.Devices.Dumping
/// <summary>
/// Implement dumping optical discs from MultiMedia devices
/// </summary>
static class Mmc
partial class Dump
{
/// <summary>
/// Dumps an optical disc
@@ -76,16 +76,16 @@ namespace DiscImageChef.Core.Devices.Dumping
/// <param name="outputPath">Path to output file</param>
/// <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,
internal void Mmc(Device dev, string devicePath,
IWritableOpticalImage outputPlugin, ushort retryPasses,
bool force, bool dumpRaw,
bool persistent, bool stopOnError, ref MediaType dskType,
ref Resume resume, ref DumpLog dumpLog,
bool dumpLeadIn, Encoding encoding,
bool force, bool dumpRaw, bool persistent,
bool stopOnError, ref MediaType dskType,
ref Resume resume, ref DumpLog dumpLog, bool dumpLeadIn,
Encoding encoding,
string outputPrefix, string outputPath,
Dictionary<string, string> formatOptions,
CICMMetadataType preSidecar, uint skip,
bool nometadata, bool notrim)
CICMMetadataType preSidecar, uint skip, bool nometadata,
bool notrim)
{
bool sense;
byte[] tmpBuf;
@@ -197,7 +197,8 @@ namespace DiscImageChef.Core.Devices.Dumping
if(compactDisc)
{
CompactDisc.Dump(dev, devicePath, outputPlugin, retryPasses, force, dumpRaw, persistent, stopOnError,
CompactDisc(dev, devicePath, outputPlugin, retryPasses, force, dumpRaw, persistent,
stopOnError,
ref dskType, ref resume, ref dumpLog, dumpLeadIn, encoding, outputPrefix, outputPath,
formatOptions, preSidecar, skip, nometadata, notrim);
return;
@@ -599,13 +600,16 @@ namespace DiscImageChef.Core.Devices.Dumping
if(isXbox)
{
Xgd.Dump(dev, devicePath, outputPlugin, retryPasses, force, dumpRaw, persistent, stopOnError, mediaTags,
Xgd(dev, devicePath, outputPlugin, retryPasses, force, dumpRaw, persistent,
stopOnError, mediaTags,
ref dskType, ref resume, ref dumpLog, encoding, outputPrefix, outputPath, formatOptions,
preSidecar, skip, nometadata, notrim);
preSidecar,
skip, nometadata, notrim);
return;
}
Sbc.Dump(dev, devicePath, outputPlugin, retryPasses, force, dumpRaw, persistent, stopOnError, mediaTags,
Sbc(dev, devicePath, outputPlugin, retryPasses, force, dumpRaw, persistent, stopOnError,
mediaTags,
ref dskType, true, ref resume, ref dumpLog, encoding, outputPrefix, outputPath, formatOptions,
preSidecar, skip, nometadata, notrim);
}

View File

@@ -39,18 +39,19 @@ using DiscImageChef.Core.Logging;
using DiscImageChef.Devices;
using Schemas;
// ReSharper disable InconsistentNaming
namespace DiscImageChef.Core.Devices.Dumping
{
public static class NvMe
public partial class Dump
{
public static void Dump(Device dev, string devicePath,
IWritableImage outputPlugin, ushort retryPasses,
bool force, bool dumpRaw,
bool persistent, bool stopOnError, ref Resume resume,
ref DumpLog dumpLog, Encoding encoding,
string outputPrefix, string outputPath,
Dictionary<string, string> formatOptions, CICMMetadataType preSidecar,
uint skip,
public void NVMe(Device dev, string devicePath,
IWritableImage outputPlugin, ushort retryPasses, bool force,
bool dumpRaw, bool persistent,
bool stopOnError, ref Resume resume, ref DumpLog dumpLog,
Encoding encoding, string outputPrefix,
string outputPath,
Dictionary<string, string> formatOptions, CICMMetadataType preSidecar, uint skip,
bool nometadata, bool notrim)
{
throw new NotImplementedException("NVMe devices not yet supported.");

View File

@@ -21,7 +21,7 @@ using Version = DiscImageChef.CommonTypes.Interop.Version;
namespace DiscImageChef.Core.Devices.Dumping
{
public static class PlayStationPortable
public partial class Dump
{
static readonly byte[] FatSignature = {0x46, 0x41, 0x54, 0x31, 0x36, 0x20, 0x20, 0x20};
static readonly byte[] IsoExtension = {0x49, 0x53, 0x4F};
@@ -47,15 +47,15 @@ namespace DiscImageChef.Core.Devices.Dumping
/// <param name="nometadata">Don't create metadata sidecar</param>
/// <param name="notrim">Don't trim errors</param>
/// <exception cref="ArgumentException">If you asked to dump long sectors from a SCSI Streaming device</exception>
public static void Dump(Device dev, string devicePath,
public void PlayStationPortable(Device dev, string devicePath,
IWritableImage outputPlugin, ushort retryPasses,
bool force, bool persistent,
bool stopOnError, ref Resume resume, ref DumpLog dumpLog,
Encoding encoding, string outputPrefix,
string outputPath,
bool stopOnError, ref Resume resume,
ref DumpLog dumpLog, Encoding encoding,
string outputPrefix, string outputPath,
Dictionary<string, string> formatOptions, CICMMetadataType preSidecar,
uint skip,
bool nometadata, bool notrim)
uint skip, bool nometadata,
bool notrim)
{
if(!outputPlugin.SupportedMediaTypes.Contains(MediaType.MemoryStickDuo) &&
!outputPlugin.SupportedMediaTypes.Contains(MediaType.MemoryStickProDuo) &&
@@ -217,15 +217,13 @@ namespace DiscImageChef.Core.Devices.Dumping
else DicConsole.ErrorWriteLine("The specified plugin does not support storing optical disc images.");
}
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,
bool nometadata, bool notrim)
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, bool nometadata,
bool notrim)
{
const uint BLOCK_SIZE = 2048;
const MediaType DSK_TYPE = MediaType.UMD;
@@ -682,7 +680,7 @@ namespace DiscImageChef.Core.Devices.Dumping
Statistics.AddMedia(DSK_TYPE, true);
}
static void DumpMs(Device dev, string devicePath, IWritableImage outputPlugin,
void DumpMs(Device dev, string devicePath, IWritableImage outputPlugin,
ushort retryPasses, bool force,
bool persistent, bool stopOnError, ref Resume resume,
ref DumpLog dumpLog, Encoding encoding,

View File

@@ -55,7 +55,7 @@ namespace DiscImageChef.Core.Devices.Dumping
/// <summary>
/// Implements dumping SCSI Block Commands and Reduced Block Commands devices
/// </summary>
static class Sbc
partial class Dump
{
/// <summary>
/// Dumps a SCSI Block Commands device or a Reduced Block Commands devices
@@ -78,16 +78,15 @@ namespace DiscImageChef.Core.Devices.Dumping
/// <param name="outputPath">Path to output file</param>
/// <param name="formatOptions">Formats to pass to output file plugin</param>
/// <exception cref="InvalidOperationException">If the resume file is invalid</exception>
internal static void Dump(Device dev, string devicePath,
IWritableImage outputPlugin, ushort retryPasses,
bool force, bool dumpRaw,
bool persistent, bool stopOnError,
Dictionary<MediaTagType, byte[]> mediaTags, ref MediaType dskType,
bool opticalDisc,
internal void Sbc(Device dev, string devicePath,
IWritableImage outputPlugin, ushort retryPasses, bool force,
bool dumpRaw, bool persistent,
bool stopOnError, Dictionary<MediaTagType, byte[]> mediaTags,
ref MediaType dskType, bool opticalDisc,
ref Resume resume, ref DumpLog dumpLog,
Encoding encoding, string outputPrefix,
string outputPath, Dictionary<string, string> formatOptions,
CICMMetadataType preSidecar, uint skip,
string outputPath,
Dictionary<string, string> formatOptions, CICMMetadataType preSidecar, uint skip,
bool nometadata, bool notrim)
{
bool sense;
@@ -827,7 +826,7 @@ namespace DiscImageChef.Core.Devices.Dumping
foreach(KeyValuePair<MediaTagType, byte[]> tag in mediaTags)
if(outputPlugin.SupportedMediaTags.Contains(tag.Key))
Mmc.AddMediaTagToSidecar(outputPath, tag, ref sidecar);
AddMediaTagToSidecar(outputPath, tag, ref sidecar);
}
else
{
@@ -974,8 +973,7 @@ namespace DiscImageChef.Core.Devices.Dumping
sidecar.BlockMedia[0].DiskSubType = xmlDskSubTyp;
// TODO: Implement device firmware revision
if(!dev.IsRemovable || dev.IsUsb)
if(dev.Type == DeviceType.ATAPI)
sidecar.BlockMedia[0].Interface = "ATAPI";
if(dev.Type == DeviceType.ATAPI) sidecar.BlockMedia[0].Interface = "ATAPI";
else if(dev.IsUsb) sidecar.BlockMedia[0].Interface = "USB";
else if(dev.IsFireWire) sidecar.BlockMedia[0].Interface = "FireWire";
else sidecar.BlockMedia[0].Interface = "SCSI";

View File

@@ -48,7 +48,7 @@ namespace DiscImageChef.Core.Devices.Dumping
/// <summary>
/// Implements dumping SCSI and ATAPI devices
/// </summary>
public static class Scsi
public partial class Dump
{
// TODO: Get cartridge serial number from Certance vendor EVPD
/// <summary>
@@ -70,15 +70,15 @@ namespace DiscImageChef.Core.Devices.Dumping
/// <param name="outputPath">Path to output file</param>
/// <param name="formatOptions">Formats to pass to output file plugin</param>
/// <exception cref="ArgumentException">If you asked to dump long sectors from a SCSI Streaming device</exception>
public static void Dump(Device dev, string devicePath,
IWritableImage outputPlugin, ushort retryPasses,
bool force, bool dumpRaw,
bool persistent, bool stopOnError, ref Resume resume,
ref DumpLog dumpLog, bool dumpFirstTrackPregap,
Encoding encoding, string outputPrefix,
string outputPath, Dictionary<string, string> formatOptions,
CICMMetadataType preSidecar, uint skip, bool nometadata,
bool notrim)
public void Scsi(Device dev, string devicePath,
IWritableImage outputPlugin, ushort retryPasses, bool force,
bool dumpRaw, bool persistent,
bool stopOnError, ref Resume resume, ref DumpLog dumpLog,
bool dumpFirstTrackPregap, Encoding encoding,
string outputPrefix, string outputPath,
Dictionary<string, string> formatOptions, CICMMetadataType preSidecar,
uint skip,
bool nometadata, bool notrim)
{
MediaType dskType = MediaType.Unknown;
int resets = 0;
@@ -206,20 +206,23 @@ namespace DiscImageChef.Core.Devices.Dumping
case PeripheralDeviceTypes.SequentialAccess:
if(dumpRaw) throw new ArgumentException("Tapes cannot be dumped raw.");
Ssc.Dump(dev, outputPrefix, devicePath, ref resume, ref dumpLog, preSidecar);
Ssc(dev, outputPrefix, devicePath, ref resume, ref dumpLog, preSidecar);
return;
case PeripheralDeviceTypes.MultiMediaDevice:
if(outputPlugin is IWritableOpticalImage opticalPlugin)
Mmc.Dump(dev, devicePath, opticalPlugin, retryPasses, force, dumpRaw, persistent, stopOnError,
Mmc(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,
Sbc(dev, devicePath, outputPlugin, retryPasses, force, dumpRaw, persistent,
stopOnError, null,
ref dskType, false, ref resume, ref dumpLog, encoding, outputPrefix, outputPath,
formatOptions, preSidecar, skip, nometadata, notrim);
formatOptions,
preSidecar, skip, nometadata, notrim);
break;
}
}

View File

@@ -48,7 +48,7 @@ using Version = DiscImageChef.CommonTypes.Metadata.Version;
namespace DiscImageChef.Core.Devices.Dumping
{
// TODO: Add support for images
static class Ssc
partial class Dump
{
/// <summary>
/// Dumps the tape from a SCSI Streaming device
@@ -58,9 +58,9 @@ namespace DiscImageChef.Core.Devices.Dumping
/// <param name="outputPrefix">Prefix for output data files</param>
/// <param name="resume">Information for dump resuming</param>
/// <param name="dumpLog">Dump logger</param>
internal static void Dump(Device dev, string outputPrefix, string devicePath,
ref Resume resume,
ref DumpLog dumpLog, CICMMetadataType preSidecar)
internal void Ssc(Device dev, string outputPrefix, string devicePath, ref Resume resume,
ref DumpLog dumpLog,
CICMMetadataType preSidecar)
{
FixedSense? fxSense;
bool aborted;
@@ -506,8 +506,7 @@ namespace DiscImageChef.Core.Devices.Dumping
DicConsole.WriteLine("Blocksize changed to {0} bytes at block {1}", blockSize, currentBlock);
dumpLog.WriteLine("Blocksize changed to {0} bytes at block {1}", blockSize, currentBlock);
sense = dev.Space(out senseBuf, SscSpaceCodes.LogicalBlock, -1, dev.Timeout,
out duration);
sense = dev.Space(out senseBuf, SscSpaceCodes.LogicalBlock, -1, dev.Timeout, out duration);
totalDuration += duration;
if(sense)

View File

@@ -53,7 +53,7 @@ namespace DiscImageChef.Core.Devices.Dumping
/// <summary>
/// Implements dumping a MultiMediaCard or SecureDigital flash card
/// </summary>
public class SecureDigital
public partial class Dump
{
/// <summary>
/// Dumps a MultiMediaCard or SecureDigital flash card
@@ -73,7 +73,7 @@ namespace DiscImageChef.Core.Devices.Dumping
/// <param name="outputPath">Path to output file</param>
/// <param name="formatOptions">Formats to pass to output file plugin</param>
/// <exception cref="ArgumentException">If you asked to dump long sectors from a SCSI Streaming device</exception>
public static void Dump(Device dev, string devicePath,
public void SecureDigital(Device dev, string devicePath,
IWritableImage outputPlugin, ushort retryPasses,
bool force, bool dumpRaw,
bool persistent, bool stopOnError, ref Resume resume,
@@ -156,6 +156,7 @@ namespace DiscImageChef.Core.Devices.Dumping
break;
}
case DeviceType.SecureDigital:
{
dumpLog.WriteLine("Reading CSD");

View File

@@ -57,7 +57,7 @@ namespace DiscImageChef.Core.Devices.Dumping
/// <summary>
/// Implements dumping an Xbox Game Disc using a Kreon drive
/// </summary>
static class Xgd
partial class Dump
{
/// <summary>
/// Dumps an Xbox Game Disc using a Kreon drive
@@ -82,7 +82,7 @@ namespace DiscImageChef.Core.Devices.Dumping
/// If the provided resume does not correspond with the current in progress
/// dump
/// </exception>
internal static void Dump(Device dev, string devicePath,
internal void Xgd(Device dev, string devicePath,
IWritableOpticalImage outputPlugin, ushort retryPasses,
bool force, bool dumpRaw,
bool persistent, bool stopOnError,
@@ -905,7 +905,7 @@ namespace DiscImageChef.Core.Devices.Dumping
(double)BLOCK_SIZE * (double)(blocks + 1) / 1024 / (totalChkDuration / 1000));
foreach(KeyValuePair<MediaTagType, byte[]> tag in mediaTags)
Mmc.AddMediaTagToSidecar(outputPath, tag, ref sidecar);
AddMediaTagToSidecar(outputPath, tag, ref sidecar);
List<(ulong start, string type)> filesystems = new List<(ulong start, string type)>();
if(sidecar.OpticalDisc[0].Track != null)
@@ -934,7 +934,7 @@ namespace DiscImageChef.Core.Devices.Dumping
foreach(KeyValuePair<MediaTagType, byte[]> tag in mediaTags)
if(outputPlugin.SupportedMediaTags.Contains(tag.Key))
Mmc.AddMediaTagToSidecar(outputPath, tag, ref sidecar);
AddMediaTagToSidecar(outputPath, tag, ref sidecar);
DicConsole.WriteLine("Writing metadata sidecar");

View File

@@ -52,7 +52,6 @@ using Eto.Serialization.Xaml;
using Schemas;
using DeviceInfo = DiscImageChef.Core.Devices.Info.DeviceInfo;
using MediaType = DiscImageChef.CommonTypes.MediaType;
using Scsi = DiscImageChef.Core.Devices.Dumping.Scsi;
namespace DiscImageChef.Gui.Forms
{
@@ -459,15 +458,15 @@ namespace DiscImageChef.Gui.Forms
break;
case DeviceType.MMC:
case DeviceType.SecureDigital:
SecureDigital.Dump(dev, devicePath, outputFormat, (ushort)stpRetries.Value,
dumper.SecureDigital(dev, devicePath, outputFormat, (ushort)stpRetries.Value,
chkForce.Checked == true, false, /*options.Raw,*/
chkPersistent.Checked == true, chkStopOnError.Checked == true, ref resume,
ref dumpLog, encoding, outputPrefix, txtDestination.Text, parsedOptions, sidecar,
(uint)stpSkipped.Value, chkExistingMetadata.Checked == false,
ref dumpLog, encoding, outputPrefix, txtDestination.Text, parsedOptions,
sidecar, (uint)stpSkipped.Value, chkExistingMetadata.Checked == false,
chkTrim.Checked == false);
break;
case DeviceType.NVMe:
NvMe.Dump(dev, devicePath, outputFormat, (ushort)stpRetries.Value, chkForce.Checked == true,
dumper.NVMe(dev, devicePath, outputFormat, (ushort)stpRetries.Value, chkForce.Checked == true,
false, /*options.Raw,*/
chkPersistent.Checked == true, chkStopOnError.Checked == true, ref resume, ref dumpLog,
encoding, outputPrefix, txtDestination.Text, parsedOptions, sidecar,
@@ -475,7 +474,7 @@ namespace DiscImageChef.Gui.Forms
break;
case DeviceType.ATAPI:
case DeviceType.SCSI:
Scsi.Dump(dev, devicePath, outputFormat, (ushort)stpRetries.Value, chkForce.Checked == true,
dumper.Scsi(dev, devicePath, outputFormat, (ushort)stpRetries.Value, chkForce.Checked == true,
false, /*options.Raw,*/
chkPersistent.Checked == true,
chkStopOnError.Checked == true, ref resume, ref dumpLog,

View File

@@ -49,7 +49,6 @@ using DiscImageChef.Devices;
using Mono.Options;
using Schemas;
using PlatformID = DiscImageChef.CommonTypes.Interop.PlatformID;
using Scsi = DiscImageChef.Core.Devices.Dumping.Scsi;
namespace DiscImageChef.Commands
{
@@ -306,7 +305,7 @@ namespace DiscImageChef.Commands
if(dev.IsUsb && dev.UsbVendorId == 0x054C &&
(dev.UsbProductId == 0x01C8 || dev.UsbProductId == 0x01C9 || dev.UsbProductId == 0x02D2))
PlayStationPortable.Dump(dev, devicePath, outputFormat, retryPasses, force, persistent, stopOnError,
dumper.PlayStationPortable(dev, devicePath, outputFormat, retryPasses, force, persistent, stopOnError,
ref resume, ref dumpLog, encoding, outputPrefix, outputFile, parsedOptions,
sidecar, (uint)skip, noMetadata, noTrim);
else
@@ -319,18 +318,18 @@ namespace DiscImageChef.Commands
break;
case DeviceType.MMC:
case DeviceType.SecureDigital:
SecureDigital.Dump(dev, devicePath, outputFormat, retryPasses, force, false, /*raw,*/
dumper.SecureDigital(dev, devicePath, outputFormat, retryPasses, force, false, /*raw,*/
persistent, stopOnError, ref resume, ref dumpLog, encoding, outputPrefix,
outputFile, parsedOptions, sidecar, (uint)skip, noMetadata, noTrim);
break;
case DeviceType.NVMe:
NvMe.Dump(dev, devicePath, outputFormat, retryPasses, force, false, /*raw,*/
persistent, stopOnError, ref resume, ref dumpLog, encoding, outputPrefix, outputFile,
parsedOptions, sidecar, (uint)skip, noMetadata, noTrim);
dumper.NVMe(dev, devicePath, outputFormat, retryPasses, force, false, /*raw,*/
persistent, stopOnError, ref resume, ref dumpLog, encoding, outputPrefix,
outputFile, parsedOptions, sidecar, (uint)skip, noMetadata, noTrim);
break;
case DeviceType.ATAPI:
case DeviceType.SCSI:
Scsi.Dump(dev, devicePath, outputFormat, retryPasses, force, false, /*raw,*/
dumper.Scsi(dev, devicePath, outputFormat, retryPasses, force, false, /*raw,*/
persistent, stopOnError, ref resume, ref dumpLog, firstTrackPregap, encoding,
outputPrefix, outputFile, parsedOptions, sidecar, (uint)skip, noMetadata, noTrim);
break;