mirror of
https://github.com/aaru-dps/Aaru.git
synced 2025-12-16 19:24:25 +00:00
Move common dumper fields to Dump class.
This commit is contained in:
@@ -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
|
||||
/// <summary>
|
||||
/// Dumps an ATA device
|
||||
/// </summary>
|
||||
/// <param name="dev">Device</param>
|
||||
/// <param name="devicePath">Path to the device</param>
|
||||
/// <param name="outputPrefix">Prefix for output log files</param>
|
||||
/// <param name="outputPlugin">Plugin for output file</param>
|
||||
/// <param name="retryPasses">How many times to retry</param>
|
||||
/// <param name="force">Force to continue dump whenever possible</param>
|
||||
/// <param name="dumpRaw">Dump long sectors</param>
|
||||
/// <param name="persistent">Store whatever data the drive returned on error</param>
|
||||
/// <param name="stopOnError">Stop dump on first error</param>
|
||||
/// <param name="resume">Information for dump resuming</param>
|
||||
/// <param name="dumpLog">Dump logger</param>
|
||||
/// <param name="encoding">Encoding to use when analyzing dump</param>
|
||||
/// <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>
|
||||
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<string, string> formatOptions, CICMMetadataType preSidecar, uint skip,
|
||||
bool nometadata, bool notrim)
|
||||
public void Ata()
|
||||
{
|
||||
bool aborted;
|
||||
|
||||
|
||||
@@ -66,36 +66,11 @@ namespace DiscImageChef.Core.Devices.Dumping
|
||||
/// <summary>
|
||||
/// Dumps a compact disc
|
||||
/// </summary>
|
||||
/// <param name="dev">Device</param>
|
||||
/// <param name="devicePath">Path to the device</param>
|
||||
/// <param name="outputPrefix">Prefix for output data files</param>
|
||||
/// <param name="outputPlugin">Plugin for output file</param>
|
||||
/// <param name="retryPasses">How many times to retry</param>
|
||||
/// <param name="force">Force to continue dump whenever possible</param>
|
||||
/// <param name="dumpRaw">Dump scrambled sectors</param>
|
||||
/// <param name="persistent">Store whatever data the drive returned on error</param>
|
||||
/// <param name="stopOnError">Stop dump on first error</param>
|
||||
/// <param name="resume">Information for dump resuming</param>
|
||||
/// <param name="dumpLog">Dump logger</param>
|
||||
/// <param name="dskType">Disc type as detected in MMC layer</param>
|
||||
/// <param name="dumpFirstTrackPregap">Try to read and dump as much first track pregap as possible</param>
|
||||
/// <param name="outputPath">Path to output file</param>
|
||||
/// <param name="formatOptions">Formats to pass to output file plugin</param>
|
||||
/// <param name="encoding">Encoding to use when analyzing dump</param>
|
||||
/// <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 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<string, string> 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.");
|
||||
|
||||
@@ -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<string, string> 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;
|
||||
|
||||
/// <summary>
|
||||
/// </summary>
|
||||
/// <param name="dev">Device</param>
|
||||
/// <param name="devicePath">Path to the device</param>
|
||||
/// <param name="outputPrefix">Prefix for output log files</param>
|
||||
/// <param name="outputPlugin">Plugin for output file</param>
|
||||
/// <param name="retryPasses">How many times to retry</param>
|
||||
/// <param name="force">Force to continue dump whenever possible</param>
|
||||
/// <param name="dumpRaw">Dump long sectors</param>
|
||||
/// <param name="persistent">Store whatever data the drive returned on error</param>
|
||||
/// <param name="stopOnError">Stop dump on first error</param>
|
||||
/// <param name="resume">Information for dump resuming</param>
|
||||
/// <param name="dumpLog">Dump logger</param>
|
||||
/// <param name="encoding">Encoding to use when analyzing dump</param>
|
||||
/// <param name="outputPath">Path to output file</param>
|
||||
/// <param name="formatOptions">Formats to pass to output file plugin</param>
|
||||
/// <param name="dumpFirstTrackPregap">Try to read and dump as much first track pregap as possible</param>
|
||||
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<string, string> 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;
|
||||
|
||||
@@ -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
|
||||
/// <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 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<string, string> 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,
|
||||
|
||||
@@ -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<string, string> formatOptions, CICMMetadataType preSidecar, uint skip,
|
||||
bool nometadata, bool notrim)
|
||||
public void NVMe()
|
||||
{
|
||||
throw new NotImplementedException("NVMe devices not yet supported.");
|
||||
}
|
||||
|
||||
@@ -29,33 +29,8 @@ namespace DiscImageChef.Core.Devices.Dumping
|
||||
/// <summary>
|
||||
/// Dumps a CFW PlayStation Portable UMD
|
||||
/// </summary>
|
||||
/// <param name="dev">Device</param>
|
||||
/// <param name="devicePath">Path to the device</param>
|
||||
/// <param name="outputPrefix">Prefix for output data files</param>
|
||||
/// <param name="outputPlugin">Plugin for output file</param>
|
||||
/// <param name="retryPasses">How many times to retry</param>
|
||||
/// <param name="force">Force to continue dump whenever possible</param>
|
||||
/// <param name="persistent">Store whatever data the drive returned on error</param>
|
||||
/// <param name="stopOnError">Stop dump on first error</param>
|
||||
/// <param name="resume">Information for dump resuming</param>
|
||||
/// <param name="dumpLog">Dump logger</param>
|
||||
/// <param name="encoding">Encoding to use when analyzing dump</param>
|
||||
/// <param name="outputPath">Path to output file</param>
|
||||
/// <param name="formatOptions">Formats to pass to output file plugin</param>
|
||||
/// <param name="preSidecar">Existing sidecar</param>
|
||||
/// <param name="skip">How many sectors to skip on errors</param>
|
||||
/// <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 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<string, string> 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<string, string> 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<Track>
|
||||
(outputPlugin as IWritableOpticalImage).SetTracks(new List<Track>
|
||||
{
|
||||
new Track
|
||||
{
|
||||
@@ -316,7 +264,8 @@ namespace DiscImageChef.Core.Devices.Dumping
|
||||
TrackEndSector = blocks - 1,
|
||||
TrackSequence = 1,
|
||||
TrackRawBytesPerSector = (int)BLOCK_SIZE,
|
||||
TrackSubchannelType = TrackSubchannelType.None,
|
||||
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<string, string> formatOptions,
|
||||
CICMMetadataType preSidecar, uint skip, bool nometadata,
|
||||
bool notrim)
|
||||
void DumpMs()
|
||||
{
|
||||
const ushort SBC_PROFILE = 0x0001;
|
||||
const uint BLOCK_SIZE = 512;
|
||||
|
||||
@@ -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
|
||||
/// <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 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,
|
||||
bool nometadata, bool notrim)
|
||||
internal void Sbc(Dictionary<MediaTagType, byte[]> mediaTags, ref MediaType dskType, bool opticalDisc)
|
||||
{
|
||||
bool sense;
|
||||
byte scsiMediumType = 0;
|
||||
|
||||
@@ -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
|
||||
/// <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 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)
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -57,9 +57,7 @@ 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 void Ssc(Device dev, string outputPrefix, string devicePath, ref Resume resume,
|
||||
ref DumpLog dumpLog,
|
||||
CICMMetadataType preSidecar)
|
||||
internal void Ssc()
|
||||
{
|
||||
FixedSense? fxSense;
|
||||
bool aborted;
|
||||
|
||||
@@ -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
|
||||
/// <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 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<string, string> formatOptions, CICMMetadataType preSidecar,
|
||||
uint skip,
|
||||
bool nometadata, bool notrim)
|
||||
public void SecureDigital()
|
||||
{
|
||||
bool aborted;
|
||||
|
||||
|
||||
@@ -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
|
||||
/// </exception>
|
||||
internal void Xgd(Device dev, string devicePath,
|
||||
IWritableOpticalImage outputPlugin, ushort retryPasses,
|
||||
bool force, bool dumpRaw,
|
||||
bool persistent, bool stopOnError,
|
||||
Dictionary<MediaTagType, byte[]> mediaTags, ref MediaType dskType,
|
||||
ref Resume resume,
|
||||
ref DumpLog dumpLog, Encoding encoding,
|
||||
string outputPrefix, string outputPath,
|
||||
Dictionary<string, string> formatOptions, CICMMetadataType preSidecar,
|
||||
uint skip,
|
||||
bool nometadata, bool notrim)
|
||||
internal void Xgd(Dictionary<MediaTagType, byte[]> 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<Track>
|
||||
(outputPlugin as IWritableOpticalImage).SetTracks(new List<Track>
|
||||
{
|
||||
new Track
|
||||
{
|
||||
@@ -390,7 +379,8 @@ namespace DiscImageChef.Core.Devices.Dumping
|
||||
TrackEndSector = blocks - 1,
|
||||
TrackSequence = 1,
|
||||
TrackRawBytesPerSector = (int)BLOCK_SIZE,
|
||||
TrackSubchannelType = TrackSubchannelType.None,
|
||||
TrackSubchannelType =
|
||||
TrackSubchannelType.None,
|
||||
TrackSession = 1,
|
||||
TrackType = TrackType.Data
|
||||
}
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user