mirror of
https://github.com/aaru-dps/Aaru.git
synced 2025-12-16 19:24:25 +00:00
Set remote statistics.
This commit is contained in:
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -36,6 +36,7 @@ using System.IO;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Xml.Serialization;
|
||||
using DiscImageChef.CommonTypes;
|
||||
using DiscImageChef.CommonTypes.Enums;
|
||||
using DiscImageChef.CommonTypes.Interfaces;
|
||||
using DiscImageChef.CommonTypes.Interop;
|
||||
@@ -53,92 +54,107 @@ namespace DiscImageChef.Commands
|
||||
{
|
||||
internal class DumpMediaCommand : Command
|
||||
{
|
||||
private string cicmXml;
|
||||
private string devicePath;
|
||||
private bool doResume = true;
|
||||
private string encodingName;
|
||||
private bool firstTrackPregap;
|
||||
private bool force;
|
||||
private bool noMetadata;
|
||||
private bool noTrim;
|
||||
private string outputFile;
|
||||
private string outputOptions;
|
||||
string cicmXml;
|
||||
string devicePath;
|
||||
bool doResume = true;
|
||||
string encodingName;
|
||||
bool firstTrackPregap;
|
||||
bool force;
|
||||
bool noMetadata;
|
||||
bool noTrim;
|
||||
string outputFile;
|
||||
string outputOptions;
|
||||
|
||||
private bool persistent;
|
||||
bool persistent;
|
||||
|
||||
// TODO: Add raw dumping
|
||||
private ushort retryPasses = 5;
|
||||
private bool showHelp;
|
||||
private int skip = 512;
|
||||
private bool stopOnError;
|
||||
private string wantedOutputFormat;
|
||||
ushort retryPasses = 5;
|
||||
bool showHelp;
|
||||
int skip = 512;
|
||||
bool stopOnError;
|
||||
string wantedOutputFormat;
|
||||
|
||||
public DumpMediaCommand() : base("dump-media", "Dumps the media inserted on a device to a media image.")
|
||||
{
|
||||
Options = new OptionSet
|
||||
{
|
||||
$"{MainClass.AssemblyTitle} {MainClass.AssemblyVersion?.InformationalVersion}",
|
||||
$"{MainClass.AssemblyCopyright}",
|
||||
"",
|
||||
$"usage: DiscImageChef {Name} [OPTIONS] devicepath outputimage",
|
||||
"",
|
||||
Help,
|
||||
{"cicm-xml|x=", "Take metadata from existing CICM XML sidecar.", s => cicmXml = s},
|
||||
{"encoding|e=", "Name of character encoding to use.", s => encodingName = s}
|
||||
$"{MainClass.AssemblyCopyright}", "", $"usage: DiscImageChef {Name} [OPTIONS] devicepath outputimage",
|
||||
"", Help,
|
||||
{
|
||||
"cicm-xml|x=", "Take metadata from existing CICM XML sidecar.", s => cicmXml = s
|
||||
},
|
||||
{
|
||||
"encoding|e=", "Name of character encoding to use.", s => encodingName = s
|
||||
}
|
||||
};
|
||||
|
||||
if (DetectOS.GetRealPlatformID() != PlatformID.FreeBSD)
|
||||
if(DetectOS.GetRealPlatformID() != PlatformID.FreeBSD)
|
||||
Options.Add("first-pregap", "Try to read first track pregap. Only applicable to CD/DDCD/GD.",
|
||||
b => firstTrackPregap = b != null);
|
||||
b => firstTrackPregap = b != null);
|
||||
|
||||
Options.Add("force|f", "Continue dump whatever happens.", b => force = b != null);
|
||||
|
||||
Options.Add("format|t=",
|
||||
"Format of the output image, as plugin name or plugin id. If not present, will try to detect it from output image extension.",
|
||||
s => wantedOutputFormat = s);
|
||||
Options.Add("no-metadata", "Disables creating CICM XML sidecar.", b => noMetadata = b != null);
|
||||
"Format of the output image, as plugin name or plugin id. If not present, will try to detect it from output image extension.",
|
||||
s => wantedOutputFormat = s);
|
||||
|
||||
Options.Add("no-metadata", "Disables creating CICM XML sidecar.", b => noMetadata = b != null);
|
||||
Options.Add("no-trim", "Disables trimming errored from skipped sectors.", b => noTrim = b != null);
|
||||
|
||||
Options.Add("options|O=", "Comma separated name=value pairs of options to pass to output image plugin.",
|
||||
s => outputOptions = s);
|
||||
s => outputOptions = s);
|
||||
|
||||
Options.Add("persistent", "Try to recover partial or incorrect data.", b => persistent = b != null);
|
||||
|
||||
/* TODO: Disabled temporarily
|
||||
Options.Add("raw|r", "Dump sectors with tags included. For optical media, dump scrambled sectors.", (b) => raw = b != null);*/
|
||||
Options.Add("resume|r", "Create/use resume mapfile.",
|
||||
b => doResume = b != null);
|
||||
Options.Add("retry-passes|p=", "How many retry passes to do.",
|
||||
(ushort us) => retryPasses = us);
|
||||
Options.Add("skip|k=", "When an unreadable sector is found skip this many sectors.",
|
||||
(int i) => skip = i);
|
||||
b => doResume = b != null);
|
||||
|
||||
Options.Add("retry-passes|p=", "How many retry passes to do.", (ushort us) => retryPasses = us);
|
||||
Options.Add("skip|k=", "When an unreadable sector is found skip this many sectors.", (int i) => skip = i);
|
||||
|
||||
Options.Add("stop-on-error|s", "Stop media dump on first error.",
|
||||
b => stopOnError = b != null);
|
||||
b => stopOnError = b != null);
|
||||
|
||||
Options.Add("help|h|?", "Show this message and exit.",
|
||||
v => showHelp = v != null);
|
||||
v => showHelp = v != null);
|
||||
}
|
||||
|
||||
public override int Invoke(IEnumerable<string> arguments)
|
||||
{
|
||||
var extra = Options.Parse(arguments);
|
||||
List<string> extra = Options.Parse(arguments);
|
||||
|
||||
if (showHelp)
|
||||
if(showHelp)
|
||||
{
|
||||
Options.WriteOptionDescriptions(CommandSet.Out);
|
||||
return (int) ErrorNumber.HelpRequested;
|
||||
|
||||
return(int)ErrorNumber.HelpRequested;
|
||||
}
|
||||
|
||||
MainClass.PrintCopyright();
|
||||
if (MainClass.Debug) DicConsole.DebugWriteLineEvent += System.Console.Error.WriteLine;
|
||||
if (MainClass.Verbose) DicConsole.VerboseWriteLineEvent += System.Console.WriteLine;
|
||||
|
||||
if(MainClass.Debug)
|
||||
DicConsole.DebugWriteLineEvent += System.Console.Error.WriteLine;
|
||||
|
||||
if(MainClass.Verbose)
|
||||
DicConsole.VerboseWriteLineEvent += System.Console.WriteLine;
|
||||
|
||||
Statistics.AddCommand("dump-media");
|
||||
|
||||
if (extra.Count > 2)
|
||||
if(extra.Count > 2)
|
||||
{
|
||||
DicConsole.ErrorWriteLine("Too many arguments.");
|
||||
return (int) ErrorNumber.UnexpectedArgumentCount;
|
||||
|
||||
return(int)ErrorNumber.UnexpectedArgumentCount;
|
||||
}
|
||||
|
||||
if (extra.Count <= 1)
|
||||
if(extra.Count <= 1)
|
||||
{
|
||||
DicConsole.ErrorWriteLine("Missing paths.");
|
||||
return (int) ErrorNumber.MissingArgument;
|
||||
|
||||
return(int)ErrorNumber.MissingArgument;
|
||||
}
|
||||
|
||||
devicePath = extra[0];
|
||||
@@ -156,6 +172,7 @@ namespace DiscImageChef.Commands
|
||||
DicConsole.DebugWriteLine("Dump-Media command", "--options={0}", Options);
|
||||
DicConsole.DebugWriteLine("Dump-Media command", "--output={0}", outputFile);
|
||||
DicConsole.DebugWriteLine("Dump-Media command", "--persistent={0}", persistent);
|
||||
|
||||
// TODO: Disabled temporarily
|
||||
//DicConsole.DebugWriteLine("Dump-Media command", "--raw={0}", raw);
|
||||
DicConsole.DebugWriteLine("Dump-Media command", "--resume={0}", doResume);
|
||||
@@ -164,129 +181,155 @@ namespace DiscImageChef.Commands
|
||||
DicConsole.DebugWriteLine("Dump-Media command", "--stop-on-error={0}", stopOnError);
|
||||
DicConsole.DebugWriteLine("Dump-Media command", "--verbose={0}", MainClass.Verbose);
|
||||
|
||||
var parsedOptions = Core.Options.Parse(outputOptions);
|
||||
Dictionary<string, string> parsedOptions = Core.Options.Parse(outputOptions);
|
||||
DicConsole.DebugWriteLine("Dump-Media command", "Parsed options:");
|
||||
foreach (var parsedOption in parsedOptions)
|
||||
|
||||
foreach(KeyValuePair<string, string> parsedOption in parsedOptions)
|
||||
DicConsole.DebugWriteLine("Dump-Media command", "{0} = {1}", parsedOption.Key, parsedOption.Value);
|
||||
|
||||
Encoding encoding = null;
|
||||
|
||||
if (encodingName != null)
|
||||
if(encodingName != null)
|
||||
try
|
||||
{
|
||||
encoding = Claunia.Encoding.Encoding.GetEncoding(encodingName);
|
||||
if (MainClass.Verbose)
|
||||
|
||||
if(MainClass.Verbose)
|
||||
DicConsole.VerboseWriteLine("Using encoding for {0}.", encoding.EncodingName);
|
||||
}
|
||||
catch (ArgumentException)
|
||||
catch(ArgumentException)
|
||||
{
|
||||
DicConsole.ErrorWriteLine("Specified encoding is not supported.");
|
||||
return (int) ErrorNumber.EncodingUnknown;
|
||||
|
||||
return(int)ErrorNumber.EncodingUnknown;
|
||||
}
|
||||
|
||||
if (devicePath.Length == 2 && devicePath[1] == ':' && devicePath[0] != '/' && char.IsLetter(devicePath[0]))
|
||||
if(devicePath.Length == 2 &&
|
||||
devicePath[1] == ':' &&
|
||||
devicePath[0] != '/' &&
|
||||
char.IsLetter(devicePath[0]))
|
||||
devicePath = "\\\\.\\" + char.ToUpper(devicePath[0]) + ':';
|
||||
|
||||
Device dev;
|
||||
|
||||
try
|
||||
{
|
||||
dev = new Device(devicePath);
|
||||
|
||||
if (dev.Error)
|
||||
if(dev.IsRemote)
|
||||
Statistics.AddRemote(dev.RemoteApplication, dev.RemoteVersion, dev.RemoteOperatingSystem,
|
||||
dev.RemoteOperatingSystemVersion, dev.RemoteArchitecture);
|
||||
|
||||
if(dev.Error)
|
||||
{
|
||||
DicConsole.ErrorWriteLine(Error.Print(dev.LastError));
|
||||
return (int) ErrorNumber.CannotOpenDevice;
|
||||
|
||||
return(int)ErrorNumber.CannotOpenDevice;
|
||||
}
|
||||
}
|
||||
catch (DeviceException e)
|
||||
catch(DeviceException e)
|
||||
{
|
||||
DicConsole.ErrorWriteLine(e.Message ?? Error.Print(e.LastError));
|
||||
return (int) ErrorNumber.CannotOpenDevice;
|
||||
|
||||
return(int)ErrorNumber.CannotOpenDevice;
|
||||
}
|
||||
|
||||
Statistics.AddDevice(dev);
|
||||
|
||||
var outputPrefix = Path.Combine(Path.GetDirectoryName(outputFile),
|
||||
Path.GetFileNameWithoutExtension(outputFile));
|
||||
string outputPrefix = Path.Combine(Path.GetDirectoryName(outputFile),
|
||||
Path.GetFileNameWithoutExtension(outputFile));
|
||||
|
||||
Resume resume = null;
|
||||
var xs = new XmlSerializer(typeof(Resume));
|
||||
if (File.Exists(outputPrefix + ".resume.xml") && doResume)
|
||||
var xs = new XmlSerializer(typeof(Resume));
|
||||
|
||||
if(File.Exists(outputPrefix + ".resume.xml") && doResume)
|
||||
try
|
||||
{
|
||||
var sr = new StreamReader(outputPrefix + ".resume.xml");
|
||||
resume = (Resume) xs.Deserialize(sr);
|
||||
resume = (Resume)xs.Deserialize(sr);
|
||||
sr.Close();
|
||||
}
|
||||
catch
|
||||
{
|
||||
DicConsole.ErrorWriteLine("Incorrect resume file, not continuing...");
|
||||
return (int) ErrorNumber.InvalidResume;
|
||||
|
||||
return(int)ErrorNumber.InvalidResume;
|
||||
}
|
||||
|
||||
if (resume != null && resume.NextBlock > resume.LastBlock && resume.BadBlocks.Count == 0 && !resume.Tape)
|
||||
if(resume != null &&
|
||||
resume.NextBlock > resume.LastBlock &&
|
||||
resume.BadBlocks.Count == 0 &&
|
||||
!resume.Tape)
|
||||
{
|
||||
DicConsole.WriteLine("Media already dumped correctly, not continuing...");
|
||||
return (int) ErrorNumber.AlreadyDumped;
|
||||
|
||||
return(int)ErrorNumber.AlreadyDumped;
|
||||
}
|
||||
|
||||
CICMMetadataType sidecar = null;
|
||||
var sidecarXs = new XmlSerializer(typeof(CICMMetadataType));
|
||||
if (cicmXml != null)
|
||||
if (File.Exists(cicmXml))
|
||||
CICMMetadataType sidecar = null;
|
||||
var sidecarXs = new XmlSerializer(typeof(CICMMetadataType));
|
||||
|
||||
if(cicmXml != null)
|
||||
if(File.Exists(cicmXml))
|
||||
{
|
||||
try
|
||||
{
|
||||
var sr = new StreamReader(cicmXml);
|
||||
sidecar = (CICMMetadataType) sidecarXs.Deserialize(sr);
|
||||
sidecar = (CICMMetadataType)sidecarXs.Deserialize(sr);
|
||||
sr.Close();
|
||||
}
|
||||
catch
|
||||
{
|
||||
DicConsole.ErrorWriteLine("Incorrect metadata sidecar file, not continuing...");
|
||||
return (int) ErrorNumber.InvalidSidecar;
|
||||
|
||||
return(int)ErrorNumber.InvalidSidecar;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
DicConsole.ErrorWriteLine("Could not find metadata sidecar, not continuing...");
|
||||
return (int) ErrorNumber.FileNotFound;
|
||||
|
||||
return(int)ErrorNumber.FileNotFound;
|
||||
}
|
||||
|
||||
var plugins = GetPluginBase.Instance;
|
||||
var candidates = new List<IWritableImage>();
|
||||
PluginBase plugins = GetPluginBase.Instance;
|
||||
List<IWritableImage> candidates = new List<IWritableImage>();
|
||||
|
||||
// Try extension
|
||||
if (string.IsNullOrEmpty(wantedOutputFormat))
|
||||
if(string.IsNullOrEmpty(wantedOutputFormat))
|
||||
candidates.AddRange(plugins.WritableImages.Values.Where(t =>
|
||||
t.KnownExtensions
|
||||
.Contains(Path.GetExtension(outputFile))));
|
||||
t.KnownExtensions.
|
||||
Contains(Path.GetExtension(outputFile))));
|
||||
|
||||
// Try Id
|
||||
else if (Guid.TryParse(wantedOutputFormat, out var outId))
|
||||
else if(Guid.TryParse(wantedOutputFormat, out Guid outId))
|
||||
candidates.AddRange(plugins.WritableImages.Values.Where(t => t.Id.Equals(outId)));
|
||||
|
||||
// Try name
|
||||
else
|
||||
candidates.AddRange(plugins.WritableImages.Values.Where(t => string.Equals(t.Name, wantedOutputFormat,
|
||||
StringComparison
|
||||
.InvariantCultureIgnoreCase)));
|
||||
StringComparison.
|
||||
InvariantCultureIgnoreCase)));
|
||||
|
||||
if (candidates.Count == 0)
|
||||
if(candidates.Count == 0)
|
||||
{
|
||||
DicConsole.WriteLine("No plugin supports requested extension.");
|
||||
return (int) ErrorNumber.FormatNotFound;
|
||||
|
||||
return(int)ErrorNumber.FormatNotFound;
|
||||
}
|
||||
|
||||
if (candidates.Count > 1)
|
||||
if(candidates.Count > 1)
|
||||
{
|
||||
DicConsole.WriteLine("More than one plugin supports requested extension.");
|
||||
return (int) ErrorNumber.TooManyFormats;
|
||||
|
||||
return(int)ErrorNumber.TooManyFormats;
|
||||
}
|
||||
|
||||
var outputFormat = candidates[0];
|
||||
IWritableImage outputFormat = candidates[0];
|
||||
|
||||
var dumpLog = new DumpLog(outputPrefix + ".log", dev);
|
||||
|
||||
if (MainClass.Verbose)
|
||||
if(MainClass.Verbose)
|
||||
{
|
||||
dumpLog.WriteLine("Output image format: {0} ({1}).", outputFormat.Name, outputFormat.Id);
|
||||
DicConsole.VerboseWriteLine("Output image format: {0} ({1}).", outputFormat.Name, outputFormat.Id);
|
||||
@@ -298,18 +341,20 @@ namespace DiscImageChef.Commands
|
||||
}
|
||||
|
||||
var 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;
|
||||
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;
|
||||
dumper.UpdateProgress += Progress.UpdateProgress;
|
||||
dumper.PulseProgress += Progress.PulseProgress;
|
||||
dumper.InitProgress += Progress.InitProgress;
|
||||
dumper.EndProgress += Progress.EndProgress;
|
||||
dumper.InitProgress2 += Progress.InitProgress2;
|
||||
dumper.EndProgress2 += Progress.EndProgress2;
|
||||
dumper.UpdateProgress2 += Progress.UpdateProgress2;
|
||||
dumper.UpdateProgress += Progress.UpdateProgress;
|
||||
dumper.PulseProgress += Progress.PulseProgress;
|
||||
dumper.InitProgress += Progress.InitProgress;
|
||||
dumper.EndProgress += Progress.EndProgress;
|
||||
dumper.InitProgress2 += Progress.InitProgress2;
|
||||
dumper.EndProgress2 += Progress.EndProgress2;
|
||||
dumper.UpdateProgress2 += Progress.UpdateProgress2;
|
||||
|
||||
System.Console.CancelKeyPress += (sender, e) =>
|
||||
{
|
||||
e.Cancel = true;
|
||||
@@ -319,7 +364,8 @@ namespace DiscImageChef.Commands
|
||||
dumper.Start();
|
||||
|
||||
dev.Close();
|
||||
return (int) ErrorNumber.NoError;
|
||||
|
||||
return(int)ErrorNumber.NoError;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -42,53 +42,67 @@ namespace DiscImageChef.Commands
|
||||
{
|
||||
internal class ListDevicesCommand : Command
|
||||
{
|
||||
private bool showHelp;
|
||||
bool showHelp;
|
||||
|
||||
public ListDevicesCommand() : base("list-devices", "Lists all connected devices.")
|
||||
public ListDevicesCommand() : base("list-devices", "Lists all connected devices.") => Options = new OptionSet
|
||||
{
|
||||
Options = new OptionSet
|
||||
$"{MainClass.AssemblyTitle} {MainClass.AssemblyVersion?.InformationalVersion}",
|
||||
$"{MainClass.AssemblyCopyright}", "", $"usage: DiscImageChef {Name} [dic-remote-host]", "",
|
||||
Help,
|
||||
{
|
||||
$"{MainClass.AssemblyTitle} {MainClass.AssemblyVersion?.InformationalVersion}",
|
||||
$"{MainClass.AssemblyCopyright}",
|
||||
"",
|
||||
$"usage: DiscImageChef {Name} [dic-remote-host]",
|
||||
"",
|
||||
Help,
|
||||
{"help|h|?", "Show this message and exit.", v => showHelp = v != null}
|
||||
};
|
||||
}
|
||||
"help|h|?", "Show this message and exit.", v => showHelp = v != null
|
||||
}
|
||||
};
|
||||
|
||||
public override int Invoke(IEnumerable<string> arguments)
|
||||
{
|
||||
var extra = Options.Parse(arguments);
|
||||
List<string> extra = Options.Parse(arguments);
|
||||
|
||||
if (showHelp)
|
||||
if(showHelp)
|
||||
{
|
||||
Options.WriteOptionDescriptions(CommandSet.Out);
|
||||
return (int) ErrorNumber.HelpRequested;
|
||||
|
||||
return(int)ErrorNumber.HelpRequested;
|
||||
}
|
||||
|
||||
MainClass.PrintCopyright();
|
||||
if (MainClass.Debug) DicConsole.DebugWriteLineEvent += System.Console.Error.WriteLine;
|
||||
if (MainClass.Verbose) DicConsole.VerboseWriteLineEvent += System.Console.WriteLine;
|
||||
|
||||
if(MainClass.Debug)
|
||||
DicConsole.DebugWriteLineEvent += System.Console.Error.WriteLine;
|
||||
|
||||
if(MainClass.Verbose)
|
||||
DicConsole.VerboseWriteLineEvent += System.Console.WriteLine;
|
||||
|
||||
Statistics.AddCommand("list-devices");
|
||||
|
||||
string dicRemote = null;
|
||||
|
||||
if (extra.Count > 1)
|
||||
if(extra.Count > 1)
|
||||
{
|
||||
DicConsole.ErrorWriteLine("Too many arguments.");
|
||||
return (int) ErrorNumber.UnexpectedArgumentCount;
|
||||
|
||||
return(int)ErrorNumber.UnexpectedArgumentCount;
|
||||
}
|
||||
|
||||
if (extra.Count == 1) dicRemote = extra[0];
|
||||
if(extra.Count == 1)
|
||||
dicRemote = extra[0];
|
||||
|
||||
DicConsole.DebugWriteLine("List-Devices command", "--debug={0}", MainClass.Debug);
|
||||
DicConsole.DebugWriteLine("List-Devices command", "--verbose={0}", MainClass.Verbose);
|
||||
|
||||
var devices = Device.ListDevices(dicRemote);
|
||||
DeviceInfo[] devices = Device.ListDevices(out bool isRemote, out string serverApplication,
|
||||
out string serverVersion, out string serverOperatingSystem,
|
||||
out string serverOperatingSystemVersion,
|
||||
out string serverArchitecture, dicRemote);
|
||||
|
||||
if (devices == null || devices.Length == 0)
|
||||
if(isRemote)
|
||||
{
|
||||
Statistics.AddRemote(serverApplication, serverVersion, serverOperatingSystem,
|
||||
serverOperatingSystemVersion, serverArchitecture);
|
||||
}
|
||||
|
||||
if(devices == null ||
|
||||
devices.Length == 0)
|
||||
{
|
||||
DicConsole.WriteLine("No known devices attached.");
|
||||
}
|
||||
@@ -96,32 +110,36 @@ namespace DiscImageChef.Commands
|
||||
{
|
||||
devices = devices.OrderBy(d => d.Path).ToArray();
|
||||
|
||||
if (dicRemote is null)
|
||||
if(dicRemote is null)
|
||||
{
|
||||
DicConsole.WriteLine("{0,-22}|{1,-16}|{2,-24}|{3,-24}|{4,-10}|{5,-10}", "Path", "Vendor", "Model",
|
||||
"Serial", "Bus", "Supported?");
|
||||
"Serial", "Bus", "Supported?");
|
||||
|
||||
DicConsole.WriteLine("{0,-22}+{1,-16}+{2,-24}+{3,-24}+{4,-10}+{5,-10}", "----------------------",
|
||||
"----------------", "------------------------", "------------------------",
|
||||
"----------", "----------");
|
||||
foreach (var dev in devices)
|
||||
"----------------", "------------------------", "------------------------",
|
||||
"----------", "----------");
|
||||
|
||||
foreach(DeviceInfo dev in devices)
|
||||
DicConsole.WriteLine("{0,-22}|{1,-16}|{2,-24}|{3,-24}|{4,-10}|{5,-10}", dev.Path, dev.Vendor,
|
||||
dev.Model, dev.Serial, dev.Bus, dev.Supported);
|
||||
dev.Model, dev.Serial, dev.Bus, dev.Supported);
|
||||
}
|
||||
else
|
||||
{
|
||||
DicConsole.WriteLine("{0,-48}|{1,-16}|{2,-24}|{3,-24}|{4,-10}|{5,-10}", "Path", "Vendor", "Model",
|
||||
"Serial", "Bus", "Supported?");
|
||||
"Serial", "Bus", "Supported?");
|
||||
|
||||
DicConsole.WriteLine("{0,-48}+{1,-16}+{2,-24}+{3,-24}+{4,-10}+{5,-10}",
|
||||
"------------------------------------------------",
|
||||
"----------------", "------------------------", "------------------------",
|
||||
"----------", "----------");
|
||||
foreach (var dev in devices)
|
||||
"------------------------------------------------", "----------------",
|
||||
"------------------------", "------------------------", "----------",
|
||||
"----------");
|
||||
|
||||
foreach(DeviceInfo dev in devices)
|
||||
DicConsole.WriteLine("{0,-48}|{1,-16}|{2,-24}|{3,-24}|{4,-10}|{5,-10}", dev.Path, dev.Vendor,
|
||||
dev.Model, dev.Serial, dev.Bus, dev.Supported);
|
||||
dev.Model, dev.Serial, dev.Bus, dev.Supported);
|
||||
}
|
||||
}
|
||||
|
||||
return (int) ErrorNumber.NoError;
|
||||
return(int)ErrorNumber.NoError;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -55,53 +55,57 @@ namespace DiscImageChef.Commands
|
||||
{
|
||||
internal class MediaInfoCommand : Command
|
||||
{
|
||||
private string devicePath;
|
||||
private string outputPrefix;
|
||||
private bool showHelp;
|
||||
string devicePath;
|
||||
string outputPrefix;
|
||||
bool showHelp;
|
||||
|
||||
public MediaInfoCommand() : base("media-info", "Gets information about the media inserted on a device.")
|
||||
{
|
||||
public MediaInfoCommand() : base("media-info", "Gets information about the media inserted on a device.") =>
|
||||
Options = new OptionSet
|
||||
{
|
||||
$"{MainClass.AssemblyTitle} {MainClass.AssemblyVersion?.InformationalVersion}",
|
||||
$"{MainClass.AssemblyCopyright}",
|
||||
"",
|
||||
$"usage: DiscImageChef {Name} [OPTIONS] devicepath",
|
||||
"",
|
||||
$"{MainClass.AssemblyCopyright}", "", $"usage: DiscImageChef {Name} [OPTIONS] devicepath", "",
|
||||
Help,
|
||||
{"output-prefix|w=", "Write binary responses from device with that prefix.", s => outputPrefix = s},
|
||||
{
|
||||
"help|h|?", "Show this message and exit.",
|
||||
v => showHelp = v != null
|
||||
"output-prefix|w=", "Write binary responses from device with that prefix.", s => outputPrefix = s
|
||||
},
|
||||
{
|
||||
"help|h|?", "Show this message and exit.", v => showHelp = v != null
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
public override int Invoke(IEnumerable<string> arguments)
|
||||
{
|
||||
var extra = Options.Parse(arguments);
|
||||
List<string> extra = Options.Parse(arguments);
|
||||
|
||||
if (showHelp)
|
||||
if(showHelp)
|
||||
{
|
||||
Options.WriteOptionDescriptions(CommandSet.Out);
|
||||
return (int) ErrorNumber.HelpRequested;
|
||||
|
||||
return(int)ErrorNumber.HelpRequested;
|
||||
}
|
||||
|
||||
MainClass.PrintCopyright();
|
||||
if (MainClass.Debug) DicConsole.DebugWriteLineEvent += System.Console.Error.WriteLine;
|
||||
if (MainClass.Verbose) DicConsole.VerboseWriteLineEvent += System.Console.WriteLine;
|
||||
|
||||
if(MainClass.Debug)
|
||||
DicConsole.DebugWriteLineEvent += System.Console.Error.WriteLine;
|
||||
|
||||
if(MainClass.Verbose)
|
||||
DicConsole.VerboseWriteLineEvent += System.Console.WriteLine;
|
||||
|
||||
Statistics.AddCommand("media-info");
|
||||
|
||||
if (extra.Count > 1)
|
||||
if(extra.Count > 1)
|
||||
{
|
||||
DicConsole.ErrorWriteLine("Too many arguments.");
|
||||
return (int) ErrorNumber.UnexpectedArgumentCount;
|
||||
|
||||
return(int)ErrorNumber.UnexpectedArgumentCount;
|
||||
}
|
||||
|
||||
if (extra.Count == 0)
|
||||
if(extra.Count == 0)
|
||||
{
|
||||
DicConsole.ErrorWriteLine("Missing device path.");
|
||||
return (int) ErrorNumber.MissingArgument;
|
||||
|
||||
return(int)ErrorNumber.MissingArgument;
|
||||
}
|
||||
|
||||
devicePath = extra[0];
|
||||
@@ -111,79 +115,87 @@ namespace DiscImageChef.Commands
|
||||
DicConsole.DebugWriteLine("Media-Info command", "--output-prefix={0}", outputPrefix);
|
||||
DicConsole.DebugWriteLine("Media-Info command", "--verbose={0}", MainClass.Verbose);
|
||||
|
||||
if (devicePath.Length == 2 && devicePath[1] == ':' && devicePath[0] != '/' && char.IsLetter(devicePath[0]))
|
||||
if(devicePath.Length == 2 &&
|
||||
devicePath[1] == ':' &&
|
||||
devicePath[0] != '/' &&
|
||||
char.IsLetter(devicePath[0]))
|
||||
devicePath = "\\\\.\\" + char.ToUpper(devicePath[0]) + ':';
|
||||
|
||||
Device dev;
|
||||
|
||||
try
|
||||
{
|
||||
dev = new Device(devicePath);
|
||||
|
||||
if (dev.Error)
|
||||
if(dev.IsRemote)
|
||||
Statistics.AddRemote(dev.RemoteApplication, dev.RemoteVersion, dev.RemoteOperatingSystem,
|
||||
dev.RemoteOperatingSystemVersion, dev.RemoteArchitecture);
|
||||
|
||||
if(dev.Error)
|
||||
{
|
||||
DicConsole.ErrorWriteLine(Error.Print(dev.LastError));
|
||||
return (int) ErrorNumber.CannotOpenDevice;
|
||||
|
||||
return(int)ErrorNumber.CannotOpenDevice;
|
||||
}
|
||||
}
|
||||
catch (DeviceException e)
|
||||
catch(DeviceException e)
|
||||
{
|
||||
DicConsole.ErrorWriteLine(e.Message ?? Error.Print(e.LastError));
|
||||
return (int) ErrorNumber.CannotOpenDevice;
|
||||
|
||||
return(int)ErrorNumber.CannotOpenDevice;
|
||||
}
|
||||
|
||||
Statistics.AddDevice(dev);
|
||||
|
||||
switch (dev.Type)
|
||||
switch(dev.Type)
|
||||
{
|
||||
case DeviceType.ATA:
|
||||
DoAtaMediaInfo();
|
||||
|
||||
break;
|
||||
case DeviceType.MMC:
|
||||
case DeviceType.SecureDigital:
|
||||
DoSdMediaInfo();
|
||||
|
||||
break;
|
||||
case DeviceType.NVMe:
|
||||
DoNvmeMediaInfo(outputPrefix, dev);
|
||||
|
||||
break;
|
||||
case DeviceType.ATAPI:
|
||||
case DeviceType.SCSI:
|
||||
DoScsiMediaInfo(outputPrefix, dev);
|
||||
|
||||
break;
|
||||
default: throw new NotSupportedException("Unknown device type.");
|
||||
}
|
||||
|
||||
return (int) ErrorNumber.NoError;
|
||||
return(int)ErrorNumber.NoError;
|
||||
}
|
||||
|
||||
private static void DoAtaMediaInfo()
|
||||
{
|
||||
DicConsole.ErrorWriteLine("Please use device-info command for ATA devices.");
|
||||
}
|
||||
static void DoAtaMediaInfo() => DicConsole.ErrorWriteLine("Please use device-info command for ATA devices.");
|
||||
|
||||
private static void DoNvmeMediaInfo(string outputPrefix, Device dev)
|
||||
{
|
||||
static void DoNvmeMediaInfo(string outputPrefix, Device dev) =>
|
||||
throw new NotImplementedException("NVMe devices not yet supported.");
|
||||
}
|
||||
|
||||
private static void DoSdMediaInfo()
|
||||
{
|
||||
DicConsole.ErrorWriteLine("Please use device-info command for MMC/SD devices.");
|
||||
}
|
||||
static void DoSdMediaInfo() => DicConsole.ErrorWriteLine("Please use device-info command for MMC/SD devices.");
|
||||
|
||||
private static void DoScsiMediaInfo(string outputPrefix, Device dev)
|
||||
static void DoScsiMediaInfo(string outputPrefix, Device dev)
|
||||
{
|
||||
var scsiInfo = new ScsiInfo(dev);
|
||||
|
||||
if (!scsiInfo.MediaInserted) return;
|
||||
if(!scsiInfo.MediaInserted)
|
||||
return;
|
||||
|
||||
if (scsiInfo.DeviceInfo.ScsiModeSense6 != null)
|
||||
if(scsiInfo.DeviceInfo.ScsiModeSense6 != null)
|
||||
DataFile.WriteTo("Media-Info command", outputPrefix, "_scsi_modesense6.bin", "SCSI MODE SENSE (6)",
|
||||
scsiInfo.DeviceInfo.ScsiModeSense6);
|
||||
if (scsiInfo.DeviceInfo.ScsiModeSense10 != null)
|
||||
DataFile.WriteTo("Media-Info command", outputPrefix, "_scsi_modesense10.bin", "SCSI MODE SENSE (10)",
|
||||
scsiInfo.DeviceInfo.ScsiModeSense10);
|
||||
scsiInfo.DeviceInfo.ScsiModeSense6);
|
||||
|
||||
switch (dev.ScsiType)
|
||||
if(scsiInfo.DeviceInfo.ScsiModeSense10 != null)
|
||||
DataFile.WriteTo("Media-Info command", outputPrefix, "_scsi_modesense10.bin", "SCSI MODE SENSE (10)",
|
||||
scsiInfo.DeviceInfo.ScsiModeSense10);
|
||||
|
||||
switch(dev.ScsiType)
|
||||
{
|
||||
case PeripheralDeviceTypes.DirectAccess:
|
||||
case PeripheralDeviceTypes.MultiMediaDevice:
|
||||
@@ -191,37 +203,40 @@ namespace DiscImageChef.Commands
|
||||
case PeripheralDeviceTypes.OpticalDevice:
|
||||
case PeripheralDeviceTypes.SimplifiedDevice:
|
||||
case PeripheralDeviceTypes.WriteOnceDevice:
|
||||
if (scsiInfo.ReadCapacity != null)
|
||||
if(scsiInfo.ReadCapacity != null)
|
||||
DataFile.WriteTo("Media-Info command", outputPrefix, "_readcapacity.bin", "SCSI READ CAPACITY",
|
||||
scsiInfo.ReadCapacity);
|
||||
scsiInfo.ReadCapacity);
|
||||
|
||||
if (scsiInfo.ReadCapacity16 != null)
|
||||
if(scsiInfo.ReadCapacity16 != null)
|
||||
DataFile.WriteTo("Media-Info command", outputPrefix, "_readcapacity16.bin",
|
||||
"SCSI READ CAPACITY(16)", scsiInfo.ReadCapacity16);
|
||||
"SCSI READ CAPACITY(16)", scsiInfo.ReadCapacity16);
|
||||
|
||||
if (scsiInfo.Blocks != 0 && scsiInfo.BlockSize != 0)
|
||||
if(scsiInfo.Blocks != 0 &&
|
||||
scsiInfo.BlockSize != 0)
|
||||
DicConsole.WriteLine("Media has {0} blocks of {1} bytes/each. (for a total of {2} bytes)",
|
||||
scsiInfo.Blocks, scsiInfo.BlockSize, scsiInfo.Blocks * scsiInfo.BlockSize);
|
||||
scsiInfo.Blocks, scsiInfo.BlockSize, scsiInfo.Blocks * scsiInfo.BlockSize);
|
||||
|
||||
break;
|
||||
case PeripheralDeviceTypes.SequentialAccess:
|
||||
if (scsiInfo.DensitySupport != null)
|
||||
if(scsiInfo.DensitySupport != null)
|
||||
{
|
||||
DataFile.WriteTo("Media-Info command", outputPrefix, "_ssc_reportdensitysupport_media.bin",
|
||||
"SSC REPORT DENSITY SUPPORT (MEDIA)", scsiInfo.DensitySupport);
|
||||
if (scsiInfo.DensitySupportHeader.HasValue)
|
||||
"SSC REPORT DENSITY SUPPORT (MEDIA)", scsiInfo.DensitySupport);
|
||||
|
||||
if(scsiInfo.DensitySupportHeader.HasValue)
|
||||
{
|
||||
DicConsole.WriteLine("Densities supported by currently inserted media:");
|
||||
DicConsole.WriteLine(DensitySupport.PrettifyDensity(scsiInfo.DensitySupportHeader));
|
||||
}
|
||||
}
|
||||
|
||||
if (scsiInfo.MediaTypeSupport != null)
|
||||
if(scsiInfo.MediaTypeSupport != null)
|
||||
{
|
||||
DataFile.WriteTo("Media-Info command", outputPrefix,
|
||||
"_ssc_reportdensitysupport_medium_media.bin",
|
||||
"SSC REPORT DENSITY SUPPORT (MEDIUM & MEDIA)", scsiInfo.MediaTypeSupport);
|
||||
if (scsiInfo.MediaTypeSupportHeader.HasValue)
|
||||
"_ssc_reportdensitysupport_medium_media.bin",
|
||||
"SSC REPORT DENSITY SUPPORT (MEDIUM & MEDIA)", scsiInfo.MediaTypeSupport);
|
||||
|
||||
if(scsiInfo.MediaTypeSupportHeader.HasValue)
|
||||
{
|
||||
DicConsole.WriteLine("Medium types currently inserted in device:");
|
||||
DicConsole.WriteLine(DensitySupport.PrettifyMediumType(scsiInfo.MediaTypeSupportHeader));
|
||||
@@ -233,258 +248,285 @@ namespace DiscImageChef.Commands
|
||||
break;
|
||||
}
|
||||
|
||||
if (dev.ScsiType == PeripheralDeviceTypes.MultiMediaDevice)
|
||||
if(dev.ScsiType == PeripheralDeviceTypes.MultiMediaDevice)
|
||||
{
|
||||
if (scsiInfo.MmcConfiguration != null)
|
||||
if(scsiInfo.MmcConfiguration != null)
|
||||
DataFile.WriteTo("Media-Info command", outputPrefix, "_getconfiguration_current.bin",
|
||||
"SCSI GET CONFIGURATION", scsiInfo.MmcConfiguration);
|
||||
"SCSI GET CONFIGURATION", scsiInfo.MmcConfiguration);
|
||||
|
||||
if (scsiInfo.RecognizedFormatLayers != null)
|
||||
if(scsiInfo.RecognizedFormatLayers != null)
|
||||
DataFile.WriteTo("Media-Info command", outputPrefix, "_readdiscstructure_formatlayers.bin",
|
||||
"SCSI READ DISC STRUCTURE", scsiInfo.RecognizedFormatLayers);
|
||||
"SCSI READ DISC STRUCTURE", scsiInfo.RecognizedFormatLayers);
|
||||
|
||||
if (scsiInfo.WriteProtectionStatus != null)
|
||||
if(scsiInfo.WriteProtectionStatus != null)
|
||||
DataFile.WriteTo("Media-Info command", outputPrefix, "_readdiscstructure_writeprotection.bin",
|
||||
"SCSI READ DISC STRUCTURE", scsiInfo.WriteProtectionStatus);
|
||||
"SCSI READ DISC STRUCTURE", scsiInfo.WriteProtectionStatus);
|
||||
|
||||
if (scsiInfo.DvdPfi != null)
|
||||
if(scsiInfo.DvdPfi != null)
|
||||
{
|
||||
DataFile.WriteTo("Media-Info command", outputPrefix, "_readdiscstructure_dvd_pfi.bin",
|
||||
"SCSI READ DISC STRUCTURE", scsiInfo.DvdPfi);
|
||||
"SCSI READ DISC STRUCTURE", scsiInfo.DvdPfi);
|
||||
|
||||
if (scsiInfo.DecodedPfi.HasValue)
|
||||
if(scsiInfo.DecodedPfi.HasValue)
|
||||
DicConsole.WriteLine("PFI:\n{0}", PFI.Prettify(scsiInfo.DecodedPfi));
|
||||
}
|
||||
|
||||
if (scsiInfo.DvdDmi != null)
|
||||
if(scsiInfo.DvdDmi != null)
|
||||
{
|
||||
DataFile.WriteTo("Media-Info command", outputPrefix, "_readdiscstructure_dvd_dmi.bin",
|
||||
"SCSI READ DISC STRUCTURE", scsiInfo.DvdDmi);
|
||||
if (DMI.IsXbox(scsiInfo.DvdDmi))
|
||||
"SCSI READ DISC STRUCTURE", scsiInfo.DvdDmi);
|
||||
|
||||
if(DMI.IsXbox(scsiInfo.DvdDmi))
|
||||
DicConsole.WriteLine("Xbox DMI:\n{0}", DMI.PrettifyXbox(scsiInfo.DvdDmi));
|
||||
else if (DMI.IsXbox360(scsiInfo.DvdDmi))
|
||||
else if(DMI.IsXbox360(scsiInfo.DvdDmi))
|
||||
DicConsole.WriteLine("Xbox 360 DMI:\n{0}", DMI.PrettifyXbox360(scsiInfo.DvdDmi));
|
||||
}
|
||||
|
||||
if (scsiInfo.DvdCmi != null)
|
||||
if(scsiInfo.DvdCmi != null)
|
||||
{
|
||||
DataFile.WriteTo("Media-Info command", outputPrefix, "_readdiscstructure_dvd_cmi.bin",
|
||||
"SCSI READ DISC STRUCTURE", scsiInfo.DvdCmi);
|
||||
"SCSI READ DISC STRUCTURE", scsiInfo.DvdCmi);
|
||||
|
||||
DicConsole.WriteLine("Lead-In CMI:\n{0}", CSS_CPRM.PrettifyLeadInCopyright(scsiInfo.DvdCmi));
|
||||
}
|
||||
|
||||
if (scsiInfo.DvdBca != null)
|
||||
if(scsiInfo.DvdBca != null)
|
||||
DataFile.WriteTo("Media-Info command", outputPrefix, "_readdiscstructure_dvd_bca.bin",
|
||||
"SCSI READ DISC STRUCTURE", scsiInfo.DvdBca);
|
||||
if (scsiInfo.DvdAacs != null)
|
||||
"SCSI READ DISC STRUCTURE", scsiInfo.DvdBca);
|
||||
|
||||
if(scsiInfo.DvdAacs != null)
|
||||
DataFile.WriteTo("Media-Info command", outputPrefix, "_readdiscstructure_dvd_aacs.bin",
|
||||
"SCSI READ DISC STRUCTURE", scsiInfo.DvdAacs);
|
||||
if (scsiInfo.DvdRamDds != null)
|
||||
"SCSI READ DISC STRUCTURE", scsiInfo.DvdAacs);
|
||||
|
||||
if(scsiInfo.DvdRamDds != null)
|
||||
{
|
||||
DataFile.WriteTo("Media-Info command", outputPrefix, "_readdiscstructure_dvdram_dds.bin",
|
||||
"SCSI READ DISC STRUCTURE", scsiInfo.DvdRamDds);
|
||||
"SCSI READ DISC STRUCTURE", scsiInfo.DvdRamDds);
|
||||
|
||||
DicConsole.WriteLine("Disc Definition Structure:\n{0}", DDS.Prettify(scsiInfo.DvdRamDds));
|
||||
}
|
||||
|
||||
if (scsiInfo.DvdRamCartridgeStatus != null)
|
||||
if(scsiInfo.DvdRamCartridgeStatus != null)
|
||||
{
|
||||
DataFile.WriteTo("Media-Info command", outputPrefix, "_readdiscstructure_dvdram_status.bin",
|
||||
"SCSI READ DISC STRUCTURE", scsiInfo.DvdRamCartridgeStatus);
|
||||
"SCSI READ DISC STRUCTURE", scsiInfo.DvdRamCartridgeStatus);
|
||||
|
||||
DicConsole.WriteLine("Medium Status:\n{0}", Cartridge.Prettify(scsiInfo.DvdRamCartridgeStatus));
|
||||
}
|
||||
|
||||
if (scsiInfo.DvdRamSpareArea != null)
|
||||
if(scsiInfo.DvdRamSpareArea != null)
|
||||
{
|
||||
DataFile.WriteTo("Media-Info command", outputPrefix, "_readdiscstructure_dvdram_spare.bin",
|
||||
"SCSI READ DISC STRUCTURE", scsiInfo.DvdRamSpareArea);
|
||||
"SCSI READ DISC STRUCTURE", scsiInfo.DvdRamSpareArea);
|
||||
|
||||
DicConsole.WriteLine("Spare Area Information:\n{0}", Spare.Prettify(scsiInfo.DvdRamSpareArea));
|
||||
}
|
||||
|
||||
if (scsiInfo.LastBorderOutRmd != null)
|
||||
if(scsiInfo.LastBorderOutRmd != null)
|
||||
DataFile.WriteTo("Media-Info command", outputPrefix, "_readdiscstructure_dvd_lastrmd.bin",
|
||||
"SCSI READ DISC STRUCTURE", scsiInfo.LastBorderOutRmd);
|
||||
"SCSI READ DISC STRUCTURE", scsiInfo.LastBorderOutRmd);
|
||||
|
||||
if (scsiInfo.DvdPreRecordedInfo != null)
|
||||
if(scsiInfo.DvdPreRecordedInfo != null)
|
||||
DataFile.WriteTo("Media-Info command", outputPrefix, "_readdiscstructure_dvd_pri.bin",
|
||||
"SCSI READ DISC STRUCTURE", scsiInfo.DvdPreRecordedInfo);
|
||||
"SCSI READ DISC STRUCTURE", scsiInfo.DvdPreRecordedInfo);
|
||||
|
||||
if (scsiInfo.DvdrMediaIdentifier != null)
|
||||
if(scsiInfo.DvdrMediaIdentifier != null)
|
||||
DataFile.WriteTo("Media-Info command", outputPrefix, "_readdiscstructure_dvdr_mediaid.bin",
|
||||
"SCSI READ DISC STRUCTURE", scsiInfo.DvdrMediaIdentifier);
|
||||
if (scsiInfo.DvdrPhysicalInformation != null)
|
||||
"SCSI READ DISC STRUCTURE", scsiInfo.DvdrMediaIdentifier);
|
||||
|
||||
if(scsiInfo.DvdrPhysicalInformation != null)
|
||||
DataFile.WriteTo("Media-Info command", outputPrefix, "_readdiscstructure_dvdr_pfi.bin",
|
||||
"SCSI READ DISC STRUCTURE", scsiInfo.DvdrPhysicalInformation);
|
||||
if (scsiInfo.DvdPlusAdip != null)
|
||||
"SCSI READ DISC STRUCTURE", scsiInfo.DvdrPhysicalInformation);
|
||||
|
||||
if(scsiInfo.DvdPlusAdip != null)
|
||||
DataFile.WriteTo("Media-Info command", outputPrefix, "_readdiscstructure_dvd+_adip.bin",
|
||||
"SCSI READ DISC STRUCTURE", scsiInfo.DvdPlusAdip);
|
||||
"SCSI READ DISC STRUCTURE", scsiInfo.DvdPlusAdip);
|
||||
|
||||
if (scsiInfo.DvdPlusDcb != null)
|
||||
if(scsiInfo.DvdPlusDcb != null)
|
||||
DataFile.WriteTo("Media-Info command", outputPrefix, "_readdiscstructure_dvd+_dcb.bin",
|
||||
"SCSI READ DISC STRUCTURE", scsiInfo.DvdPlusDcb);
|
||||
if (scsiInfo.HddvdCopyrightInformation != null)
|
||||
"SCSI READ DISC STRUCTURE", scsiInfo.DvdPlusDcb);
|
||||
|
||||
if(scsiInfo.HddvdCopyrightInformation != null)
|
||||
DataFile.WriteTo("Media-Info command", outputPrefix, "_readdiscstructure_hddvd_cmi.bin",
|
||||
"SCSI READ DISC STRUCTURE", scsiInfo.HddvdCopyrightInformation);
|
||||
if (scsiInfo.HddvdrMediumStatus != null)
|
||||
"SCSI READ DISC STRUCTURE", scsiInfo.HddvdCopyrightInformation);
|
||||
|
||||
if(scsiInfo.HddvdrMediumStatus != null)
|
||||
DataFile.WriteTo("Media-Info command", outputPrefix, "_readdiscstructure_hddvdr_status.bin",
|
||||
"SCSI READ DISC STRUCTURE", scsiInfo.HddvdrMediumStatus);
|
||||
"SCSI READ DISC STRUCTURE", scsiInfo.HddvdrMediumStatus);
|
||||
|
||||
if (scsiInfo.HddvdrLastRmd != null)
|
||||
if(scsiInfo.HddvdrLastRmd != null)
|
||||
DataFile.WriteTo("Media-Info command", outputPrefix, "_readdiscstructure_hddvdr_lastrmd.bin",
|
||||
"SCSI READ DISC STRUCTURE", scsiInfo.HddvdrLastRmd);
|
||||
"SCSI READ DISC STRUCTURE", scsiInfo.HddvdrLastRmd);
|
||||
|
||||
if (scsiInfo.DvdrLayerCapacity != null)
|
||||
if(scsiInfo.DvdrLayerCapacity != null)
|
||||
DataFile.WriteTo("Media-Info command", outputPrefix, "_readdiscstructure_dvdr_layercap.bin",
|
||||
"SCSI READ DISC STRUCTURE", scsiInfo.DvdrLayerCapacity);
|
||||
"SCSI READ DISC STRUCTURE", scsiInfo.DvdrLayerCapacity);
|
||||
|
||||
if (scsiInfo.DvdrDlMiddleZoneStart != null)
|
||||
if(scsiInfo.DvdrDlMiddleZoneStart != null)
|
||||
DataFile.WriteTo("Media-Info command", outputPrefix, "_readdiscstructure_dvd_mzs.bin",
|
||||
"SCSI READ DISC STRUCTURE", scsiInfo.DvdrDlMiddleZoneStart);
|
||||
"SCSI READ DISC STRUCTURE", scsiInfo.DvdrDlMiddleZoneStart);
|
||||
|
||||
if (scsiInfo.DvdrDlJumpIntervalSize != null)
|
||||
if(scsiInfo.DvdrDlJumpIntervalSize != null)
|
||||
DataFile.WriteTo("Media-Info command", outputPrefix, "_readdiscstructure_dvd_jis.bin",
|
||||
"SCSI READ DISC STRUCTURE", scsiInfo.DvdrDlJumpIntervalSize);
|
||||
"SCSI READ DISC STRUCTURE", scsiInfo.DvdrDlJumpIntervalSize);
|
||||
|
||||
if (scsiInfo.DvdrDlManualLayerJumpStartLba != null)
|
||||
if(scsiInfo.DvdrDlManualLayerJumpStartLba != null)
|
||||
DataFile.WriteTo("Media-Info command", outputPrefix, "_readdiscstructure_dvd_manuallj.bin",
|
||||
"SCSI READ DISC STRUCTURE", scsiInfo.DvdrDlManualLayerJumpStartLba);
|
||||
"SCSI READ DISC STRUCTURE", scsiInfo.DvdrDlManualLayerJumpStartLba);
|
||||
|
||||
if (scsiInfo.DvdrDlRemapAnchorPoint != null)
|
||||
if(scsiInfo.DvdrDlRemapAnchorPoint != null)
|
||||
DataFile.WriteTo("Media-Info command", outputPrefix, "_readdiscstructure_dvd_remapanchor.bin",
|
||||
"SCSI READ DISC STRUCTURE", scsiInfo.DvdrDlRemapAnchorPoint);
|
||||
if (scsiInfo.BlurayDiscInformation != null)
|
||||
"SCSI READ DISC STRUCTURE", scsiInfo.DvdrDlRemapAnchorPoint);
|
||||
|
||||
if(scsiInfo.BlurayDiscInformation != null)
|
||||
{
|
||||
DataFile.WriteTo("Media-Info command", outputPrefix, "_readdiscstructure_bd_di.bin",
|
||||
"SCSI READ DISC STRUCTURE", scsiInfo.BlurayDiscInformation);
|
||||
"SCSI READ DISC STRUCTURE", scsiInfo.BlurayDiscInformation);
|
||||
|
||||
DicConsole.WriteLine("Blu-ray Disc Information:\n{0}", DI.Prettify(scsiInfo.BlurayDiscInformation));
|
||||
}
|
||||
|
||||
if (scsiInfo.BlurayPac != null)
|
||||
if(scsiInfo.BlurayPac != null)
|
||||
DataFile.WriteTo("Media-Info command", outputPrefix, "_readdiscstructure_bd_pac.bin",
|
||||
"SCSI READ DISC STRUCTURE", scsiInfo.BlurayPac);
|
||||
"SCSI READ DISC STRUCTURE", scsiInfo.BlurayPac);
|
||||
|
||||
if (scsiInfo.BlurayBurstCuttingArea != null)
|
||||
if(scsiInfo.BlurayBurstCuttingArea != null)
|
||||
{
|
||||
DataFile.WriteTo("Media-Info command", outputPrefix, "_readdiscstructure_bd_bca.bin",
|
||||
"SCSI READ DISC STRUCTURE", scsiInfo.BlurayBurstCuttingArea);
|
||||
"SCSI READ DISC STRUCTURE", scsiInfo.BlurayBurstCuttingArea);
|
||||
|
||||
DicConsole.WriteLine("Blu-ray Burst Cutting Area:\n{0}",
|
||||
BCA.Prettify(scsiInfo.BlurayBurstCuttingArea));
|
||||
BCA.Prettify(scsiInfo.BlurayBurstCuttingArea));
|
||||
}
|
||||
|
||||
if (scsiInfo.BlurayDds != null)
|
||||
if(scsiInfo.BlurayDds != null)
|
||||
{
|
||||
DataFile.WriteTo("Media-Info command", outputPrefix, "_readdiscstructure_bd_dds.bin",
|
||||
"SCSI READ DISC STRUCTURE", scsiInfo.BlurayDds);
|
||||
"SCSI READ DISC STRUCTURE", scsiInfo.BlurayDds);
|
||||
|
||||
DicConsole.WriteLine("Blu-ray Disc Definition Structure:\n{0}",
|
||||
Decoders.Bluray.DDS.Prettify(scsiInfo.BlurayDds));
|
||||
Decoders.Bluray.DDS.Prettify(scsiInfo.BlurayDds));
|
||||
}
|
||||
|
||||
if (scsiInfo.BlurayCartridgeStatus != null)
|
||||
if(scsiInfo.BlurayCartridgeStatus != null)
|
||||
{
|
||||
DataFile.WriteTo("Media-Info command", outputPrefix, "_readdiscstructure_bd_cartstatus.bin",
|
||||
"SCSI READ DISC STRUCTURE", scsiInfo.BlurayCartridgeStatus);
|
||||
"SCSI READ DISC STRUCTURE", scsiInfo.BlurayCartridgeStatus);
|
||||
|
||||
DicConsole.WriteLine("Blu-ray Cartridge Status:\n{0}",
|
||||
Decoders.Bluray.Cartridge.Prettify(scsiInfo.BlurayCartridgeStatus));
|
||||
Decoders.Bluray.Cartridge.Prettify(scsiInfo.BlurayCartridgeStatus));
|
||||
}
|
||||
|
||||
if (scsiInfo.BluraySpareAreaInformation != null)
|
||||
if(scsiInfo.BluraySpareAreaInformation != null)
|
||||
{
|
||||
DataFile.WriteTo("Media-Info command", outputPrefix, "_readdiscstructure_bd_spare.bin",
|
||||
"SCSI READ DISC STRUCTURE", scsiInfo.BluraySpareAreaInformation);
|
||||
"SCSI READ DISC STRUCTURE", scsiInfo.BluraySpareAreaInformation);
|
||||
|
||||
DicConsole.WriteLine("Blu-ray Spare Area Information:\n{0}",
|
||||
Decoders.Bluray.Spare.Prettify(scsiInfo.BluraySpareAreaInformation));
|
||||
Decoders.Bluray.Spare.Prettify(scsiInfo.BluraySpareAreaInformation));
|
||||
}
|
||||
|
||||
if (scsiInfo.BlurayRawDfl != null)
|
||||
if(scsiInfo.BlurayRawDfl != null)
|
||||
DataFile.WriteTo("Media-Info command", outputPrefix, "_readdiscstructure_bd_dfl.bin",
|
||||
"SCSI READ DISC STRUCTURE", scsiInfo.BlurayRawDfl);
|
||||
"SCSI READ DISC STRUCTURE", scsiInfo.BlurayRawDfl);
|
||||
|
||||
if (scsiInfo.BlurayTrackResources != null)
|
||||
if(scsiInfo.BlurayTrackResources != null)
|
||||
{
|
||||
DicConsole.WriteLine("Track Resources Information:\n{0}",
|
||||
DiscInformation.Prettify(scsiInfo.BlurayTrackResources));
|
||||
DiscInformation.Prettify(scsiInfo.BlurayTrackResources));
|
||||
|
||||
DataFile.WriteTo("Media-Info command", outputPrefix, "_readdiscinformation_001b.bin",
|
||||
"SCSI READ DISC INFORMATION", scsiInfo.BlurayTrackResources);
|
||||
"SCSI READ DISC INFORMATION", scsiInfo.BlurayTrackResources);
|
||||
}
|
||||
|
||||
if (scsiInfo.BlurayPowResources != null)
|
||||
if(scsiInfo.BlurayPowResources != null)
|
||||
{
|
||||
DicConsole.WriteLine("POW Resources Information:\n{0}",
|
||||
DiscInformation.Prettify(scsiInfo.BlurayPowResources));
|
||||
DiscInformation.Prettify(scsiInfo.BlurayPowResources));
|
||||
|
||||
DataFile.WriteTo("Media-Info command", outputPrefix, "_readdiscinformation_010b.bin",
|
||||
"SCSI READ DISC INFORMATION", scsiInfo.BlurayPowResources);
|
||||
"SCSI READ DISC INFORMATION", scsiInfo.BlurayPowResources);
|
||||
}
|
||||
|
||||
if (scsiInfo.Toc != null)
|
||||
if(scsiInfo.Toc != null)
|
||||
{
|
||||
DataFile.WriteTo("Media-Info command", outputPrefix, "_toc.bin", "SCSI READ TOC/PMA/ATIP",
|
||||
scsiInfo.Toc);
|
||||
if (scsiInfo.DecodedToc.HasValue)
|
||||
scsiInfo.Toc);
|
||||
|
||||
if(scsiInfo.DecodedToc.HasValue)
|
||||
DicConsole.WriteLine("TOC:\n{0}", TOC.Prettify(scsiInfo.DecodedToc));
|
||||
}
|
||||
|
||||
if (scsiInfo.Atip != null)
|
||||
if(scsiInfo.Atip != null)
|
||||
{
|
||||
DataFile.WriteTo("Media-Info command", outputPrefix, "_atip.bin", "SCSI READ TOC/PMA/ATIP",
|
||||
scsiInfo.Atip);
|
||||
if (scsiInfo.DecodedAtip.HasValue)
|
||||
scsiInfo.Atip);
|
||||
|
||||
if(scsiInfo.DecodedAtip.HasValue)
|
||||
DicConsole.WriteLine("ATIP:\n{0}", ATIP.Prettify(scsiInfo.DecodedAtip));
|
||||
}
|
||||
|
||||
if (scsiInfo.CompactDiscInformation != null)
|
||||
if(scsiInfo.CompactDiscInformation != null)
|
||||
{
|
||||
DataFile.WriteTo("Media-Info command", outputPrefix, "_readdiscinformation_000b.bin",
|
||||
"SCSI READ DISC INFORMATION", scsiInfo.CompactDiscInformation);
|
||||
if (scsiInfo.DecodedCompactDiscInformation.HasValue)
|
||||
"SCSI READ DISC INFORMATION", scsiInfo.CompactDiscInformation);
|
||||
|
||||
if(scsiInfo.DecodedCompactDiscInformation.HasValue)
|
||||
DicConsole.WriteLine("Standard Disc Information:\n{0}",
|
||||
DiscInformation.Prettify000b(scsiInfo.DecodedCompactDiscInformation));
|
||||
DiscInformation.Prettify000b(scsiInfo.DecodedCompactDiscInformation));
|
||||
}
|
||||
|
||||
if (scsiInfo.Session != null)
|
||||
if(scsiInfo.Session != null)
|
||||
{
|
||||
DataFile.WriteTo("Media-Info command", outputPrefix, "_session.bin", "SCSI READ TOC/PMA/ATIP",
|
||||
scsiInfo.Session);
|
||||
if (scsiInfo.DecodedSession.HasValue)
|
||||
scsiInfo.Session);
|
||||
|
||||
if(scsiInfo.DecodedSession.HasValue)
|
||||
DicConsole.WriteLine("Session information:\n{0}", Session.Prettify(scsiInfo.DecodedSession));
|
||||
}
|
||||
|
||||
if (scsiInfo.RawToc != null)
|
||||
if(scsiInfo.RawToc != null)
|
||||
{
|
||||
DataFile.WriteTo("Media-Info command", outputPrefix, "_rawtoc.bin", "SCSI READ TOC/PMA/ATIP",
|
||||
scsiInfo.RawToc);
|
||||
if (scsiInfo.FullToc.HasValue)
|
||||
scsiInfo.RawToc);
|
||||
|
||||
if(scsiInfo.FullToc.HasValue)
|
||||
DicConsole.WriteLine("Raw TOC:\n{0}", FullTOC.Prettify(scsiInfo.RawToc));
|
||||
}
|
||||
|
||||
if (scsiInfo.Pma != null)
|
||||
if(scsiInfo.Pma != null)
|
||||
{
|
||||
DataFile.WriteTo("Media-Info command", outputPrefix, "_pma.bin", "SCSI READ TOC/PMA/ATIP",
|
||||
scsiInfo.Pma);
|
||||
scsiInfo.Pma);
|
||||
|
||||
DicConsole.WriteLine("PMA:\n{0}", PMA.Prettify(scsiInfo.Pma));
|
||||
}
|
||||
|
||||
if (scsiInfo.CdTextLeadIn != null)
|
||||
if(scsiInfo.CdTextLeadIn != null)
|
||||
{
|
||||
DataFile.WriteTo("Media-Info command", outputPrefix, "_cdtext.bin", "SCSI READ TOC/PMA/ATIP",
|
||||
scsiInfo.CdTextLeadIn);
|
||||
if (scsiInfo.DecodedCdTextLeadIn.HasValue)
|
||||
scsiInfo.CdTextLeadIn);
|
||||
|
||||
if(scsiInfo.DecodedCdTextLeadIn.HasValue)
|
||||
DicConsole.WriteLine("CD-TEXT on Lead-In:\n{0}",
|
||||
CDTextOnLeadIn.Prettify(scsiInfo.DecodedCdTextLeadIn));
|
||||
CDTextOnLeadIn.Prettify(scsiInfo.DecodedCdTextLeadIn));
|
||||
}
|
||||
|
||||
if (!string.IsNullOrEmpty(scsiInfo.Mcn)) DicConsole.WriteLine("MCN: {0}", scsiInfo.Mcn);
|
||||
if(!string.IsNullOrEmpty(scsiInfo.Mcn))
|
||||
DicConsole.WriteLine("MCN: {0}", scsiInfo.Mcn);
|
||||
|
||||
if (scsiInfo.Isrcs != null)
|
||||
foreach (var isrc in scsiInfo.Isrcs)
|
||||
if(scsiInfo.Isrcs != null)
|
||||
foreach(KeyValuePair<byte, string> isrc in scsiInfo.Isrcs)
|
||||
DicConsole.WriteLine("Track's {0} ISRC: {1}", isrc.Key, isrc.Value);
|
||||
|
||||
if (scsiInfo.XboxSecuritySector != null)
|
||||
if(scsiInfo.XboxSecuritySector != null)
|
||||
DataFile.WriteTo("Media-Info command", outputPrefix, "_xbox_ss.bin", "KREON EXTRACT SS",
|
||||
scsiInfo.XboxSecuritySector);
|
||||
scsiInfo.XboxSecuritySector);
|
||||
|
||||
if (scsiInfo.DecodedXboxSecuritySector.HasValue)
|
||||
if(scsiInfo.DecodedXboxSecuritySector.HasValue)
|
||||
DicConsole.WriteLine("Xbox Security Sector:\n{0}", SS.Prettify(scsiInfo.DecodedXboxSecuritySector));
|
||||
|
||||
if (scsiInfo.XgdInfo != null)
|
||||
if(scsiInfo.XgdInfo != null)
|
||||
{
|
||||
DicConsole.WriteLine("Video layer 0 size: {0} sectors", scsiInfo.XgdInfo.L0Video);
|
||||
DicConsole.WriteLine("Video layer 1 size: {0} sectors", scsiInfo.XgdInfo.L1Video);
|
||||
@@ -496,13 +538,14 @@ namespace DiscImageChef.Commands
|
||||
}
|
||||
}
|
||||
|
||||
if (scsiInfo.MediaSerialNumber != null)
|
||||
if(scsiInfo.MediaSerialNumber != null)
|
||||
{
|
||||
DataFile.WriteTo("Media-Info command", outputPrefix, "_mediaserialnumber.bin",
|
||||
"SCSI READ MEDIA SERIAL NUMBER", scsiInfo.MediaSerialNumber);
|
||||
"SCSI READ MEDIA SERIAL NUMBER", scsiInfo.MediaSerialNumber);
|
||||
|
||||
DicConsole.Write("Media Serial Number: ");
|
||||
for (var i = 4; i < scsiInfo.MediaSerialNumber.Length; i++)
|
||||
|
||||
for(int i = 4; i < scsiInfo.MediaSerialNumber.Length; i++)
|
||||
DicConsole.Write("{0:X2}", scsiInfo.MediaSerialNumber[i]);
|
||||
|
||||
DicConsole.WriteLine();
|
||||
|
||||
@@ -42,52 +42,61 @@ namespace DiscImageChef.Commands
|
||||
{
|
||||
internal class MediaScanCommand : Command
|
||||
{
|
||||
private string devicePath;
|
||||
private string ibgLogPath;
|
||||
private string mhddLogPath;
|
||||
private bool showHelp;
|
||||
string devicePath;
|
||||
string ibgLogPath;
|
||||
string mhddLogPath;
|
||||
bool showHelp;
|
||||
|
||||
public MediaScanCommand() : base("media-scan", "Scans the media inserted on a device.")
|
||||
{
|
||||
public MediaScanCommand() : base("media-scan", "Scans the media inserted on a device.") =>
|
||||
Options = new OptionSet
|
||||
{
|
||||
$"{MainClass.AssemblyTitle} {MainClass.AssemblyVersion?.InformationalVersion}",
|
||||
$"{MainClass.AssemblyCopyright}",
|
||||
"",
|
||||
$"usage: DiscImageChef {Name} [OPTIONS] devicepath",
|
||||
"",
|
||||
$"{MainClass.AssemblyCopyright}", "", $"usage: DiscImageChef {Name} [OPTIONS] devicepath", "",
|
||||
Help,
|
||||
{"mhdd-log|mw=", "Write a log of the scan in the format used by MHDD.", s => mhddLogPath = s},
|
||||
{"ibg-log|b=", "Write a log of the scan in the format used by ImgBurn.", s => ibgLogPath = s},
|
||||
{"help|h|?", "Show this message and exit.", v => showHelp = v != null}
|
||||
{
|
||||
"mhdd-log|mw=", "Write a log of the scan in the format used by MHDD.", s => mhddLogPath = s
|
||||
},
|
||||
{
|
||||
"ibg-log|b=", "Write a log of the scan in the format used by ImgBurn.", s => ibgLogPath = s
|
||||
},
|
||||
{
|
||||
"help|h|?", "Show this message and exit.", v => showHelp = v != null
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
public override int Invoke(IEnumerable<string> arguments)
|
||||
{
|
||||
var extra = Options.Parse(arguments);
|
||||
List<string> extra = Options.Parse(arguments);
|
||||
|
||||
if (showHelp)
|
||||
if(showHelp)
|
||||
{
|
||||
Options.WriteOptionDescriptions(CommandSet.Out);
|
||||
return (int) ErrorNumber.HelpRequested;
|
||||
|
||||
return(int)ErrorNumber.HelpRequested;
|
||||
}
|
||||
|
||||
MainClass.PrintCopyright();
|
||||
if (MainClass.Debug) DicConsole.DebugWriteLineEvent += System.Console.Error.WriteLine;
|
||||
if (MainClass.Verbose) DicConsole.VerboseWriteLineEvent += System.Console.WriteLine;
|
||||
|
||||
if(MainClass.Debug)
|
||||
DicConsole.DebugWriteLineEvent += System.Console.Error.WriteLine;
|
||||
|
||||
if(MainClass.Verbose)
|
||||
DicConsole.VerboseWriteLineEvent += System.Console.WriteLine;
|
||||
|
||||
Statistics.AddCommand("media-scan");
|
||||
|
||||
if (extra.Count > 1)
|
||||
if(extra.Count > 1)
|
||||
{
|
||||
DicConsole.ErrorWriteLine("Too many arguments.");
|
||||
return (int) ErrorNumber.UnexpectedArgumentCount;
|
||||
|
||||
return(int)ErrorNumber.UnexpectedArgumentCount;
|
||||
}
|
||||
|
||||
if (extra.Count == 0)
|
||||
if(extra.Count == 0)
|
||||
{
|
||||
DicConsole.ErrorWriteLine("Missing device path.");
|
||||
return (int) ErrorNumber.MissingArgument;
|
||||
|
||||
return(int)ErrorNumber.MissingArgument;
|
||||
}
|
||||
|
||||
devicePath = extra[0];
|
||||
@@ -98,44 +107,57 @@ namespace DiscImageChef.Commands
|
||||
DicConsole.DebugWriteLine("Media-Scan command", "--mhdd-log={0}", mhddLogPath);
|
||||
DicConsole.DebugWriteLine("Media-Scan command", "--verbose={0}", MainClass.Verbose);
|
||||
|
||||
if (devicePath.Length == 2 && devicePath[1] == ':' && devicePath[0] != '/' && char.IsLetter(devicePath[0]))
|
||||
if(devicePath.Length == 2 &&
|
||||
devicePath[1] == ':' &&
|
||||
devicePath[0] != '/' &&
|
||||
char.IsLetter(devicePath[0]))
|
||||
devicePath = "\\\\.\\" + char.ToUpper(devicePath[0]) + ':';
|
||||
|
||||
Device dev;
|
||||
|
||||
try
|
||||
{
|
||||
dev = new Device(devicePath);
|
||||
|
||||
if (dev.Error)
|
||||
if(dev.IsRemote)
|
||||
Statistics.AddRemote(dev.RemoteApplication, dev.RemoteVersion, dev.RemoteOperatingSystem,
|
||||
dev.RemoteOperatingSystemVersion, dev.RemoteArchitecture);
|
||||
|
||||
if(dev.Error)
|
||||
{
|
||||
DicConsole.ErrorWriteLine(Error.Print(dev.LastError));
|
||||
return (int) ErrorNumber.CannotOpenDevice;
|
||||
|
||||
return(int)ErrorNumber.CannotOpenDevice;
|
||||
}
|
||||
}
|
||||
catch (DeviceException e)
|
||||
catch(DeviceException e)
|
||||
{
|
||||
DicConsole.ErrorWriteLine(e.Message ?? Error.Print(e.LastError));
|
||||
return (int) ErrorNumber.CannotOpenDevice;
|
||||
|
||||
return(int)ErrorNumber.CannotOpenDevice;
|
||||
}
|
||||
|
||||
Statistics.AddDevice(dev);
|
||||
|
||||
var scanner = new MediaScan(mhddLogPath, ibgLogPath, devicePath, dev);
|
||||
scanner.UpdateStatus += Progress.UpdateStatus;
|
||||
scanner.UpdateStatus += Progress.UpdateStatus;
|
||||
scanner.StoppingErrorMessage += Progress.ErrorMessage;
|
||||
scanner.UpdateProgress += Progress.UpdateProgress;
|
||||
scanner.PulseProgress += Progress.PulseProgress;
|
||||
scanner.InitProgress += Progress.InitProgress;
|
||||
scanner.EndProgress += Progress.EndProgress;
|
||||
scanner.UpdateProgress += Progress.UpdateProgress;
|
||||
scanner.PulseProgress += Progress.PulseProgress;
|
||||
scanner.InitProgress += Progress.InitProgress;
|
||||
scanner.EndProgress += Progress.EndProgress;
|
||||
|
||||
System.Console.CancelKeyPress += (sender, e) =>
|
||||
{
|
||||
e.Cancel = true;
|
||||
scanner.Abort();
|
||||
};
|
||||
var results = scanner.Scan();
|
||||
|
||||
ScanResults results = scanner.Scan();
|
||||
|
||||
DicConsole.WriteLine("Took a total of {0} seconds ({1} processing commands).", results.TotalTime,
|
||||
results.ProcessingTime);
|
||||
results.ProcessingTime);
|
||||
|
||||
DicConsole.WriteLine("Average speed: {0:F3} MiB/sec.", results.AvgSpeed);
|
||||
DicConsole.WriteLine("Fastest speed burst: {0:F3} MiB/sec.", results.MaxSpeed);
|
||||
DicConsole.WriteLine("Slowest speed burst: {0:F3} MiB/sec.", results.MinSpeed);
|
||||
@@ -146,23 +168,25 @@ namespace DiscImageChef.Commands
|
||||
DicConsole.WriteLine("{0} sectors took less than 150 ms but more than 50 ms.", results.D);
|
||||
DicConsole.WriteLine("{0} sectors took less than 500 ms but more than 150 ms.", results.E);
|
||||
DicConsole.WriteLine("{0} sectors took more than 500 ms.", results.F);
|
||||
DicConsole.WriteLine("{0} sectors could not be read.",
|
||||
results.UnreadableSectors.Count);
|
||||
if (results.UnreadableSectors.Count > 0)
|
||||
foreach (var bad in results.UnreadableSectors)
|
||||
DicConsole.WriteLine("{0} sectors could not be read.", results.UnreadableSectors.Count);
|
||||
|
||||
if(results.UnreadableSectors.Count > 0)
|
||||
foreach(ulong bad in results.UnreadableSectors)
|
||||
DicConsole.WriteLine("Sector {0} could not be read", bad);
|
||||
|
||||
DicConsole.WriteLine();
|
||||
|
||||
#pragma warning disable RECS0018 // Comparison of floating point numbers with equality operator
|
||||
if (results.SeekTotal != 0 || results.SeekMin != double.MaxValue || results.SeekMax != double.MinValue)
|
||||
#pragma warning restore RECS0018 // Comparison of floating point numbers with equality operator
|
||||
DicConsole.WriteLine(
|
||||
"Testing {0} seeks, longest seek took {1:F3} ms, fastest one took {2:F3} ms. ({3:F3} ms average)",
|
||||
results.SeekTimes, results.SeekMax, results.SeekMin, results.SeekTotal / 1000);
|
||||
#pragma warning disable RECS0018 // Comparison of floating point numbers with equality operator
|
||||
if(results.SeekTotal != 0 ||
|
||||
results.SeekMin != double.MaxValue ||
|
||||
results.SeekMax != double.MinValue)
|
||||
#pragma warning restore RECS0018 // Comparison of floating point numbers with equality operator
|
||||
DicConsole.WriteLine("Testing {0} seeks, longest seek took {1:F3} ms, fastest one took {2:F3} ms. ({3:F3} ms average)",
|
||||
results.SeekTimes, results.SeekMax, results.SeekMin, results.SeekTotal / 1000);
|
||||
|
||||
dev.Close();
|
||||
return (int) ErrorNumber.NoError;
|
||||
|
||||
return(int)ErrorNumber.NoError;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -36,55 +36,61 @@ using System;
|
||||
using System.Collections.Generic;
|
||||
using DiscImageChef.CommonTypes.Enums;
|
||||
using DiscImageChef.Console;
|
||||
using DiscImageChef.Devices.Remote;
|
||||
using DiscImageChef.Core;
|
||||
using Mono.Options;
|
||||
using Remote = DiscImageChef.Devices.Remote.Remote;
|
||||
|
||||
namespace DiscImageChef.Commands
|
||||
{
|
||||
internal class RemoteCommand : Command
|
||||
{
|
||||
private string host;
|
||||
private bool showHelp;
|
||||
string host;
|
||||
bool showHelp;
|
||||
|
||||
public RemoteCommand() : base("remote", "Tests connection to a DiscImageChef Remote Server.")
|
||||
{
|
||||
public RemoteCommand() : base("remote", "Tests connection to a DiscImageChef Remote Server.") =>
|
||||
Options = new OptionSet
|
||||
{
|
||||
$"{MainClass.AssemblyTitle} {MainClass.AssemblyVersion?.InformationalVersion}",
|
||||
$"{MainClass.AssemblyCopyright}",
|
||||
"",
|
||||
$"usage: DiscImageChef {Name} [OPTIONS] host",
|
||||
"",
|
||||
$"{MainClass.AssemblyCopyright}", "", $"usage: DiscImageChef {Name} [OPTIONS] host", "",
|
||||
Help,
|
||||
{"help|h|?", "Show this message and exit.", v => showHelp = v != null}
|
||||
{
|
||||
"help|h|?", "Show this message and exit.", v => showHelp = v != null
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
public override int Invoke(IEnumerable<string> arguments)
|
||||
{
|
||||
var extra = Options.Parse(arguments);
|
||||
List<string> extra = Options.Parse(arguments);
|
||||
|
||||
if (showHelp)
|
||||
if(showHelp)
|
||||
{
|
||||
Options.WriteOptionDescriptions(CommandSet.Out);
|
||||
return (int) ErrorNumber.HelpRequested;
|
||||
|
||||
return(int)ErrorNumber.HelpRequested;
|
||||
}
|
||||
|
||||
MainClass.PrintCopyright();
|
||||
if (MainClass.Debug) DicConsole.DebugWriteLineEvent += System.Console.Error.WriteLine;
|
||||
if (MainClass.Verbose) DicConsole.VerboseWriteLineEvent += System.Console.WriteLine;
|
||||
// Statistics.AddCommand("remote");
|
||||
|
||||
if (extra.Count > 1)
|
||||
if(MainClass.Debug)
|
||||
DicConsole.DebugWriteLineEvent += System.Console.Error.WriteLine;
|
||||
|
||||
if(MainClass.Verbose)
|
||||
DicConsole.VerboseWriteLineEvent += System.Console.WriteLine;
|
||||
|
||||
// Statistics.AddCommand("remote");
|
||||
|
||||
if(extra.Count > 1)
|
||||
{
|
||||
DicConsole.ErrorWriteLine("Too many arguments.");
|
||||
return (int) ErrorNumber.UnexpectedArgumentCount;
|
||||
|
||||
return(int)ErrorNumber.UnexpectedArgumentCount;
|
||||
}
|
||||
|
||||
if (extra.Count == 0)
|
||||
if(extra.Count == 0)
|
||||
{
|
||||
DicConsole.ErrorWriteLine("Missing input image.");
|
||||
return (int) ErrorNumber.MissingArgument;
|
||||
|
||||
return(int)ErrorNumber.MissingArgument;
|
||||
}
|
||||
|
||||
host = extra[0];
|
||||
@@ -96,21 +102,26 @@ namespace DiscImageChef.Commands
|
||||
try
|
||||
{
|
||||
var remote = new Remote(host);
|
||||
|
||||
Statistics.AddRemote(remote.ServerApplication, remote.ServerVersion, remote.ServerOperatingSystem,
|
||||
remote.ServerOperatingSystemVersion, remote.ServerArchitecture);
|
||||
|
||||
DicConsole.WriteLine("Server application: {0} {1}", remote.ServerApplication, remote.ServerVersion);
|
||||
|
||||
DicConsole.WriteLine("Server operating system: {0} {1} ({2})", remote.ServerOperatingSystem,
|
||||
remote.ServerOperatingSystemVersion,
|
||||
remote.ServerArchitecture);
|
||||
remote.ServerOperatingSystemVersion, remote.ServerArchitecture);
|
||||
|
||||
DicConsole.WriteLine("Server maximum protocol: {0}", remote.ServerProtocolVersion);
|
||||
remote.Disconnect();
|
||||
}
|
||||
catch (Exception)
|
||||
catch(Exception)
|
||||
{
|
||||
DicConsole.ErrorWriteLine("Error connecting to host.");
|
||||
return (int) ErrorNumber.CannotOpenDevice;
|
||||
|
||||
return(int)ErrorNumber.CannotOpenDevice;
|
||||
}
|
||||
|
||||
|
||||
return (int) ErrorNumber.NoError;
|
||||
return(int)ErrorNumber.NoError;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user