From 341e8b563ac808ffb0b9a0918d78c1e943038537 Mon Sep 17 00:00:00 2001 From: Natalia Portillo Date: Tue, 19 Dec 2017 01:38:11 +0000 Subject: [PATCH] Corrected passing encoding to dump-media command. --- DiscImageChef.Core/Devices/Dumping/ATA.cs | 5 ++-- DiscImageChef.Core/Devices/Dumping/MMC.cs | 7 +++-- DiscImageChef.Core/Devices/Dumping/NVMe.cs | 3 +- DiscImageChef.Core/Devices/Dumping/SBC.cs | 5 ++-- DiscImageChef.Core/Devices/Dumping/SCSI.cs | 7 +++-- DiscImageChef.Core/Devices/Dumping/SSC.cs | 1 + .../Devices/Dumping/SecureDigital.cs | 5 ++-- DiscImageChef.Core/Devices/Dumping/XGD.cs | 5 ++-- DiscImageChef/Commands/DumpMedia.cs | 29 ++++++++++++++++--- DiscImageChef/Options.cs | 4 ++- 10 files changed, 51 insertions(+), 20 deletions(-) diff --git a/DiscImageChef.Core/Devices/Dumping/ATA.cs b/DiscImageChef.Core/Devices/Dumping/ATA.cs index 8b894bcfd..d87ad8137 100644 --- a/DiscImageChef.Core/Devices/Dumping/ATA.cs +++ b/DiscImageChef.Core/Devices/Dumping/ATA.cs @@ -38,6 +38,7 @@ using System; using System.Collections.Generic; using System.IO; +using System.Text; using DiscImageChef.CommonTypes; using DiscImageChef.Console; using DiscImageChef.Core.Logging; @@ -54,7 +55,7 @@ namespace DiscImageChef.Core.Devices.Dumping { public class ATA { - public static void Dump(Device dev, string devicePath, string outputPrefix, ushort retryPasses, bool force, bool dumpRaw, bool persistent, bool stopOnError, ref Metadata.Resume resume, ref DumpLog dumpLog) + public static void Dump(Device dev, string devicePath, string outputPrefix, ushort retryPasses, bool force, bool dumpRaw, bool persistent, bool stopOnError, ref Metadata.Resume resume, ref DumpLog dumpLog, Encoding encoding) { bool aborted; MHDDLog mhddLog; @@ -457,7 +458,7 @@ namespace DiscImageChef.Core.Devices.Dumping dumpLog.WriteLine("Average checksum speed {0:F3} KiB/sec.", (((double)blockSize * (double)(blocks + 1)) / 1024) / (totalChkDuration / 1000)); PluginBase plugins = new PluginBase(); - plugins.RegisterAllPlugins(); + plugins.RegisterAllPlugins(encoding); ImagePlugin _imageFormat; FiltersList filtersList = new FiltersList(); diff --git a/DiscImageChef.Core/Devices/Dumping/MMC.cs b/DiscImageChef.Core/Devices/Dumping/MMC.cs index 3b23f411a..5c564d4bf 100644 --- a/DiscImageChef.Core/Devices/Dumping/MMC.cs +++ b/DiscImageChef.Core/Devices/Dumping/MMC.cs @@ -36,6 +36,7 @@ // ****************************************************************************/ // //$Id$ using System; +using System.Text; using DiscImageChef.CommonTypes; using DiscImageChef.Console; using DiscImageChef.Devices; @@ -46,7 +47,7 @@ namespace DiscImageChef.Core.Devices.Dumping { internal static class MMC { - internal static void Dump(Device dev, string devicePath, string outputPrefix, ushort retryPasses, bool force, bool dumpRaw, bool persistent, bool stopOnError, ref CICMMetadataType sidecar, ref MediaType dskType, bool separateSubchannel, ref Metadata.Resume resume, ref DumpLog dumpLog, bool dumpLeadIn) + internal static void Dump(Device dev, string devicePath, string outputPrefix, ushort retryPasses, bool force, bool dumpRaw, bool persistent, bool stopOnError, ref CICMMetadataType sidecar, ref MediaType dskType, bool separateSubchannel, ref Metadata.Resume resume, ref DumpLog dumpLog, bool dumpLeadIn, Encoding encoding) { byte[] cmdBuf = null; byte[] senseBuf = null; @@ -645,11 +646,11 @@ namespace DiscImageChef.Core.Devices.Dumping if(isXbox) { - XGD.Dump(dev, devicePath, outputPrefix, retryPasses, force, dumpRaw, persistent, stopOnError, ref sidecar, ref dskType, ref resume, ref dumpLog); + XGD.Dump(dev, devicePath, outputPrefix, retryPasses, force, dumpRaw, persistent, stopOnError, ref sidecar, ref dskType, ref resume, ref dumpLog, encoding); return; } - SBC.Dump(dev, devicePath, outputPrefix, retryPasses, force, dumpRaw, persistent, stopOnError, ref sidecar, ref dskType, true, ref resume, ref dumpLog, alcohol); + SBC.Dump(dev, devicePath, outputPrefix, retryPasses, force, dumpRaw, persistent, stopOnError, ref sidecar, ref dskType, true, ref resume, ref dumpLog, encoding, alcohol); } } } diff --git a/DiscImageChef.Core/Devices/Dumping/NVMe.cs b/DiscImageChef.Core/Devices/Dumping/NVMe.cs index bc4219420..167d8cf2d 100644 --- a/DiscImageChef.Core/Devices/Dumping/NVMe.cs +++ b/DiscImageChef.Core/Devices/Dumping/NVMe.cs @@ -36,6 +36,7 @@ // ****************************************************************************/ // //$Id$ using System; +using System.Text; using DiscImageChef.Devices; using DiscImageChef.Core.Logging; @@ -43,7 +44,7 @@ namespace DiscImageChef.Core.Devices.Dumping { public static class NVMe { - public static void Dump(Device dev, string devicePath, string outputPrefix, ushort retryPasses, bool force, bool dumpRaw, bool persistent, bool stopOnError, ref Metadata.Resume resume, ref DumpLog dumpLog) + public static void Dump(Device dev, string devicePath, string outputPrefix, ushort retryPasses, bool force, bool dumpRaw, bool persistent, bool stopOnError, ref Metadata.Resume resume, ref DumpLog dumpLog, Encoding encoding) { throw new NotImplementedException("NVMe devices not yet supported."); } diff --git a/DiscImageChef.Core/Devices/Dumping/SBC.cs b/DiscImageChef.Core/Devices/Dumping/SBC.cs index e9f2531d3..f4765d9ee 100644 --- a/DiscImageChef.Core/Devices/Dumping/SBC.cs +++ b/DiscImageChef.Core/Devices/Dumping/SBC.cs @@ -38,6 +38,7 @@ using System; using System.Collections.Generic; using System.IO; +using System.Text; using DiscImageChef.CommonTypes; using DiscImageChef.Console; using DiscImageChef.Core.Logging; @@ -55,7 +56,7 @@ namespace DiscImageChef.Core.Devices.Dumping internal static class SBC { - internal static void Dump(Device dev, string devicePath, string outputPrefix, ushort retryPasses, bool force, bool dumpRaw, bool persistent, bool stopOnError, ref CICMMetadataType sidecar, ref MediaType dskType, bool opticalDisc, ref Metadata.Resume resume, ref DumpLog dumpLog, Alcohol120 alcohol = null) + internal static void Dump(Device dev, string devicePath, string outputPrefix, ushort retryPasses, bool force, bool dumpRaw, bool persistent, bool stopOnError, ref CICMMetadataType sidecar, ref MediaType dskType, bool opticalDisc, ref Metadata.Resume resume, ref DumpLog dumpLog, Encoding encoding, Alcohol120 alcohol = null) { MHDDLog mhddLog; IBGLog ibgLog; @@ -626,7 +627,7 @@ namespace DiscImageChef.Core.Devices.Dumping dumpLog.WriteLine("Average checksum speed {0:F3} KiB/sec.", (((double)blockSize * (double)(blocks + 1)) / 1024) / (totalChkDuration / 1000)); PluginBase plugins = new PluginBase(); - plugins.RegisterAllPlugins(); + plugins.RegisterAllPlugins(encoding); ImagePlugin _imageFormat; FiltersList filtersList = new FiltersList(); Filter inputFilter = filtersList.GetFilter(outputPrefix + outputExtension); diff --git a/DiscImageChef.Core/Devices/Dumping/SCSI.cs b/DiscImageChef.Core/Devices/Dumping/SCSI.cs index 1fc901779..1a500a094 100644 --- a/DiscImageChef.Core/Devices/Dumping/SCSI.cs +++ b/DiscImageChef.Core/Devices/Dumping/SCSI.cs @@ -37,6 +37,7 @@ // //$Id$ using System; using System.IO; +using System.Text; using DiscImageChef.CommonTypes; using DiscImageChef.Console; using DiscImageChef.Devices; @@ -48,7 +49,7 @@ namespace DiscImageChef.Core.Devices.Dumping public class SCSI { // TODO: Get cartridge serial number from Certance vendor EVPD - public static void Dump(Device dev, string devicePath, string outputPrefix, ushort retryPasses, bool force, bool dumpRaw, bool persistent, bool stopOnError, bool separateSubchannel, ref Metadata.Resume resume, ref DumpLog dumpLog, bool dumpLeadIn) + public static void Dump(Device dev, string devicePath, string outputPrefix, ushort retryPasses, bool force, bool dumpRaw, bool persistent, bool stopOnError, bool separateSubchannel, ref Metadata.Resume resume, ref DumpLog dumpLog, bool dumpLeadIn, Encoding encoding) { byte[] senseBuf = null; bool sense = false; @@ -183,11 +184,11 @@ namespace DiscImageChef.Core.Devices.Dumping if(dev.SCSIType == Decoders.SCSI.PeripheralDeviceTypes.MultiMediaDevice) { - MMC.Dump(dev, devicePath, outputPrefix, retryPasses, force, dumpRaw, persistent, stopOnError, ref sidecar, ref dskType, separateSubchannel, ref resume, ref dumpLog, dumpLeadIn); + MMC.Dump(dev, devicePath, outputPrefix, retryPasses, force, dumpRaw, persistent, stopOnError, ref sidecar, ref dskType, separateSubchannel, ref resume, ref dumpLog, dumpLeadIn, encoding); return; } - SBC.Dump(dev, devicePath, outputPrefix, retryPasses, force, dumpRaw, persistent, stopOnError, ref sidecar, ref dskType, false, ref resume, ref dumpLog); + SBC.Dump(dev, devicePath, outputPrefix, retryPasses, force, dumpRaw, persistent, stopOnError, ref sidecar, ref dskType, false, ref resume, ref dumpLog, encoding); } } } diff --git a/DiscImageChef.Core/Devices/Dumping/SSC.cs b/DiscImageChef.Core/Devices/Dumping/SSC.cs index 9edf2d569..23cc4bb76 100644 --- a/DiscImageChef.Core/Devices/Dumping/SSC.cs +++ b/DiscImageChef.Core/Devices/Dumping/SSC.cs @@ -38,6 +38,7 @@ using System; using System.Collections.Generic; using System.IO; +using System.Text; using DiscImageChef.CommonTypes; using DiscImageChef.Console; using DiscImageChef.Core.Logging; diff --git a/DiscImageChef.Core/Devices/Dumping/SecureDigital.cs b/DiscImageChef.Core/Devices/Dumping/SecureDigital.cs index 93d48f43f..192fbafeb 100644 --- a/DiscImageChef.Core/Devices/Dumping/SecureDigital.cs +++ b/DiscImageChef.Core/Devices/Dumping/SecureDigital.cs @@ -38,6 +38,7 @@ using System; using System.Collections.Generic; using System.IO; +using System.Text; using DiscImageChef.CommonTypes; using DiscImageChef.Console; using DiscImageChef.Core.Logging; @@ -53,7 +54,7 @@ namespace DiscImageChef.Core.Devices.Dumping { public class SecureDigital { - public static void Dump(Device dev, string devicePath, string outputPrefix, ushort retryPasses, bool force, bool dumpRaw, bool persistent, bool stopOnError, ref Metadata.Resume resume, ref DumpLog dumpLog) + public static void Dump(Device dev, string devicePath, string outputPrefix, ushort retryPasses, bool force, bool dumpRaw, bool persistent, bool stopOnError, ref Metadata.Resume resume, ref DumpLog dumpLog, Encoding encoding) { bool aborted; MHDDLog mhddLog; @@ -452,7 +453,7 @@ namespace DiscImageChef.Core.Devices.Dumping dumpLog.WriteLine("Average checksum speed {0:F3} KiB/sec.", (((double)blockSize * (double)(blocks + 1)) / 1024) / (totalChkDuration / 1000)); PluginBase plugins = new PluginBase(); - plugins.RegisterAllPlugins(); + plugins.RegisterAllPlugins(encoding); ImagePlugin _imageFormat; FiltersList filtersList = new FiltersList(); diff --git a/DiscImageChef.Core/Devices/Dumping/XGD.cs b/DiscImageChef.Core/Devices/Dumping/XGD.cs index c627fc7f3..ef8a8436d 100644 --- a/DiscImageChef.Core/Devices/Dumping/XGD.cs +++ b/DiscImageChef.Core/Devices/Dumping/XGD.cs @@ -38,6 +38,7 @@ using System; using System.Collections.Generic; using System.IO; +using System.Text; using DiscImageChef.CommonTypes; using DiscImageChef.Console; using DiscImageChef.Core.Logging; @@ -53,7 +54,7 @@ namespace DiscImageChef.Core.Devices.Dumping { internal static class XGD { - internal static void Dump(Device dev, string devicePath, string outputPrefix, ushort retryPasses, bool force, bool dumpRaw, bool persistent, bool stopOnError, ref CICMMetadataType sidecar, ref MediaType dskType, ref Metadata.Resume resume, ref DumpLog dumpLog) + internal static void Dump(Device dev, string devicePath, string outputPrefix, ushort retryPasses, bool force, bool dumpRaw, bool persistent, bool stopOnError, ref CICMMetadataType sidecar, ref MediaType dskType, ref Metadata.Resume resume, ref DumpLog dumpLog, Encoding encoding) { MHDDLog mhddLog; IBGLog ibgLog; @@ -803,7 +804,7 @@ namespace DiscImageChef.Core.Devices.Dumping dumpLog.WriteLine("Average checksum speed {0:F3} KiB/sec.", (((double)blockSize * (double)(blocks + 1)) / 1024) / (totalChkDuration / 1000)); PluginBase plugins = new PluginBase(); - plugins.RegisterAllPlugins(); + plugins.RegisterAllPlugins(encoding); ImagePlugin _imageFormat; FiltersList filtersList = new FiltersList(); Filter inputFilter = filtersList.GetFilter(outputPrefix + ".iso"); diff --git a/DiscImageChef/Commands/DumpMedia.cs b/DiscImageChef/Commands/DumpMedia.cs index 04c35fedb..9c5a0a855 100644 --- a/DiscImageChef/Commands/DumpMedia.cs +++ b/DiscImageChef/Commands/DumpMedia.cs @@ -33,6 +33,7 @@ using System; using System.Collections.Generic; using System.IO; +using System.Text; using DiscImageChef.CommonTypes; using DiscImageChef.Console; using DiscImageChef.Core; @@ -65,6 +66,26 @@ namespace DiscImageChef.Commands DicConsole.DebugWriteLine("Dump-Media command", "--persistent={0}", options.Persistent); DicConsole.DebugWriteLine("Dump-Media command", "--separate-subchannel={0}", options.SeparateSubchannel); DicConsole.DebugWriteLine("Dump-Media command", "--resume={0}", options.Resume); + DicConsole.DebugWriteLine("Dump-Media command", "--lead-in={0}", options.LeadIn); + DicConsole.DebugWriteLine("Dump-Media command", "--encoding={0}", options.EncodingName); + + Encoding encoding = null; + + if(options.EncodingName != null) + { + try + { + encoding = Claunia.Encoding.Encoding.GetEncoding(options.EncodingName); + if(options.Verbose) + DicConsole.VerboseWriteLine("Using encoding for {0}.", encoding.EncodingName); + } + catch(ArgumentException) + { + DicConsole.ErrorWriteLine("Specified encoding is not supported."); + encoding = null; + return; + } + } if(options.DevicePath.Length == 2 && options.DevicePath[1] == ':' && options.DevicePath[0] != '/' && char.IsLetter(options.DevicePath[0])) @@ -110,18 +131,18 @@ namespace DiscImageChef.Commands switch(dev.Type) { case DeviceType.ATA: - ATA.Dump(dev, options.DevicePath, options.OutputPrefix, options.RetryPasses, options.Force, options.Raw, options.Persistent, options.StopOnError, ref resume, ref dumpLog); + ATA.Dump(dev, options.DevicePath, options.OutputPrefix, options.RetryPasses, options.Force, options.Raw, options.Persistent, options.StopOnError, ref resume, ref dumpLog, encoding); break; case DeviceType.MMC: case DeviceType.SecureDigital: - SecureDigital.Dump(dev, options.DevicePath, options.OutputPrefix, options.RetryPasses, options.Force, options.Raw, options.Persistent, options.StopOnError, ref resume, ref dumpLog); + SecureDigital.Dump(dev, options.DevicePath, options.OutputPrefix, options.RetryPasses, options.Force, options.Raw, options.Persistent, options.StopOnError, ref resume, ref dumpLog, encoding); break; case DeviceType.NVMe: - NVMe.Dump(dev, options.DevicePath, options.OutputPrefix, options.RetryPasses, options.Force, options.Raw, options.Persistent, options.StopOnError, ref resume, ref dumpLog); + NVMe.Dump(dev, options.DevicePath, options.OutputPrefix, options.RetryPasses, options.Force, options.Raw, options.Persistent, options.StopOnError, ref resume, ref dumpLog, encoding); break; case DeviceType.ATAPI: case DeviceType.SCSI: - SCSI.Dump(dev, options.DevicePath, options.OutputPrefix, options.RetryPasses, options.Force, options.Raw, options.Persistent, options.StopOnError, options.SeparateSubchannel, ref resume, ref dumpLog, options.LeadIn); + SCSI.Dump(dev, options.DevicePath, options.OutputPrefix, options.RetryPasses, options.Force, options.Raw, options.Persistent, options.StopOnError, options.SeparateSubchannel, ref resume, ref dumpLog, options.LeadIn, encoding); break; default: dumpLog.WriteLine("Unknown device type."); diff --git a/DiscImageChef/Options.cs b/DiscImageChef/Options.cs index 922e56135..de809c3c2 100644 --- a/DiscImageChef/Options.cs +++ b/DiscImageChef/Options.cs @@ -280,7 +280,6 @@ namespace DiscImageChef public string EncodingName { get; set; } } - // TODO: Add encoding, check options [Verb("dump-media", HelpText = "Dumps the media inserted on a device to a media image.")] public class DumpMediaOptions : CommonOptions { @@ -320,6 +319,9 @@ namespace DiscImageChef [Option("lead-in", Default = false, HelpText = "Try to read lead-in. Only applicable to CD/DDCD/GD.")] public bool LeadIn { get; set; } + + [Option('e', "encoding", Default = null, HelpText = "Name of character encoding to use.")] + public string EncodingName { get; set; } } [Verb("device-report", HelpText = "Tests the device capabilities and creates an XML report of them.")]