diff --git a/DiscImageChef.Core/Devices/Dumping/ATA.cs b/DiscImageChef.Core/Devices/Dumping/ATA.cs
index 63953b508..c82910124 100644
--- a/DiscImageChef.Core/Devices/Dumping/ATA.cs
+++ b/DiscImageChef.Core/Devices/Dumping/ATA.cs
@@ -34,19 +34,15 @@ using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
-using System.Text;
using System.Xml.Serialization;
using DiscImageChef.CommonTypes;
using DiscImageChef.CommonTypes.Enums;
using DiscImageChef.CommonTypes.Extents;
using DiscImageChef.CommonTypes.Interfaces;
-using DiscImageChef.CommonTypes.Metadata;
using DiscImageChef.Core.Logging;
using DiscImageChef.Decoders.ATA;
using DiscImageChef.Decoders.PCMCIA;
-using DiscImageChef.Devices;
using Schemas;
-using MediaType = DiscImageChef.CommonTypes.MediaType;
using Tuple = DiscImageChef.Decoders.PCMCIA.Tuple;
namespace DiscImageChef.Core.Devices.Dumping
@@ -59,29 +55,8 @@ namespace DiscImageChef.Core.Devices.Dumping
///
/// Dumps an ATA device
///
- /// Device
- /// Path to the device
- /// Prefix for output log files
- /// Plugin for output file
- /// How many times to retry
- /// Force to continue dump whenever possible
- /// Dump long sectors
- /// Store whatever data the drive returned on error
- /// Stop dump on first error
- /// Information for dump resuming
- /// Dump logger
- /// Encoding to use when analyzing dump
- /// Path to output file
- /// Formats to pass to output file plugin
/// If the resume file is invalid
- public void Ata(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 formatOptions, CICMMetadataType preSidecar, uint skip,
- bool nometadata, bool notrim)
+ public void Ata()
{
bool aborted;
diff --git a/DiscImageChef.Core/Devices/Dumping/CompactDisc.cs b/DiscImageChef.Core/Devices/Dumping/CompactDisc.cs
index 8dadbba11..803821a27 100644
--- a/DiscImageChef.Core/Devices/Dumping/CompactDisc.cs
+++ b/DiscImageChef.Core/Devices/Dumping/CompactDisc.cs
@@ -66,36 +66,11 @@ namespace DiscImageChef.Core.Devices.Dumping
///
/// Dumps a compact disc
///
- /// Device
- /// Path to the device
- /// Prefix for output data files
- /// Plugin for output file
- /// How many times to retry
- /// Force to continue dump whenever possible
- /// Dump scrambled sectors
- /// Store whatever data the drive returned on error
- /// Stop dump on first error
- /// Information for dump resuming
- /// Dump logger
/// Disc type as detected in MMC layer
- /// Try to read and dump as much first track pregap as possible
- /// Path to output file
- /// Formats to pass to output file plugin
- /// Encoding to use when analyzing dump
/// If trying to dump scrambled sectors
/// If the resume file is invalid
/// If the track type is unknown (never)
- internal void CompactDisc(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 dumpFirstTrackPregap, Encoding encoding,
- string outputPrefix, string outputPath,
- Dictionary formatOptions,
- CICMMetadataType preSidecar, uint skip,
- bool nometadata, bool notrim)
+ internal void CompactDisc(ref MediaType dskType, bool dumpFirstTrackPregap)
{
uint subSize;
DateTime start;
@@ -1002,7 +977,7 @@ namespace DiscImageChef.Core.Devices.Dumping
}
// Send tracklist to output plugin. This may fail if subchannel is set but unsupported.
- ret = outputPlugin.SetTracks(tracks.ToList());
+ ret = (outputPlugin as IWritableOpticalImage).SetTracks(tracks.ToList());
if(!ret && supportedSubchannel == MmcSubchannel.None)
{
dumpLog.WriteLine("Error sending tracks to output image, not continuing.");
@@ -1048,7 +1023,7 @@ namespace DiscImageChef.Core.Devices.Dumping
subSize = 0;
blockSize = SECTOR_SIZE + subSize;
for(int t = 0; t < tracks.Length; t++) tracks[t].TrackSubchannelType = TrackSubchannelType.None;
- ret = outputPlugin.SetTracks(tracks.ToList());
+ ret = (outputPlugin as IWritableOpticalImage).SetTracks(tracks.ToList());
if(!ret)
{
dumpLog.WriteLine("Error sending tracks to output image, not continuing.");
diff --git a/DiscImageChef.Core/Devices/Dumping/Dump.cs b/DiscImageChef.Core/Devices/Dumping/Dump.cs
index 27ad04c35..520ee123e 100644
--- a/DiscImageChef.Core/Devices/Dumping/Dump.cs
+++ b/DiscImageChef.Core/Devices/Dumping/Dump.cs
@@ -1,7 +1,132 @@
+using System;
+using System.Collections.Generic;
+using System.IO;
+using System.Text;
+using System.Xml.Serialization;
+using DiscImageChef.CommonTypes.Enums;
+using DiscImageChef.CommonTypes.Interfaces;
+using DiscImageChef.CommonTypes.Metadata;
+using DiscImageChef.Core.Logging;
+using DiscImageChef.Devices;
+using Schemas;
+
namespace DiscImageChef.Core.Devices.Dumping
{
public partial class Dump
{
+ readonly Device dev;
+ readonly string devicePath;
+
+ readonly bool doResume;
+ readonly bool dumpFirstTrackPregap;
+ readonly DumpLog dumpLog;
+ readonly bool dumpRaw;
+ readonly Encoding encoding;
+ readonly bool force;
+ readonly Dictionary formatOptions;
+ readonly bool nometadata;
+ readonly bool notrim;
+ readonly string outputPath;
+ readonly IWritableImage outputPlugin;
+ readonly string outputPrefix;
+ readonly bool persistent;
+ readonly CICMMetadataType preSidecar;
+ readonly ushort retryPasses;
+ readonly bool stopOnError;
+ Resume resume;
+ uint skip;
+
+ ///
+ ///
+ /// Device
+ /// Path to the device
+ /// Prefix for output log files
+ /// Plugin for output file
+ /// How many times to retry
+ /// Force to continue dump whenever possible
+ /// Dump long sectors
+ /// Store whatever data the drive returned on error
+ /// Stop dump on first error
+ /// Information for dump resuming
+ /// Dump logger
+ /// Encoding to use when analyzing dump
+ /// Path to output file
+ /// Formats to pass to output file plugin
+ /// Try to read and dump as much first track pregap as possible
+ public Dump(bool doResume, Device dev, string devicePath,
+ IWritableImage outputPlugin, ushort retryPasses,
+ bool force, bool dumpRaw, bool persistent,
+ bool stopOnError, Resume resume, DumpLog dumpLog,
+ Encoding encoding, string outputPrefix, string outputPath,
+ Dictionary formatOptions,
+ CICMMetadataType preSidecar, uint skip, bool nometadata,
+ bool notrim, bool dumpFirstTrackPregap)
+ {
+ this.doResume = doResume;
+ this.dev = dev;
+ this.devicePath = devicePath;
+ this.outputPlugin = outputPlugin;
+ this.retryPasses = retryPasses;
+ this.force = force;
+ this.dumpRaw = dumpRaw;
+ this.persistent = persistent;
+ this.stopOnError = stopOnError;
+ this.resume = resume;
+ this.dumpLog = dumpLog;
+ this.encoding = encoding;
+ this.outputPrefix = outputPrefix;
+ this.outputPath = outputPath;
+ this.formatOptions = formatOptions;
+ this.preSidecar = preSidecar;
+ this.skip = skip;
+ this.nometadata = nometadata;
+ this.notrim = notrim;
+ this.dumpFirstTrackPregap = dumpFirstTrackPregap;
+ }
+
+ public void Start()
+ {
+ if(dev.IsUsb && dev.UsbVendorId == 0x054C &&
+ (dev.UsbProductId == 0x01C8 || dev.UsbProductId == 0x01C9 || dev.UsbProductId == 0x02D2))
+ PlayStationPortable();
+ else
+ switch(dev.Type)
+ {
+ case DeviceType.ATA:
+ Ata();
+ break;
+ case DeviceType.MMC:
+ case DeviceType.SecureDigital:
+ SecureDigital();
+ break;
+ case DeviceType.NVMe:
+ NVMe();
+ break;
+ case DeviceType.ATAPI:
+ case DeviceType.SCSI:
+ Scsi();
+ break;
+ default:
+ dumpLog.WriteLine("Unknown device type.");
+ dumpLog.Close();
+ throw new NotSupportedException("Unknown device type.");
+ }
+
+ dumpLog.Close();
+
+ if(resume == null || !doResume) return;
+
+ resume.LastWriteDate = DateTime.UtcNow;
+ resume.BadBlocks.Sort();
+
+ if(File.Exists(outputPrefix + ".resume.xml")) File.Delete(outputPrefix + ".resume.xml");
+
+ FileStream fs = new FileStream(outputPrefix + ".resume.xml", FileMode.Create, FileAccess.ReadWrite);
+ XmlSerializer xs = new XmlSerializer(resume.GetType());
+ xs.Serialize(fs, resume);
+ fs.Close();
+ }
+
public event EndProgressHandler EndProgress;
public event InitProgressHandler InitProgress;
public event UpdateStatusHandler UpdateStatus;
diff --git a/DiscImageChef.Core/Devices/Dumping/MMC.cs b/DiscImageChef.Core/Devices/Dumping/MMC.cs
index 27211a499..080305228 100644
--- a/DiscImageChef.Core/Devices/Dumping/MMC.cs
+++ b/DiscImageChef.Core/Devices/Dumping/MMC.cs
@@ -32,12 +32,9 @@
using System;
using System.Collections.Generic;
-using System.Text;
+using DiscImageChef.CommonTypes;
using DiscImageChef.CommonTypes.Enums;
-using DiscImageChef.CommonTypes.Interfaces;
-using DiscImageChef.CommonTypes.Metadata;
using DiscImageChef.Console;
-using DiscImageChef.Core.Logging;
using DiscImageChef.Decoders.Bluray;
using DiscImageChef.Decoders.DVD;
using DiscImageChef.Decoders.SCSI;
@@ -46,7 +43,6 @@ using DiscImageChef.Devices;
using Schemas;
using DDS = DiscImageChef.Decoders.DVD.DDS;
using DMI = DiscImageChef.Decoders.Xbox.DMI;
-using MediaType = DiscImageChef.CommonTypes.MediaType;
using Spare = DiscImageChef.Decoders.DVD.Spare;
namespace DiscImageChef.Core.Devices.Dumping
@@ -76,16 +72,7 @@ namespace DiscImageChef.Core.Devices.Dumping
/// Path to output file
/// Formats to pass to output file plugin
/// If trying to dump GOD or WOD, or XGDs without a Kreon drive
- 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,
- string outputPrefix, string outputPath,
- Dictionary formatOptions,
- CICMMetadataType preSidecar, uint skip, bool nometadata,
- bool notrim)
+ internal void Mmc(ref MediaType dskType, bool dumpLeadIn)
{
bool sense;
byte[] tmpBuf;
@@ -197,10 +184,7 @@ namespace DiscImageChef.Core.Devices.Dumping
if(compactDisc)
{
- CompactDisc(dev, devicePath, outputPlugin, retryPasses, force, dumpRaw, persistent,
- stopOnError,
- ref dskType, ref resume, ref dumpLog, dumpLeadIn, encoding, outputPrefix, outputPath,
- formatOptions, preSidecar, skip, nometadata, notrim);
+ CompactDisc(ref dskType, dumpLeadIn);
return;
}
@@ -600,18 +584,11 @@ namespace DiscImageChef.Core.Devices.Dumping
if(isXbox)
{
- Xgd(dev, devicePath, outputPlugin, retryPasses, force, dumpRaw, persistent,
- stopOnError, mediaTags,
- ref dskType, ref resume, ref dumpLog, encoding, outputPrefix, outputPath, formatOptions,
- preSidecar,
- skip, nometadata, notrim);
+ Xgd(mediaTags, ref dskType);
return;
}
- 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);
+ Sbc(mediaTags, ref dskType, true);
}
internal static void AddMediaTagToSidecar(string outputPath,
diff --git a/DiscImageChef.Core/Devices/Dumping/NVMe.cs b/DiscImageChef.Core/Devices/Dumping/NVMe.cs
index 9175b46a5..5ff8383a6 100644
--- a/DiscImageChef.Core/Devices/Dumping/NVMe.cs
+++ b/DiscImageChef.Core/Devices/Dumping/NVMe.cs
@@ -31,13 +31,6 @@
// ****************************************************************************/
using System;
-using System.Collections.Generic;
-using System.Text;
-using DiscImageChef.CommonTypes.Interfaces;
-using DiscImageChef.CommonTypes.Metadata;
-using DiscImageChef.Core.Logging;
-using DiscImageChef.Devices;
-using Schemas;
// ReSharper disable InconsistentNaming
@@ -45,14 +38,7 @@ namespace DiscImageChef.Core.Devices.Dumping
{
public partial class Dump
{
- 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 formatOptions, CICMMetadataType preSidecar, uint skip,
- bool nometadata, bool notrim)
+ public void NVMe()
{
throw new NotImplementedException("NVMe devices not yet supported.");
}
diff --git a/DiscImageChef.Core/Devices/Dumping/PlayStationPortable.cs b/DiscImageChef.Core/Devices/Dumping/PlayStationPortable.cs
index b4a558ba0..ca99dd56a 100644
--- a/DiscImageChef.Core/Devices/Dumping/PlayStationPortable.cs
+++ b/DiscImageChef.Core/Devices/Dumping/PlayStationPortable.cs
@@ -29,33 +29,8 @@ namespace DiscImageChef.Core.Devices.Dumping
///
/// Dumps a CFW PlayStation Portable UMD
///
- /// Device
- /// Path to the device
- /// Prefix for output data files
- /// Plugin for output file
- /// How many times to retry
- /// Force to continue dump whenever possible
- /// Store whatever data the drive returned on error
- /// Stop dump on first error
- /// Information for dump resuming
- /// Dump logger
- /// Encoding to use when analyzing dump
- /// Path to output file
- /// Formats to pass to output file plugin
- /// Existing sidecar
- /// How many sectors to skip on errors
- /// Don't create metadata sidecar
- /// Don't trim errors
/// If you asked to dump long sectors from a SCSI Streaming device
- 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,
- Dictionary formatOptions, CICMMetadataType preSidecar,
- uint skip, bool nometadata,
- bool notrim)
+ void PlayStationPortable()
{
if(!outputPlugin.SupportedMediaTypes.Contains(MediaType.MemoryStickDuo) &&
!outputPlugin.SupportedMediaTypes.Contains(MediaType.MemoryStickProDuo) &&
@@ -92,11 +67,7 @@ namespace DiscImageChef.Core.Devices.Dumping
// UMDs are always write protected
if(!decoded.Value.Header.WriteProtected)
{
- DumpMs(dev, devicePath, outputPlugin, retryPasses, force, persistent, stopOnError,
- ref resume,
- ref dumpLog, encoding, outputPrefix, outputPath, formatOptions, preSidecar, skip,
- nometadata,
- notrim);
+ DumpMs();
return;
}
@@ -117,11 +88,7 @@ namespace DiscImageChef.Core.Devices.Dumping
// UMDs are stored inside a FAT16 volume
if(!tmp.SequenceEqual(FatSignature))
{
- DumpMs(dev, devicePath, outputPlugin, retryPasses, force, persistent, stopOnError,
- ref resume,
- ref dumpLog, encoding, outputPrefix, outputPath, formatOptions, preSidecar, skip,
- nometadata,
- notrim);
+ DumpMs();
return;
}
@@ -147,11 +114,7 @@ namespace DiscImageChef.Core.Devices.Dumping
if(!tmp.SequenceEqual(IsoExtension))
{
- DumpMs(dev, devicePath, outputPlugin, retryPasses, force, persistent, stopOnError,
- ref resume,
- ref dumpLog, encoding, outputPrefix, outputPath, formatOptions, preSidecar, skip,
- nometadata,
- notrim);
+ DumpMs();
return;
}
@@ -201,30 +164,15 @@ namespace DiscImageChef.Core.Devices.Dumping
if(nextCluster == 0xFFFF) break;
- DumpMs(dev, devicePath, outputPlugin, retryPasses, force, persistent, stopOnError,
- ref resume,
- ref dumpLog, encoding, outputPrefix, outputPath, formatOptions, preSidecar, skip,
- nometadata,
- notrim);
+ DumpMs();
return;
}
- 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);
+ if(outputPlugin is IWritableOpticalImage) DumpUmd();
else StoppingErrorMessage?.Invoke("The specified plugin does not support storing optical disc images.");
}
- 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 formatOptions,
- CICMMetadataType preSidecar, uint skip, bool nometadata,
- bool notrim)
+ void DumpUmd()
{
const uint BLOCK_SIZE = 2048;
const MediaType DSK_TYPE = MediaType.UMD;
@@ -308,7 +256,7 @@ namespace DiscImageChef.Core.Devices.Dumping
start = DateTime.UtcNow;
double imageWriteDuration = 0;
- outputPlugin.SetTracks(new List