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 + (outputPlugin as IWritableOpticalImage).SetTracks(new List { new Track { @@ -316,9 +264,10 @@ namespace DiscImageChef.Core.Devices.Dumping TrackEndSector = blocks - 1, TrackSequence = 1, TrackRawBytesPerSector = (int)BLOCK_SIZE, - TrackSubchannelType = TrackSubchannelType.None, - TrackSession = 1, - TrackType = TrackType.Data + TrackSubchannelType = + TrackSubchannelType.None, + TrackSession = 1, + TrackType = TrackType.Data } }); @@ -704,13 +653,7 @@ namespace DiscImageChef.Core.Devices.Dumping Statistics.AddMedia(DSK_TYPE, true); } - void DumpMs(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 DumpMs() { const ushort SBC_PROFILE = 0x0001; const uint BLOCK_SIZE = 512; diff --git a/DiscImageChef.Core/Devices/Dumping/SBC.cs b/DiscImageChef.Core/Devices/Dumping/SBC.cs index 438157f98..2bff29e26 100644 --- a/DiscImageChef.Core/Devices/Dumping/SBC.cs +++ b/DiscImageChef.Core/Devices/Dumping/SBC.cs @@ -34,7 +34,6 @@ 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; @@ -78,16 +77,7 @@ namespace DiscImageChef.Core.Devices.Dumping /// Path to output file /// Formats to pass to output file plugin /// If the resume file is invalid - internal void Sbc(Device dev, string devicePath, - IWritableImage outputPlugin, ushort retryPasses, bool force, - bool dumpRaw, bool persistent, - bool stopOnError, Dictionary mediaTags, - ref MediaType dskType, bool opticalDisc, - ref Resume resume, ref DumpLog dumpLog, - Encoding encoding, string outputPrefix, - string outputPath, - Dictionary formatOptions, CICMMetadataType preSidecar, uint skip, - bool nometadata, bool notrim) + internal void Sbc(Dictionary mediaTags, ref MediaType dskType, bool opticalDisc) { bool sense; byte scsiMediumType = 0; diff --git a/DiscImageChef.Core/Devices/Dumping/SCSI.cs b/DiscImageChef.Core/Devices/Dumping/SCSI.cs index 79d415657..64bb418c9 100644 --- a/DiscImageChef.Core/Devices/Dumping/SCSI.cs +++ b/DiscImageChef.Core/Devices/Dumping/SCSI.cs @@ -31,16 +31,10 @@ // ****************************************************************************/ using System; -using System.Collections.Generic; -using System.Text; using System.Threading; +using DiscImageChef.CommonTypes; using DiscImageChef.CommonTypes.Interfaces; -using DiscImageChef.CommonTypes.Metadata; -using DiscImageChef.Core.Logging; using DiscImageChef.Decoders.SCSI; -using DiscImageChef.Devices; -using Schemas; -using MediaType = DiscImageChef.CommonTypes.MediaType; namespace DiscImageChef.Core.Devices.Dumping { @@ -69,15 +63,7 @@ namespace DiscImageChef.Core.Devices.Dumping /// Path to output file /// Formats to pass to output file plugin /// If you asked to dump long sectors from a SCSI Streaming device - 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 formatOptions, CICMMetadataType preSidecar, - uint skip, - bool nometadata, bool notrim) + public void Scsi() { MediaType dskType = MediaType.Unknown; int resets = 0; @@ -226,24 +212,16 @@ namespace DiscImageChef.Core.Devices.Dumping case PeripheralDeviceTypes.SequentialAccess: if(dumpRaw) throw new ArgumentException("Tapes cannot be dumped raw."); - Ssc(dev, outputPrefix, devicePath, ref resume, ref dumpLog, preSidecar); + Ssc(); return; case PeripheralDeviceTypes.MultiMediaDevice: - if(outputPlugin is IWritableOpticalImage opticalPlugin) - Mmc(dev, devicePath, opticalPlugin, 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(ref dskType, dumpFirstTrackPregap); else StoppingErrorMessage ?.Invoke("The specified plugin does not support storing optical disc images."); return; default: - 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); + Sbc(null, ref dskType, false); break; } } diff --git a/DiscImageChef.Core/Devices/Dumping/SSC.cs b/DiscImageChef.Core/Devices/Dumping/SSC.cs index 1440a1670..72ac5a6e4 100644 --- a/DiscImageChef.Core/Devices/Dumping/SSC.cs +++ b/DiscImageChef.Core/Devices/Dumping/SSC.cs @@ -57,9 +57,7 @@ namespace DiscImageChef.Core.Devices.Dumping /// Prefix for output data files /// Information for dump resuming /// Dump logger - internal void Ssc(Device dev, string outputPrefix, string devicePath, ref Resume resume, - ref DumpLog dumpLog, - CICMMetadataType preSidecar) + internal void Ssc() { FixedSense? fxSense; bool aborted; diff --git a/DiscImageChef.Core/Devices/Dumping/SecureDigital.cs b/DiscImageChef.Core/Devices/Dumping/SecureDigital.cs index 2b52bb50c..aba29ea33 100644 --- a/DiscImageChef.Core/Devices/Dumping/SecureDigital.cs +++ b/DiscImageChef.Core/Devices/Dumping/SecureDigital.cs @@ -34,7 +34,6 @@ 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; @@ -43,7 +42,6 @@ using DiscImageChef.CommonTypes.Interfaces; using DiscImageChef.CommonTypes.Metadata; using DiscImageChef.Core.Logging; using DiscImageChef.Decoders.MMC; -using DiscImageChef.Devices; using Schemas; using MediaType = DiscImageChef.CommonTypes.MediaType; @@ -72,15 +70,7 @@ namespace DiscImageChef.Core.Devices.Dumping /// Path to output file /// Formats to pass to output file plugin /// If you asked to dump long sectors from a SCSI Streaming device - public void SecureDigital(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 SecureDigital() { bool aborted; diff --git a/DiscImageChef.Core/Devices/Dumping/XGD.cs b/DiscImageChef.Core/Devices/Dumping/XGD.cs index b7f534399..71fbb7ac2 100644 --- a/DiscImageChef.Core/Devices/Dumping/XGD.cs +++ b/DiscImageChef.Core/Devices/Dumping/XGD.cs @@ -34,7 +34,6 @@ 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; @@ -82,17 +81,7 @@ namespace DiscImageChef.Core.Devices.Dumping /// If the provided resume does not correspond with the current in progress /// dump /// - internal void Xgd(Device dev, string devicePath, - IWritableOpticalImage outputPlugin, ushort retryPasses, - bool force, bool dumpRaw, - bool persistent, bool stopOnError, - Dictionary mediaTags, ref MediaType dskType, - ref Resume resume, - ref DumpLog dumpLog, Encoding encoding, - string outputPrefix, string outputPath, - Dictionary formatOptions, CICMMetadataType preSidecar, - uint skip, - bool nometadata, bool notrim) + internal void Xgd(Dictionary mediaTags, ref MediaType dskType) { bool sense; const uint BLOCK_SIZE = 2048; @@ -382,7 +371,7 @@ namespace DiscImageChef.Core.Devices.Dumping if(currentTry == null || extents == null) throw new NotImplementedException("Could not process resume file, not continuing..."); - outputPlugin.SetTracks(new List + (outputPlugin as IWritableOpticalImage).SetTracks(new List { new Track { @@ -390,9 +379,10 @@ namespace DiscImageChef.Core.Devices.Dumping TrackEndSector = blocks - 1, TrackSequence = 1, TrackRawBytesPerSector = (int)BLOCK_SIZE, - TrackSubchannelType = TrackSubchannelType.None, - TrackSession = 1, - TrackType = TrackType.Data + TrackSubchannelType = + TrackSubchannelType.None, + TrackSession = 1, + TrackType = TrackType.Data } }); diff --git a/DiscImageChef.Gui/Forms/frmDump.xeto.cs b/DiscImageChef.Gui/Forms/frmDump.xeto.cs index d30bbb90b..87565932c 100644 --- a/DiscImageChef.Gui/Forms/frmDump.xeto.cs +++ b/DiscImageChef.Gui/Forms/frmDump.xeto.cs @@ -398,6 +398,7 @@ namespace DiscImageChef.Gui.Forms } Statistics.AddDevice(dev); + Statistics.AddCommand("dump-media"); if(!(cmbFormat.SelectedValue is IWritableImage outputFormat)) { @@ -445,67 +446,23 @@ namespace DiscImageChef.Gui.Forms parsedOptions.Add(key, value); } - Dump dumper = new Dump(); + Dump dumper = new Dump(chkResume.Checked == true, dev, devicePath, outputFormat, + (ushort)stpRetries.Value, + chkForce.Checked == true, false, chkPersistent.Checked == true, + chkStopOnError.Checked == true, resume, dumpLog, encoding, outputPrefix, + txtDestination.Text, parsedOptions, sidecar, (uint)stpSkipped.Value, + chkExistingMetadata.Checked == false, chkTrim.Checked == false, + chkTrack1Pregap.Checked == true); - switch(dev.Type) - { - case DeviceType.ATA: - dumper.Ata(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, chkTrim.Checked == false); - break; - case DeviceType.MMC: - case DeviceType.SecureDigital: - 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, - chkTrim.Checked == false); - break; - case DeviceType.NVMe: - 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, - (uint)stpSkipped.Value, chkExistingMetadata.Checked == false, chkTrim.Checked == false); - break; - case DeviceType.ATAPI: - case DeviceType.SCSI: - dumper.Scsi(dev, devicePath, outputFormat, (ushort)stpRetries.Value, chkForce.Checked == true, - false, /*options.Raw,*/ - chkPersistent.Checked == true, - chkStopOnError.Checked == true, ref resume, ref dumpLog, - chkTrack1Pregap.Checked == true, - encoding, outputPrefix, txtDestination.Text, - parsedOptions, sidecar, (uint)stpSkipped.Value, chkExistingMetadata.Checked == false, - chkTrim.Checked == false); - break; - default: - dumpLog.WriteLine("Unknown device type."); - dumpLog.Close(); - MessageBox.Show("Unknown device type.", MessageBoxType.Error); - return; - } + /*dumper.UpdateStatus += Progress.UpdateStatus; + dumper.ErrorMessage += Progress.ErrorMessage; + dumper.StoppingErrorMessage += Progress.ErrorMessage; + dumper.UpdateProgress += Progress.UpdateProgress; + dumper.PulseProgress += Progress.PulseProgress; + dumper.InitProgress += Progress.InitProgress; + dumper.EndProgress += Progress.EndProgress;*/ - if(resume != null && chkResume.Checked == true) - { - 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(); - } - - dumpLog.Close(); - - Statistics.AddCommand("dump-media"); + dumper.Start(); dev.Close(); } diff --git a/DiscImageChef/Commands/DumpMedia.cs b/DiscImageChef/Commands/DumpMedia.cs index 7788b3168..975c3fbe6 100644 --- a/DiscImageChef/Commands/DumpMedia.cs +++ b/DiscImageChef/Commands/DumpMedia.cs @@ -294,7 +294,9 @@ namespace DiscImageChef.Commands DicConsole.WriteLine("Output image format: {0}.", outputFormat.Name); } - Dump dumper = new Dump(); + Dump dumper = new Dump(doResume, dev, devicePath, outputFormat, retryPasses, force, false, persistent, + stopOnError, resume, dumpLog, encoding, outputPrefix, outputFile, parsedOptions, + sidecar, (uint)skip, noMetadata, noTrim, firstTrackPregap); dumper.UpdateStatus += Progress.UpdateStatus; dumper.ErrorMessage += Progress.ErrorMessage; dumper.StoppingErrorMessage += Progress.ErrorMessage; @@ -303,56 +305,8 @@ namespace DiscImageChef.Commands dumper.InitProgress += Progress.InitProgress; dumper.EndProgress += Progress.EndProgress; - if(dev.IsUsb && dev.UsbVendorId == 0x054C && - (dev.UsbProductId == 0x01C8 || dev.UsbProductId == 0x01C9 || dev.UsbProductId == 0x02D2)) - dumper.PlayStationPortable(dev, devicePath, outputFormat, retryPasses, force, persistent, stopOnError, - ref resume, ref dumpLog, encoding, outputPrefix, outputFile, parsedOptions, - sidecar, (uint)skip, noMetadata, noTrim); - else - switch(dev.Type) - { - case DeviceType.ATA: - dumper.Ata(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.MMC: - case DeviceType.SecureDigital: - 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: - 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: - 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; - default: - dumpLog.WriteLine("Unknown device type."); - dumpLog.Close(); - throw new NotSupportedException("Unknown device type."); - } + dumper.Start(); - if(resume != null && doResume) - { - 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); - xs = new XmlSerializer(resume.GetType()); - xs.Serialize(fs, resume); - fs.Close(); - } - - dumpLog.Close(); dev.Close(); return (int)ErrorNumber.NoError; }