mirror of
https://github.com/aaru-dps/Aaru.Server.git
synced 2025-12-16 19:24:27 +00:00
Added specific console handling for standard, verbose, debug
and error outputs.
This commit is contained in:
@@ -1,3 +1,20 @@
|
||||
2015-10-18 Natalia Portillo <claunia@claunia.com>
|
||||
|
||||
* Main.cs:
|
||||
* Plugins.cs:
|
||||
* Commands/Decode.cs:
|
||||
* Commands/Verify.cs:
|
||||
* Commands/Analyze.cs:
|
||||
* Commands/Formats.cs:
|
||||
* Commands/Entropy.cs:
|
||||
* Commands/Compare.cs:
|
||||
* Commands/PrintHex.cs:
|
||||
* Commands/Checksum.cs:
|
||||
* DiscImageChef.csproj:
|
||||
* Commands/DeviceInfo.cs:
|
||||
Added specific console handling for standard, verbose, debug
|
||||
and error outputs.
|
||||
|
||||
2015-10-17 Natalia Portillo <claunia@claunia.com>
|
||||
|
||||
* Commands/DeviceInfo.cs:
|
||||
|
||||
@@ -40,6 +40,7 @@ using System.Collections.Generic;
|
||||
using DiscImageChef.Plugins;
|
||||
using DiscImageChef.ImagePlugins;
|
||||
using DiscImageChef.PartPlugins;
|
||||
using DiscImageChef.Console;
|
||||
|
||||
namespace DiscImageChef.Commands
|
||||
{
|
||||
@@ -47,18 +48,15 @@ namespace DiscImageChef.Commands
|
||||
{
|
||||
public static void doAnalyze(AnalyzeSubOptions options)
|
||||
{
|
||||
if (MainClass.isDebug)
|
||||
{
|
||||
Console.WriteLine("--debug={0}", options.Debug);
|
||||
Console.WriteLine("--verbose={0}", options.Verbose);
|
||||
Console.WriteLine("--input={0}", options.InputFile);
|
||||
Console.WriteLine("--filesystems={0}", options.SearchForFilesystems);
|
||||
Console.WriteLine("--partitions={0}", options.SearchForPartitions);
|
||||
}
|
||||
DicConsole.DebugWriteLine("Analyze command", "--debug={0}", options.Debug);
|
||||
DicConsole.DebugWriteLine("Analyze command", "--verbose={0}", options.Verbose);
|
||||
DicConsole.DebugWriteLine("Analyze command", "--input={0}", options.InputFile);
|
||||
DicConsole.DebugWriteLine("Analyze command", "--filesystems={0}", options.SearchForFilesystems);
|
||||
DicConsole.DebugWriteLine("Analyze command", "--partitions={0}", options.SearchForPartitions);
|
||||
|
||||
if (!System.IO.File.Exists(options.InputFile))
|
||||
{
|
||||
Console.WriteLine("Specified file does not exist.");
|
||||
DicConsole.WriteLine("Specified file does not exist.");
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -77,38 +75,35 @@ namespace DiscImageChef.Commands
|
||||
|
||||
if(_imageFormat == null)
|
||||
{
|
||||
Console.WriteLine("Image format not identified, not proceeding with analysis.");
|
||||
DicConsole.WriteLine("Image format not identified, not proceeding with analysis.");
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
if(MainClass.isVerbose)
|
||||
Console.WriteLine("Image format identified by {0} ({1}).", _imageFormat.Name, _imageFormat.PluginUUID);
|
||||
if(options.Verbose)
|
||||
DicConsole.VerboseWriteLine("Image format identified by {0} ({1}).", _imageFormat.Name, _imageFormat.PluginUUID);
|
||||
else
|
||||
Console.WriteLine("Image format identified by {0}.", _imageFormat.Name);
|
||||
DicConsole.WriteLine("Image format identified by {0}.", _imageFormat.Name);
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
if (!_imageFormat.OpenImage(options.InputFile))
|
||||
{
|
||||
Console.WriteLine("Unable to open image format");
|
||||
Console.WriteLine("No error given");
|
||||
DicConsole.WriteLine("Unable to open image format");
|
||||
DicConsole.WriteLine("No error given");
|
||||
return;
|
||||
}
|
||||
|
||||
if (MainClass.isDebug)
|
||||
{
|
||||
Console.WriteLine("DEBUG: Correctly opened image file.");
|
||||
Console.WriteLine("DEBUG: Image without headers is {0} bytes.", _imageFormat.GetImageSize());
|
||||
Console.WriteLine("DEBUG: Image has {0} sectors.", _imageFormat.GetSectors());
|
||||
Console.WriteLine("DEBUG: Image identifies disk type as {0}.", _imageFormat.GetDiskType());
|
||||
}
|
||||
DicConsole.DebugWriteLine("Analyze command", "Correctly opened image file.");
|
||||
DicConsole.DebugWriteLine("Analyze command", "Image without headers is {0} bytes.", _imageFormat.GetImageSize());
|
||||
DicConsole.DebugWriteLine("Analyze command", "Image has {0} sectors.", _imageFormat.GetSectors());
|
||||
DicConsole.DebugWriteLine("Analyze command", "Image identifies disk type as {0}.", _imageFormat.GetDiskType());
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Console.WriteLine("Unable to open image format");
|
||||
Console.WriteLine("Error: {0}", ex.Message);
|
||||
System.Console.Error.WriteLine("Unable to open image format");
|
||||
DicConsole.ErrorWriteLine("Error: {0}", ex.Message);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -138,58 +133,57 @@ namespace DiscImageChef.Commands
|
||||
|
||||
if (partition_scheme == "")
|
||||
{
|
||||
if(MainClass.isDebug)
|
||||
Console.WriteLine("DEBUG: No partitions found");
|
||||
DicConsole.DebugWriteLine("Analyze command", "No partitions found");
|
||||
if (!options.SearchForFilesystems)
|
||||
{
|
||||
Console.WriteLine("No partitions founds, not searching for filesystems");
|
||||
DicConsole.WriteLine("No partitions founds, not searching for filesystems");
|
||||
return;
|
||||
}
|
||||
checkraw = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
Console.WriteLine("Partition scheme identified as {0}", partition_scheme);
|
||||
Console.WriteLine("{0} partitions found.", partitions.Count);
|
||||
DicConsole.WriteLine("Partition scheme identified as {0}", partition_scheme);
|
||||
DicConsole.WriteLine("{0} partitions found.", partitions.Count);
|
||||
|
||||
for (int i = 0; i < partitions.Count; i++)
|
||||
{
|
||||
Console.WriteLine();
|
||||
Console.WriteLine("Partition {0}:", partitions[i].PartitionSequence);
|
||||
Console.WriteLine("Partition name: {0}", partitions[i].PartitionName);
|
||||
Console.WriteLine("Partition type: {0}", partitions[i].PartitionType);
|
||||
Console.WriteLine("Partition start: sector {0}, byte {1}", partitions[i].PartitionStartSector, partitions[i].PartitionStart);
|
||||
Console.WriteLine("Partition length: {0} sectors, {1} bytes", partitions[i].PartitionSectors, partitions[i].PartitionLength);
|
||||
Console.WriteLine("Partition description:");
|
||||
Console.WriteLine(partitions[i].PartitionDescription);
|
||||
DicConsole.WriteLine();
|
||||
DicConsole.WriteLine("Partition {0}:", partitions[i].PartitionSequence);
|
||||
DicConsole.WriteLine("Partition name: {0}", partitions[i].PartitionName);
|
||||
DicConsole.WriteLine("Partition type: {0}", partitions[i].PartitionType);
|
||||
DicConsole.WriteLine("Partition start: sector {0}, byte {1}", partitions[i].PartitionStartSector, partitions[i].PartitionStart);
|
||||
DicConsole.WriteLine("Partition length: {0} sectors, {1} bytes", partitions[i].PartitionSectors, partitions[i].PartitionLength);
|
||||
DicConsole.WriteLine("Partition description:");
|
||||
DicConsole.WriteLine(partitions[i].PartitionDescription);
|
||||
|
||||
if (options.SearchForFilesystems)
|
||||
{
|
||||
Console.WriteLine("Identifying filesystem on partition");
|
||||
DicConsole.WriteLine("Identifying filesystem on partition");
|
||||
|
||||
IdentifyFilesystems(_imageFormat, out id_plugins, partitions[i].PartitionStartSector, partitions[i].PartitionStartSector+partitions[i].PartitionSectors);
|
||||
if (id_plugins.Count == 0)
|
||||
Console.WriteLine("Filesystem not identified");
|
||||
DicConsole.WriteLine("Filesystem not identified");
|
||||
else if (id_plugins.Count > 1)
|
||||
{
|
||||
Console.WriteLine(String.Format("Identified by {0} plugins", id_plugins.Count));
|
||||
DicConsole.WriteLine(String.Format("Identified by {0} plugins", id_plugins.Count));
|
||||
|
||||
foreach (string plugin_name in id_plugins)
|
||||
{
|
||||
if (plugins.PluginsList.TryGetValue(plugin_name, out _plugin))
|
||||
{
|
||||
Console.WriteLine(String.Format("As identified by {0}.", _plugin.Name));
|
||||
DicConsole.WriteLine(String.Format("As identified by {0}.", _plugin.Name));
|
||||
_plugin.GetInformation(_imageFormat, partitions[i].PartitionStartSector, partitions[i].PartitionStartSector+partitions[i].PartitionSectors, out information);
|
||||
Console.Write(information);
|
||||
DicConsole.Write(information);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
plugins.PluginsList.TryGetValue(id_plugins[0], out _plugin);
|
||||
Console.WriteLine(String.Format("Identified by {0}.", _plugin.Name));
|
||||
DicConsole.WriteLine(String.Format("Identified by {0}.", _plugin.Name));
|
||||
_plugin.GetInformation(_imageFormat, partitions[i].PartitionStartSector, partitions[i].PartitionStartSector+partitions[i].PartitionSectors, out information);
|
||||
Console.Write(information);
|
||||
DicConsole.Write(information);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -200,35 +194,34 @@ namespace DiscImageChef.Commands
|
||||
{
|
||||
IdentifyFilesystems(_imageFormat, out id_plugins, 0, _imageFormat.GetSectors()-1);
|
||||
if (id_plugins.Count == 0)
|
||||
Console.WriteLine("Filesystem not identified");
|
||||
DicConsole.WriteLine("Filesystem not identified");
|
||||
else if (id_plugins.Count > 1)
|
||||
{
|
||||
Console.WriteLine(String.Format("Identified by {0} plugins", id_plugins.Count));
|
||||
DicConsole.WriteLine(String.Format("Identified by {0} plugins", id_plugins.Count));
|
||||
|
||||
foreach (string plugin_name in id_plugins)
|
||||
{
|
||||
if (plugins.PluginsList.TryGetValue(plugin_name, out _plugin))
|
||||
{
|
||||
Console.WriteLine(String.Format("As identified by {0}.", _plugin.Name));
|
||||
DicConsole.WriteLine(String.Format("As identified by {0}.", _plugin.Name));
|
||||
_plugin.GetInformation(_imageFormat, 0, _imageFormat.GetSectors()-1, out information);
|
||||
Console.Write(information);
|
||||
DicConsole.Write(information);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
plugins.PluginsList.TryGetValue(id_plugins[0], out _plugin);
|
||||
Console.WriteLine(String.Format("Identified by {0}.", _plugin.Name));
|
||||
DicConsole.WriteLine(String.Format("Identified by {0}.", _plugin.Name));
|
||||
_plugin.GetInformation(_imageFormat, 0, _imageFormat.GetSectors()-1, out information);
|
||||
Console.Write(information);
|
||||
DicConsole.Write(information);
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Console.WriteLine(String.Format("Error reading file: {0}", ex.Message));
|
||||
if (MainClass.isDebug)
|
||||
Console.WriteLine(ex.StackTrace);
|
||||
DicConsole.ErrorWriteLine(String.Format("Error reading file: {0}", ex.Message));
|
||||
DicConsole.DebugWriteLine("Analyze command", ex.StackTrace);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -39,6 +39,7 @@ using System;
|
||||
using DiscImageChef.ImagePlugins;
|
||||
using DiscImageChef.Checksums;
|
||||
using System.Collections.Generic;
|
||||
using DiscImageChef.Console;
|
||||
|
||||
namespace DiscImageChef.Commands
|
||||
{
|
||||
@@ -46,32 +47,28 @@ namespace DiscImageChef.Commands
|
||||
{
|
||||
public static void doChecksum(ChecksumSubOptions options)
|
||||
{
|
||||
if (MainClass.isDebug)
|
||||
{
|
||||
Console.WriteLine("--debug={0}", options.Debug);
|
||||
Console.WriteLine("--verbose={0}", options.Verbose);
|
||||
Console.WriteLine("--separated-tracks={0}", options.SeparatedTracks);
|
||||
Console.WriteLine("--whole-disc={0}", options.WholeDisc);
|
||||
Console.WriteLine("--input={0}", options.InputFile);
|
||||
Console.WriteLine("--adler32={0}", options.DoAdler32);
|
||||
Console.WriteLine("--crc16={0}", options.DoCRC16);
|
||||
Console.WriteLine("--crc32={0}", options.DoCRC32);
|
||||
Console.WriteLine("--crc64={0}", options.DoCRC64);
|
||||
Console.WriteLine("--md5={0}", options.DoMD5);
|
||||
Console.WriteLine("--ripemd160={0}", options.DoRIPEMD160);
|
||||
Console.WriteLine("--sha1={0}", options.DoSHA1);
|
||||
Console.WriteLine("--sha256={0}", options.DoSHA256);
|
||||
Console.WriteLine("--sha384={0}", options.DoSHA384);
|
||||
Console.WriteLine("--sha512={0}", options.DoSHA512);
|
||||
Console.WriteLine("--spamsum={0}", options.DoSpamSum);
|
||||
}
|
||||
//throw new NotImplementedException("Checksumming not yet implemented.");
|
||||
DicConsole.DebugWriteLine("Checksum command", "--debug={0}", options.Debug);
|
||||
DicConsole.DebugWriteLine("Checksum command", "--verbose={0}", options.Verbose);
|
||||
DicConsole.DebugWriteLine("Checksum command", "--separated-tracks={0}", options.SeparatedTracks);
|
||||
DicConsole.DebugWriteLine("Checksum command", "--whole-disc={0}", options.WholeDisc);
|
||||
DicConsole.DebugWriteLine("Checksum command", "--input={0}", options.InputFile);
|
||||
DicConsole.DebugWriteLine("Checksum command", "--adler32={0}", options.DoAdler32);
|
||||
DicConsole.DebugWriteLine("Checksum command", "--crc16={0}", options.DoCRC16);
|
||||
DicConsole.DebugWriteLine("Checksum command", "--crc32={0}", options.DoCRC32);
|
||||
DicConsole.DebugWriteLine("Checksum command", "--crc64={0}", options.DoCRC64);
|
||||
DicConsole.DebugWriteLine("Checksum command", "--md5={0}", options.DoMD5);
|
||||
DicConsole.DebugWriteLine("Checksum command", "--ripemd160={0}", options.DoRIPEMD160);
|
||||
DicConsole.DebugWriteLine("Checksum command", "--sha1={0}", options.DoSHA1);
|
||||
DicConsole.DebugWriteLine("Checksum command", "--sha256={0}", options.DoSHA256);
|
||||
DicConsole.DebugWriteLine("Checksum command", "--sha384={0}", options.DoSHA384);
|
||||
DicConsole.DebugWriteLine("Checksum command", "--sha512={0}", options.DoSHA512);
|
||||
DicConsole.DebugWriteLine("Checksum command", "--spamsum={0}", options.DoSpamSum);
|
||||
|
||||
ImagePlugin inputFormat = ImageFormat.Detect(options.InputFile);
|
||||
|
||||
if (inputFormat == null)
|
||||
{
|
||||
Console.WriteLine("Unable to recognize image format, not checksumming");
|
||||
DicConsole.ErrorWriteLine("Unable to recognize image format, not checksumming");
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -126,11 +123,11 @@ namespace DiscImageChef.Commands
|
||||
ssctxTrack.Init();
|
||||
|
||||
ulong sectors = currentTrack.TrackEndSector - currentTrack.TrackStartSector + 1;
|
||||
Console.WriteLine("Track {0} has {1} sectors", currentTrack.TrackSequence, sectors);
|
||||
DicConsole.WriteLine("Track {0} has {1} sectors", currentTrack.TrackSequence, sectors);
|
||||
|
||||
for (ulong i = currentTrack.TrackStartSector; i <= currentTrack.TrackEndSector; i++)
|
||||
{
|
||||
Console.Write("\rHashing sector {0} of track {1}", i + 1, currentTrack.TrackSequence);
|
||||
DicConsole.Write("\rHashing sector {0} of track {1}", i + 1, currentTrack.TrackSequence);
|
||||
byte[] sector = inputFormat.ReadSector(i, currentTrack.TrackSequence);
|
||||
if (options.DoAdler32)
|
||||
adler32ctxTrack.Update(sector);
|
||||
@@ -160,42 +157,42 @@ namespace DiscImageChef.Commands
|
||||
ssctxTrack.Update(sector);
|
||||
}
|
||||
|
||||
Console.WriteLine();
|
||||
DicConsole.WriteLine();
|
||||
|
||||
if (options.DoAdler32)
|
||||
Console.WriteLine("Track {0}'s Adler-32: 0x{1}", currentTrack.TrackSequence, adler32ctxTrack.End());
|
||||
DicConsole.WriteLine("Track {0}'s Adler-32: 0x{1}", currentTrack.TrackSequence, adler32ctxTrack.End());
|
||||
if (options.DoCRC16)
|
||||
Console.WriteLine("Track {0}'s CRC16: 0x{1}", currentTrack.TrackSequence, crc16ctxTrack.End());
|
||||
DicConsole.WriteLine("Track {0}'s CRC16: 0x{1}", currentTrack.TrackSequence, crc16ctxTrack.End());
|
||||
if (options.DoCRC32)
|
||||
Console.WriteLine("Track {0}'s CRC32: 0x{1}", currentTrack.TrackSequence, crc32ctxTrack.End());
|
||||
DicConsole.WriteLine("Track {0}'s CRC32: 0x{1}", currentTrack.TrackSequence, crc32ctxTrack.End());
|
||||
if (options.DoCRC64)
|
||||
Console.WriteLine("Track {0}'s CRC64 (ECMA): 0x{1}", currentTrack.TrackSequence, crc64ctxTrack.End());
|
||||
DicConsole.WriteLine("Track {0}'s CRC64 (ECMA): 0x{1}", currentTrack.TrackSequence, crc64ctxTrack.End());
|
||||
if (options.DoFletcher16)
|
||||
Console.WriteLine("Track {0}'s Fletcher-16: 0x{1}", currentTrack.TrackSequence, fletcher16ctxTrack.End());
|
||||
DicConsole.WriteLine("Track {0}'s Fletcher-16: 0x{1}", currentTrack.TrackSequence, fletcher16ctxTrack.End());
|
||||
if (options.DoFletcher32)
|
||||
Console.WriteLine("Track {0}'s Fletcher-32: 0x{1}", currentTrack.TrackSequence, fletcher32ctxTrack.End());
|
||||
DicConsole.WriteLine("Track {0}'s Fletcher-32: 0x{1}", currentTrack.TrackSequence, fletcher32ctxTrack.End());
|
||||
if (options.DoMD5)
|
||||
Console.WriteLine("Track {0}'s MD5: {1}", currentTrack.TrackSequence, md5ctxTrack.End());
|
||||
DicConsole.WriteLine("Track {0}'s MD5: {1}", currentTrack.TrackSequence, md5ctxTrack.End());
|
||||
if (options.DoRIPEMD160)
|
||||
Console.WriteLine("Track {0}'s RIPEMD160: {1}", currentTrack.TrackSequence, ripemd160ctxTrack.End());
|
||||
DicConsole.WriteLine("Track {0}'s RIPEMD160: {1}", currentTrack.TrackSequence, ripemd160ctxTrack.End());
|
||||
if (options.DoSHA1)
|
||||
Console.WriteLine("Track {0}'s SHA1: {1}", currentTrack.TrackSequence, sha1ctxTrack.End());
|
||||
DicConsole.WriteLine("Track {0}'s SHA1: {1}", currentTrack.TrackSequence, sha1ctxTrack.End());
|
||||
if (options.DoSHA256)
|
||||
Console.WriteLine("Track {0}'s SHA256: {1}", currentTrack.TrackSequence, sha256ctxTrack.End());
|
||||
DicConsole.WriteLine("Track {0}'s SHA256: {1}", currentTrack.TrackSequence, sha256ctxTrack.End());
|
||||
if (options.DoSHA384)
|
||||
Console.WriteLine("Track {0}'s SHA384: {1}", currentTrack.TrackSequence, sha384ctxTrack.End());
|
||||
DicConsole.WriteLine("Track {0}'s SHA384: {1}", currentTrack.TrackSequence, sha384ctxTrack.End());
|
||||
if (options.DoSHA512)
|
||||
Console.WriteLine("Track {0}'s SHA512: {1}", currentTrack.TrackSequence, sha512ctxTrack.End());
|
||||
DicConsole.WriteLine("Track {0}'s SHA512: {1}", currentTrack.TrackSequence, sha512ctxTrack.End());
|
||||
if (options.DoSpamSum)
|
||||
Console.WriteLine("Track {0}'s SpamSum: {1}", currentTrack.TrackSequence, ssctxTrack.End());
|
||||
DicConsole.WriteLine("Track {0}'s SpamSum: {1}", currentTrack.TrackSequence, ssctxTrack.End());
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
if (options.Debug)
|
||||
Console.WriteLine("Could not get tracks because {0}", ex.Message);
|
||||
DicConsole.DebugWriteLine("Could not get tracks because {0}", ex.Message);
|
||||
else
|
||||
Console.WriteLine("Unable to get separate tracks, not checksumming them");
|
||||
DicConsole.WriteLine("Unable to get separate tracks, not checksumming them");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -244,11 +241,11 @@ namespace DiscImageChef.Commands
|
||||
ssctx.Init();
|
||||
|
||||
ulong sectors = inputFormat.GetSectors();
|
||||
Console.WriteLine("Sectors {0}", sectors);
|
||||
DicConsole.WriteLine("Sectors {0}", sectors);
|
||||
|
||||
for (ulong i = 0; i < sectors; i++)
|
||||
{
|
||||
Console.Write("\rHashing sector {0}", i + 1);
|
||||
DicConsole.Write("\rHashing sector {0}", i + 1);
|
||||
byte[] sector = inputFormat.ReadSector(i);
|
||||
if (options.DoAdler32)
|
||||
adler32ctx.Update(sector);
|
||||
@@ -278,34 +275,34 @@ namespace DiscImageChef.Commands
|
||||
ssctx.Update(sector);
|
||||
}
|
||||
|
||||
Console.WriteLine();
|
||||
DicConsole.WriteLine();
|
||||
|
||||
if (options.DoAdler32)
|
||||
Console.WriteLine("Disk's Adler-32: 0x{0}", adler32ctx.End());
|
||||
DicConsole.WriteLine("Disk's Adler-32: 0x{0}", adler32ctx.End());
|
||||
if (options.DoCRC16)
|
||||
Console.WriteLine("Disk's CRC16: 0x{0}", crc16ctx.End());
|
||||
DicConsole.WriteLine("Disk's CRC16: 0x{0}", crc16ctx.End());
|
||||
if (options.DoCRC32)
|
||||
Console.WriteLine("Disk's CRC32: 0x{0}", crc32ctx.End());
|
||||
DicConsole.WriteLine("Disk's CRC32: 0x{0}", crc32ctx.End());
|
||||
if (options.DoCRC64)
|
||||
Console.WriteLine("Disk's CRC64 (ECMA): 0x{0}", crc64ctx.End());
|
||||
DicConsole.WriteLine("Disk's CRC64 (ECMA): 0x{0}", crc64ctx.End());
|
||||
if (options.DoFletcher16)
|
||||
Console.WriteLine("Disk's Fletcher-16: 0x{0}", fletcher16ctx.End());
|
||||
DicConsole.WriteLine("Disk's Fletcher-16: 0x{0}", fletcher16ctx.End());
|
||||
if (options.DoFletcher32)
|
||||
Console.WriteLine("Disk's Fletcher-32: 0x{0}", fletcher32ctx.End());
|
||||
DicConsole.WriteLine("Disk's Fletcher-32: 0x{0}", fletcher32ctx.End());
|
||||
if (options.DoMD5)
|
||||
Console.WriteLine("Disk's MD5: {0}", md5ctx.End());
|
||||
DicConsole.WriteLine("Disk's MD5: {0}", md5ctx.End());
|
||||
if (options.DoRIPEMD160)
|
||||
Console.WriteLine("Disk's RIPEMD160: {0}", ripemd160ctx.End());
|
||||
DicConsole.WriteLine("Disk's RIPEMD160: {0}", ripemd160ctx.End());
|
||||
if (options.DoSHA1)
|
||||
Console.WriteLine("Disk's SHA1: {0}", sha1ctx.End());
|
||||
DicConsole.WriteLine("Disk's SHA1: {0}", sha1ctx.End());
|
||||
if (options.DoSHA256)
|
||||
Console.WriteLine("Disk's SHA256: {0}", sha256ctx.End());
|
||||
DicConsole.WriteLine("Disk's SHA256: {0}", sha256ctx.End());
|
||||
if (options.DoSHA384)
|
||||
Console.WriteLine("Disk's SHA384: {0}", sha384ctx.End());
|
||||
DicConsole.WriteLine("Disk's SHA384: {0}", sha384ctx.End());
|
||||
if (options.DoSHA512)
|
||||
Console.WriteLine("Disk's SHA512: {0}", sha512ctx.End());
|
||||
DicConsole.WriteLine("Disk's SHA512: {0}", sha512ctx.End());
|
||||
if (options.DoSpamSum)
|
||||
Console.WriteLine("Disk's SpamSum: {0}", ssctx.End());
|
||||
DicConsole.WriteLine("Disk's SpamSum: {0}", ssctx.End());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -39,6 +39,7 @@ using System;
|
||||
using DiscImageChef.ImagePlugins;
|
||||
using System.Text;
|
||||
using System.Collections.Generic;
|
||||
using DiscImageChef.Console;
|
||||
|
||||
namespace DiscImageChef.Commands
|
||||
{
|
||||
@@ -46,23 +47,20 @@ namespace DiscImageChef.Commands
|
||||
{
|
||||
public static void doCompare(CompareSubOptions options)
|
||||
{
|
||||
if (MainClass.isDebug)
|
||||
{
|
||||
Console.WriteLine("--debug={0}", options.Debug);
|
||||
Console.WriteLine("--verbose={0}", options.Verbose);
|
||||
Console.WriteLine("--input1={0}", options.InputFile1);
|
||||
Console.WriteLine("--input2={0}", options.InputFile2);
|
||||
}
|
||||
DicConsole.DebugWriteLine("Compare command", "--debug={0}", options.Debug);
|
||||
DicConsole.DebugWriteLine("Compare command", "--verbose={0}", options.Verbose);
|
||||
DicConsole.DebugWriteLine("Compare command", "--input1={0}", options.InputFile1);
|
||||
DicConsole.DebugWriteLine("Compare command", "--input2={0}", options.InputFile2);
|
||||
|
||||
if (!System.IO.File.Exists(options.InputFile1))
|
||||
{
|
||||
Console.WriteLine("Input file 1 does not exist.");
|
||||
System.Console.Error.WriteLine("Input file 1 does not exist.");
|
||||
return;
|
||||
}
|
||||
|
||||
if (!System.IO.File.Exists(options.InputFile2))
|
||||
{
|
||||
Console.WriteLine("Input file 2 does not exist.");
|
||||
System.Console.Error.WriteLine("Input file 2 does not exist.");
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -71,28 +69,28 @@ namespace DiscImageChef.Commands
|
||||
|
||||
if(input1Format == null)
|
||||
{
|
||||
Console.WriteLine("Input file 1 format not identified, not proceeding with comparison.");
|
||||
DicConsole.ErrorWriteLine("Input file 1 format not identified, not proceeding with comparison.");
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
if(MainClass.isVerbose)
|
||||
Console.WriteLine("Input file 1 format identified by {0} ({1}).", input1Format.Name, input1Format.PluginUUID);
|
||||
if(options.Verbose)
|
||||
DicConsole.VerboseWriteLine("Input file 1 format identified by {0} ({1}).", input1Format.Name, input1Format.PluginUUID);
|
||||
else
|
||||
Console.WriteLine("Input file 1 format identified by {0}.", input1Format.Name);
|
||||
DicConsole.WriteLine("Input file 1 format identified by {0}.", input1Format.Name);
|
||||
}
|
||||
|
||||
if(input2Format == null)
|
||||
{
|
||||
Console.WriteLine("Input file 2 format not identified, not proceeding with comparison.");
|
||||
DicConsole.ErrorWriteLine("Input file 2 format not identified, not proceeding with comparison.");
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
if(MainClass.isVerbose)
|
||||
Console.WriteLine("Input file 2 format identified by {0} ({1}).", input2Format.Name, input2Format.PluginUUID);
|
||||
if(options.Verbose)
|
||||
DicConsole.VerboseWriteLine("Input file 2 format identified by {0} ({1}).", input2Format.Name, input2Format.PluginUUID);
|
||||
else
|
||||
Console.WriteLine("Input file 2 format identified by {0}.", input2Format.Name);
|
||||
DicConsole.WriteLine("Input file 2 format identified by {0}.", input2Format.Name);
|
||||
}
|
||||
|
||||
input1Format.OpenImage(options.InputFile1);
|
||||
@@ -100,7 +98,7 @@ namespace DiscImageChef.Commands
|
||||
|
||||
StringBuilder sb = new StringBuilder();
|
||||
|
||||
if (MainClass.isVerbose)
|
||||
if (options.Verbose)
|
||||
{
|
||||
sb.AppendLine("\tDisc image 1\tDisc image 2");
|
||||
sb.AppendLine("================================");
|
||||
@@ -194,7 +192,7 @@ namespace DiscImageChef.Commands
|
||||
}
|
||||
}
|
||||
|
||||
if (MainClass.isVerbose)
|
||||
if (options.Verbose)
|
||||
{
|
||||
sb.AppendFormat("Has partitions?\t{0}\t{1}", image1Info.imageHasPartitions, image2Info.imageHasPartitions).AppendLine();
|
||||
sb.AppendFormat("Has sessions?\t{0}\t{1}", image1Info.imageHasSessions, image2Info.imageHasSessions).AppendLine();
|
||||
@@ -226,150 +224,150 @@ namespace DiscImageChef.Commands
|
||||
}
|
||||
}
|
||||
|
||||
Console.WriteLine("Comparing disk image characteristics");
|
||||
DicConsole.WriteLine("Comparing disk image characteristics");
|
||||
|
||||
if (image1Info.imageHasPartitions != image2Info.imageHasPartitions)
|
||||
{
|
||||
imagesDiffer = true;
|
||||
if (!MainClass.isVerbose)
|
||||
if (!options.Verbose)
|
||||
sb.AppendLine("Image partitioned status differ");
|
||||
}
|
||||
if (image1Info.imageHasSessions != image2Info.imageHasSessions)
|
||||
{
|
||||
imagesDiffer = true;
|
||||
if (!MainClass.isVerbose)
|
||||
if (!options.Verbose)
|
||||
sb.AppendLine("Image session status differ");
|
||||
}
|
||||
if (image1Info.imageSize != image2Info.imageSize)
|
||||
{
|
||||
imagesDiffer = true;
|
||||
if (!MainClass.isVerbose)
|
||||
if (!options.Verbose)
|
||||
sb.AppendLine("Image size differ");
|
||||
}
|
||||
if (image1Info.sectors != image2Info.sectors)
|
||||
{
|
||||
imagesDiffer = true;
|
||||
if (!MainClass.isVerbose)
|
||||
if (!options.Verbose)
|
||||
sb.AppendLine("Image sectors differ");
|
||||
}
|
||||
if (image1Info.sectorSize != image2Info.sectorSize)
|
||||
{
|
||||
imagesDiffer = true;
|
||||
if (!MainClass.isVerbose)
|
||||
if (!options.Verbose)
|
||||
sb.AppendLine("Image sector size differ");
|
||||
}
|
||||
if (image1Info.imageCreationTime != image2Info.imageCreationTime)
|
||||
{
|
||||
imagesDiffer = true;
|
||||
if (!MainClass.isVerbose)
|
||||
if (!options.Verbose)
|
||||
sb.AppendLine("Image creation time differ");
|
||||
}
|
||||
if (image1Info.imageLastModificationTime != image2Info.imageLastModificationTime)
|
||||
{
|
||||
imagesDiffer = true;
|
||||
if (!MainClass.isVerbose)
|
||||
if (!options.Verbose)
|
||||
sb.AppendLine("Image last modification time differ");
|
||||
}
|
||||
if (image1Info.diskType != image2Info.diskType)
|
||||
{
|
||||
imagesDiffer = true;
|
||||
if (!MainClass.isVerbose)
|
||||
if (!options.Verbose)
|
||||
sb.AppendLine("Disk type differ");
|
||||
}
|
||||
if (image1Info.imageVersion != image2Info.imageVersion)
|
||||
{
|
||||
imagesDiffer = true;
|
||||
if (!MainClass.isVerbose)
|
||||
if (!options.Verbose)
|
||||
sb.AppendLine("Image version differ");
|
||||
}
|
||||
if (image1Info.imageApplication != image2Info.imageApplication)
|
||||
{
|
||||
imagesDiffer = true;
|
||||
if (!MainClass.isVerbose)
|
||||
if (!options.Verbose)
|
||||
sb.AppendLine("Image application differ");
|
||||
}
|
||||
if (image1Info.imageApplicationVersion != image2Info.imageApplicationVersion)
|
||||
{
|
||||
imagesDiffer = true;
|
||||
if (!MainClass.isVerbose)
|
||||
if (!options.Verbose)
|
||||
sb.AppendLine("Image application version differ");
|
||||
}
|
||||
if (image1Info.imageCreator != image2Info.imageCreator)
|
||||
{
|
||||
imagesDiffer = true;
|
||||
if (!MainClass.isVerbose)
|
||||
if (!options.Verbose)
|
||||
sb.AppendLine("Image creator differ");
|
||||
}
|
||||
if (image1Info.imageName != image2Info.imageName)
|
||||
{
|
||||
imagesDiffer = true;
|
||||
if (!MainClass.isVerbose)
|
||||
if (!options.Verbose)
|
||||
sb.AppendLine("Image name differ");
|
||||
}
|
||||
if (image1Info.imageComments != image2Info.imageComments)
|
||||
{
|
||||
imagesDiffer = true;
|
||||
if (!MainClass.isVerbose)
|
||||
if (!options.Verbose)
|
||||
sb.AppendLine("Image comments differ");
|
||||
}
|
||||
if (image1Info.diskManufacturer != image2Info.diskManufacturer)
|
||||
{
|
||||
imagesDiffer = true;
|
||||
if (!MainClass.isVerbose)
|
||||
if (!options.Verbose)
|
||||
sb.AppendLine("Disk manufacturer differ");
|
||||
}
|
||||
if (image1Info.diskModel != image2Info.diskModel)
|
||||
{
|
||||
imagesDiffer = true;
|
||||
if (!MainClass.isVerbose)
|
||||
if (!options.Verbose)
|
||||
sb.AppendLine("Disk model differ");
|
||||
}
|
||||
if (image1Info.diskSerialNumber != image2Info.diskSerialNumber)
|
||||
{
|
||||
imagesDiffer = true;
|
||||
if (!MainClass.isVerbose)
|
||||
if (!options.Verbose)
|
||||
sb.AppendLine("Disk serial number differ");
|
||||
}
|
||||
if (image1Info.diskBarcode != image2Info.diskBarcode)
|
||||
{
|
||||
imagesDiffer = true;
|
||||
if (!MainClass.isVerbose)
|
||||
if (!options.Verbose)
|
||||
sb.AppendLine("Disk barcode differ");
|
||||
}
|
||||
if (image1Info.diskPartNumber != image2Info.diskPartNumber)
|
||||
{
|
||||
imagesDiffer = true;
|
||||
if (!MainClass.isVerbose)
|
||||
if (!options.Verbose)
|
||||
sb.AppendLine("Disk part number differ");
|
||||
}
|
||||
if (image1Info.diskSequence != image2Info.diskSequence)
|
||||
{
|
||||
imagesDiffer = true;
|
||||
if (!MainClass.isVerbose)
|
||||
if (!options.Verbose)
|
||||
sb.AppendLine("Disk sequence differ");
|
||||
}
|
||||
if (image1Info.lastDiskSequence != image2Info.lastDiskSequence)
|
||||
{
|
||||
imagesDiffer = true;
|
||||
if (!MainClass.isVerbose)
|
||||
if (!options.Verbose)
|
||||
sb.AppendLine("Last disk in sequence differ");
|
||||
}
|
||||
if (image1Info.driveManufacturer != image2Info.driveManufacturer)
|
||||
{
|
||||
imagesDiffer = true;
|
||||
if (!MainClass.isVerbose)
|
||||
if (!options.Verbose)
|
||||
sb.AppendLine("Drive manufacturer differ");
|
||||
}
|
||||
if (image1Info.driveModel != image2Info.driveModel)
|
||||
{
|
||||
imagesDiffer = true;
|
||||
if (!MainClass.isVerbose)
|
||||
if (!options.Verbose)
|
||||
sb.AppendLine("Drive model differ");
|
||||
}
|
||||
if (image1Info.driveSerialNumber != image2Info.driveSerialNumber)
|
||||
{
|
||||
imagesDiffer = true;
|
||||
if (!MainClass.isVerbose)
|
||||
if (!options.Verbose)
|
||||
sb.AppendLine("Drive serial number differ");
|
||||
}
|
||||
|
||||
@@ -378,24 +376,24 @@ namespace DiscImageChef.Commands
|
||||
{
|
||||
imagesDiffer = true;
|
||||
leastSectors = image1Info.sectors;
|
||||
if (!MainClass.isVerbose)
|
||||
if (!options.Verbose)
|
||||
sb.AppendLine("Image 2 has more sectors");
|
||||
}
|
||||
else if (image1Info.sectors > image2Info.sectors)
|
||||
{
|
||||
imagesDiffer = true;
|
||||
leastSectors = image2Info.sectors;
|
||||
if (!MainClass.isVerbose)
|
||||
if (!options.Verbose)
|
||||
sb.AppendLine("Image 1 has more sectors");
|
||||
}
|
||||
else
|
||||
leastSectors = image1Info.sectors;
|
||||
|
||||
Console.WriteLine("Comparing sectors...");
|
||||
DicConsole.WriteLine("Comparing sectors...");
|
||||
|
||||
for (UInt64 sector = 0; sector < leastSectors; sector++)
|
||||
{
|
||||
Console.Write("\rComparing sector {0} of {1}...", sector+1, leastSectors);
|
||||
DicConsole.Write("\rComparing sector {0} of {1}...", sector+1, leastSectors);
|
||||
try
|
||||
{
|
||||
byte[] image1Sector = input1Format.ReadSector(sector);
|
||||
@@ -416,14 +414,14 @@ namespace DiscImageChef.Commands
|
||||
}
|
||||
catch{}
|
||||
}
|
||||
Console.WriteLine();
|
||||
DicConsole.WriteLine();
|
||||
|
||||
if (imagesDiffer)
|
||||
sb.AppendLine("Images differ");
|
||||
else
|
||||
sb.AppendLine("Images do not differ");
|
||||
|
||||
Console.WriteLine(sb.ToString());
|
||||
DicConsole.WriteLine(sb.ToString());
|
||||
}
|
||||
|
||||
private static void CompareBytes(out bool different, out bool sameSize, byte[] compareArray1, byte[] compareArray2)
|
||||
|
||||
@@ -37,6 +37,7 @@ Copyright (C) 2011-2014 Claunia.com
|
||||
//$Id$
|
||||
using System;
|
||||
using DiscImageChef.ImagePlugins;
|
||||
using DiscImageChef.Console;
|
||||
|
||||
namespace DiscImageChef.Commands
|
||||
{
|
||||
@@ -44,22 +45,19 @@ namespace DiscImageChef.Commands
|
||||
{
|
||||
public static void doDecode(DecodeSubOptions options)
|
||||
{
|
||||
if (MainClass.isDebug)
|
||||
{
|
||||
Console.WriteLine("--debug={0}", options.Debug);
|
||||
Console.WriteLine("--verbose={0}", options.Verbose);
|
||||
Console.WriteLine("--input={0}", options.InputFile);
|
||||
Console.WriteLine("--start={0}", options.StartSector);
|
||||
Console.WriteLine("--length={0}", options.Length);
|
||||
Console.WriteLine("--disk-tags={0}", options.DiskTags);
|
||||
Console.WriteLine("--sector-tags={0}", options.SectorTags);
|
||||
}
|
||||
DicConsole.DebugWriteLine("Decode command", "--debug={0}", options.Debug);
|
||||
DicConsole.DebugWriteLine("Decode command", "--verbose={0}", options.Verbose);
|
||||
DicConsole.DebugWriteLine("Decode command", "--input={0}", options.InputFile);
|
||||
DicConsole.DebugWriteLine("Decode command", "--start={0}", options.StartSector);
|
||||
DicConsole.DebugWriteLine("Decode command", "--length={0}", options.Length);
|
||||
DicConsole.DebugWriteLine("Decode command", "--disk-tags={0}", options.DiskTags);
|
||||
DicConsole.DebugWriteLine("Decode command", "--sector-tags={0}", options.SectorTags);
|
||||
|
||||
ImagePlugin inputFormat = ImageFormat.Detect(options.InputFile);
|
||||
|
||||
if (inputFormat == null)
|
||||
{
|
||||
Console.WriteLine("Unable to recognize image format, not verifying");
|
||||
DicConsole.ErrorWriteLine("Unable to recognize image format, not decoding");
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -68,7 +66,7 @@ namespace DiscImageChef.Commands
|
||||
if (options.DiskTags)
|
||||
{
|
||||
if (inputFormat.ImageInfo.readableDiskTags.Count == 0)
|
||||
Console.WriteLine("There are no disk tags in chosen disc image.");
|
||||
DicConsole.WriteLine("There are no disk tags in chosen disc image.");
|
||||
else
|
||||
{
|
||||
foreach (DiskTagType tag in inputFormat.ImageInfo.readableDiskTags)
|
||||
@@ -79,13 +77,13 @@ namespace DiscImageChef.Commands
|
||||
{
|
||||
byte[] inquiry = inputFormat.ReadDiskTag(DiskTagType.SCSI_INQUIRY);
|
||||
if (inquiry == null)
|
||||
Console.WriteLine("Error reading SCSI INQUIRY response from disc image");
|
||||
DicConsole.WriteLine("Error reading SCSI INQUIRY response from disc image");
|
||||
else
|
||||
{
|
||||
Console.WriteLine("SCSI INQUIRY command response:");
|
||||
Console.WriteLine("================================================================================");
|
||||
Console.WriteLine(Decoders.SCSI.PrettifySCSIInquiry(inquiry));
|
||||
Console.WriteLine("================================================================================");
|
||||
DicConsole.WriteLine("SCSI INQUIRY command response:");
|
||||
DicConsole.WriteLine("================================================================================");
|
||||
DicConsole.WriteLine(Decoders.SCSI.PrettifySCSIInquiry(inquiry));
|
||||
DicConsole.WriteLine("================================================================================");
|
||||
}
|
||||
break;
|
||||
}
|
||||
@@ -93,13 +91,13 @@ namespace DiscImageChef.Commands
|
||||
{
|
||||
byte[] atip = inputFormat.ReadDiskTag(DiskTagType.CD_ATIP);
|
||||
if (atip == null)
|
||||
Console.WriteLine("Error reading CD ATIP from disc image");
|
||||
DicConsole.WriteLine("Error reading CD ATIP from disc image");
|
||||
else
|
||||
{
|
||||
Console.WriteLine("CD ATIP:");
|
||||
Console.WriteLine("================================================================================");
|
||||
Console.WriteLine(Decoders.CD.PrettifyCDATIP(atip));
|
||||
Console.WriteLine("================================================================================");
|
||||
DicConsole.WriteLine("CD ATIP:");
|
||||
DicConsole.WriteLine("================================================================================");
|
||||
DicConsole.WriteLine(Decoders.CD.PrettifyCDATIP(atip));
|
||||
DicConsole.WriteLine("================================================================================");
|
||||
}
|
||||
break;
|
||||
}
|
||||
@@ -107,13 +105,13 @@ namespace DiscImageChef.Commands
|
||||
{
|
||||
byte[] fulltoc = inputFormat.ReadDiskTag(DiskTagType.CD_FullTOC);
|
||||
if (fulltoc == null)
|
||||
Console.WriteLine("Error reading CD full TOC from disc image");
|
||||
DicConsole.WriteLine("Error reading CD full TOC from disc image");
|
||||
else
|
||||
{
|
||||
Console.WriteLine("CD full TOC:");
|
||||
Console.WriteLine("================================================================================");
|
||||
Console.WriteLine(Decoders.CD.PrettifyCDFullTOC(fulltoc));
|
||||
Console.WriteLine("================================================================================");
|
||||
DicConsole.WriteLine("CD full TOC:");
|
||||
DicConsole.WriteLine("================================================================================");
|
||||
DicConsole.WriteLine(Decoders.CD.PrettifyCDFullTOC(fulltoc));
|
||||
DicConsole.WriteLine("================================================================================");
|
||||
}
|
||||
break;
|
||||
}
|
||||
@@ -121,13 +119,13 @@ namespace DiscImageChef.Commands
|
||||
{
|
||||
byte[] pma = inputFormat.ReadDiskTag(DiskTagType.CD_PMA);
|
||||
if (pma == null)
|
||||
Console.WriteLine("Error reading CD PMA from disc image");
|
||||
DicConsole.WriteLine("Error reading CD PMA from disc image");
|
||||
else
|
||||
{
|
||||
Console.WriteLine("CD PMA:");
|
||||
Console.WriteLine("================================================================================");
|
||||
Console.WriteLine(Decoders.CD.PrettifyCDPMA(pma));
|
||||
Console.WriteLine("================================================================================");
|
||||
DicConsole.WriteLine("CD PMA:");
|
||||
DicConsole.WriteLine("================================================================================");
|
||||
DicConsole.WriteLine(Decoders.CD.PrettifyCDPMA(pma));
|
||||
DicConsole.WriteLine("================================================================================");
|
||||
}
|
||||
break;
|
||||
}
|
||||
@@ -135,13 +133,13 @@ namespace DiscImageChef.Commands
|
||||
{
|
||||
byte[] sessioninfo = inputFormat.ReadDiskTag(DiskTagType.CD_SessionInfo);
|
||||
if (sessioninfo == null)
|
||||
Console.WriteLine("Error reading CD session information from disc image");
|
||||
DicConsole.WriteLine("Error reading CD session information from disc image");
|
||||
else
|
||||
{
|
||||
Console.WriteLine("CD session information:");
|
||||
Console.WriteLine("================================================================================");
|
||||
Console.WriteLine(Decoders.CD.PrettifyCDSessionInfo(sessioninfo));
|
||||
Console.WriteLine("================================================================================");
|
||||
DicConsole.WriteLine("CD session information:");
|
||||
DicConsole.WriteLine("================================================================================");
|
||||
DicConsole.WriteLine(Decoders.CD.PrettifyCDSessionInfo(sessioninfo));
|
||||
DicConsole.WriteLine("================================================================================");
|
||||
}
|
||||
break;
|
||||
}
|
||||
@@ -149,13 +147,13 @@ namespace DiscImageChef.Commands
|
||||
{
|
||||
byte[] cdtext = inputFormat.ReadDiskTag(DiskTagType.CD_TEXT);
|
||||
if (cdtext == null)
|
||||
Console.WriteLine("Error reading CD-TEXT from disc image");
|
||||
DicConsole.WriteLine("Error reading CD-TEXT from disc image");
|
||||
else
|
||||
{
|
||||
Console.WriteLine("CD-TEXT:");
|
||||
Console.WriteLine("================================================================================");
|
||||
Console.WriteLine(Decoders.CD.PrettifyCDTextLeadIn(cdtext));
|
||||
Console.WriteLine("================================================================================");
|
||||
DicConsole.WriteLine("CD-TEXT:");
|
||||
DicConsole.WriteLine("================================================================================");
|
||||
DicConsole.WriteLine(Decoders.CD.PrettifyCDTextLeadIn(cdtext));
|
||||
DicConsole.WriteLine("================================================================================");
|
||||
}
|
||||
break;
|
||||
}
|
||||
@@ -163,18 +161,18 @@ namespace DiscImageChef.Commands
|
||||
{
|
||||
byte[] toc = inputFormat.ReadDiskTag(DiskTagType.CD_TOC);
|
||||
if (toc == null)
|
||||
Console.WriteLine("Error reading CD TOC from disc image");
|
||||
DicConsole.WriteLine("Error reading CD TOC from disc image");
|
||||
else
|
||||
{
|
||||
Console.WriteLine("CD TOC:");
|
||||
Console.WriteLine("================================================================================");
|
||||
Console.WriteLine(Decoders.CD.PrettifyCDTOC(toc));
|
||||
Console.WriteLine("================================================================================");
|
||||
DicConsole.WriteLine("CD TOC:");
|
||||
DicConsole.WriteLine("================================================================================");
|
||||
DicConsole.WriteLine(Decoders.CD.PrettifyCDTOC(toc));
|
||||
DicConsole.WriteLine("================================================================================");
|
||||
}
|
||||
break;
|
||||
}
|
||||
default:
|
||||
Console.WriteLine("Decoder for disk tag type \"{0}\" not yet implemented, sorry.", tag);
|
||||
DicConsole.WriteLine("Decoder for disk tag type \"{0}\" not yet implemented, sorry.", tag);
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -191,14 +189,14 @@ namespace DiscImageChef.Commands
|
||||
{
|
||||
if (!UInt64.TryParse(options.Length, out length))
|
||||
{
|
||||
Console.WriteLine("Value \"{0}\" is not a valid number for length.", options.Length);
|
||||
Console.WriteLine("Not decoding sectors tags");
|
||||
DicConsole.WriteLine("Value \"{0}\" is not a valid number for length.", options.Length);
|
||||
DicConsole.WriteLine("Not decoding sectors tags");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (inputFormat.ImageInfo.readableSectorTags.Count == 0)
|
||||
Console.WriteLine("There are no sector tags in chosen disc image.");
|
||||
DicConsole.WriteLine("There are no sector tags in chosen disc image.");
|
||||
else
|
||||
{
|
||||
foreach (SectorTagType tag in inputFormat.ImageInfo.readableSectorTags)
|
||||
@@ -206,7 +204,7 @@ namespace DiscImageChef.Commands
|
||||
switch (tag)
|
||||
{
|
||||
default:
|
||||
Console.WriteLine("Decoder for disk tag type \"{0}\" not yet implemented, sorry.", tag);
|
||||
DicConsole.WriteLine("Decoder for disk tag type \"{0}\" not yet implemented, sorry.", tag);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -38,6 +38,7 @@
|
||||
using System;
|
||||
using DiscImageChef.Devices;
|
||||
using System.IO;
|
||||
using DiscImageChef.Console;
|
||||
|
||||
namespace DiscImageChef.Commands
|
||||
{
|
||||
@@ -45,12 +46,9 @@ namespace DiscImageChef.Commands
|
||||
{
|
||||
public static void doDeviceInfo(DeviceInfoSubOptions options)
|
||||
{
|
||||
if (MainClass.isDebug)
|
||||
{
|
||||
Console.WriteLine("--debug={0}", options.Debug);
|
||||
Console.WriteLine("--verbose={0}", options.Verbose);
|
||||
Console.WriteLine("--device={0}", options.DevicePath);
|
||||
}
|
||||
DicConsole.DebugWriteLine("Device-Info command", "--debug={0}", options.Debug);
|
||||
DicConsole.DebugWriteLine("Device-Info command", "--verbose={0}", options.Verbose);
|
||||
DicConsole.DebugWriteLine("Device-Info command", "--device={0}", options.DevicePath);
|
||||
|
||||
if (options.DevicePath.Length == 2 && options.DevicePath[1] == ':' &&
|
||||
options.DevicePath[0] != '/' && Char.IsLetter(options.DevicePath[0]))
|
||||
@@ -62,7 +60,7 @@ namespace DiscImageChef.Commands
|
||||
|
||||
if (dev.Error)
|
||||
{
|
||||
Console.WriteLine("Error {0} opening device.", dev.LastError);
|
||||
DicConsole.ErrorWriteLine("Error {0} opening device.", dev.LastError);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -73,7 +71,7 @@ namespace DiscImageChef.Commands
|
||||
|
||||
if(sense)
|
||||
{
|
||||
Console.WriteLine("SCSI error. Sense decoding not yet implemented.");
|
||||
DicConsole.ErrorWriteLine("SCSI error. Sense decoding not yet implemented.");
|
||||
|
||||
#if DEBUG
|
||||
FileStream senseFs = File.Open("sense.bin", FileMode.OpenOrCreate);
|
||||
@@ -81,9 +79,9 @@ namespace DiscImageChef.Commands
|
||||
#endif
|
||||
}
|
||||
else
|
||||
Console.WriteLine("SCSI OK");
|
||||
DicConsole.WriteLine("SCSI OK");
|
||||
|
||||
Console.WriteLine("{0}", Decoders.SCSI.PrettifySCSIInquiry(inqBuf));
|
||||
DicConsole.WriteLine("{0}", Decoders.SCSI.PrettifySCSIInquiry(inqBuf));
|
||||
|
||||
Structs.AtaErrorRegistersCHS errorRegisters;
|
||||
|
||||
@@ -98,52 +96,48 @@ namespace DiscImageChef.Commands
|
||||
&& errorRegisters.cylinderHigh == 0xEB
|
||||
&& errorRegisters.cylinderLow == 0x14)
|
||||
{
|
||||
Console.WriteLine("ATA error, but ATAPI signature detected.");
|
||||
DicConsole.WriteLine("ATA error, but ATAPI signature detected.");
|
||||
sense = dev.AtapiIdentify(out ataBuf, out errorRegisters);
|
||||
|
||||
if (sense)
|
||||
{
|
||||
Console.WriteLine("ATAPI error");
|
||||
DicConsole.WriteLine("ATAPI error");
|
||||
|
||||
#if DEBUG
|
||||
Console.WriteLine("STATUS = 0x{0:X2}", errorRegisters.status);
|
||||
Console.WriteLine("ERROR = 0x{0:X2}", errorRegisters.error);
|
||||
Console.WriteLine("NSECTOR = 0x{0:X2}", errorRegisters.sectorCount);
|
||||
Console.WriteLine("SECTOR = 0x{0:X2}", errorRegisters.sector);
|
||||
Console.WriteLine("CYLHIGH = 0x{0:X2}", errorRegisters.cylinderHigh);
|
||||
Console.WriteLine("CYLLOW = 0x{0:X2}", errorRegisters.cylinderLow);
|
||||
Console.WriteLine("DEVICE = 0x{0:X2}", errorRegisters.deviceHead);
|
||||
Console.WriteLine("COMMAND = 0x{0:X2}", errorRegisters.command);
|
||||
Console.WriteLine("Error code = {0}", dev.LastError);
|
||||
#endif
|
||||
DicConsole.DebugWriteLine("Device-Info command", "STATUS = 0x{0:X2}", errorRegisters.status);
|
||||
DicConsole.DebugWriteLine("Device-Info command", "ERROR = 0x{0:X2}", errorRegisters.error);
|
||||
DicConsole.DebugWriteLine("Device-Info command", "NSECTOR = 0x{0:X2}", errorRegisters.sectorCount);
|
||||
DicConsole.DebugWriteLine("Device-Info command", "SECTOR = 0x{0:X2}", errorRegisters.sector);
|
||||
DicConsole.DebugWriteLine("Device-Info command", "CYLHIGH = 0x{0:X2}", errorRegisters.cylinderHigh);
|
||||
DicConsole.DebugWriteLine("Device-Info command", "CYLLOW = 0x{0:X2}", errorRegisters.cylinderLow);
|
||||
DicConsole.DebugWriteLine("Device-Info command", "DEVICE = 0x{0:X2}", errorRegisters.deviceHead);
|
||||
DicConsole.DebugWriteLine("Device-Info command", "COMMAND = 0x{0:X2}", errorRegisters.command);
|
||||
DicConsole.DebugWriteLine("Device-Info command", "Error code = {0}", dev.LastError);
|
||||
}
|
||||
else
|
||||
{
|
||||
Console.WriteLine("ATAPI OK");
|
||||
Console.WriteLine("{0}", Decoders.ATA.PrettifyIdentifyDevice(ataBuf));
|
||||
DicConsole.WriteLine("ATAPI OK");
|
||||
DicConsole.WriteLine("{0}", Decoders.ATA.PrettifyIdentifyDevice(ataBuf));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
Console.WriteLine("ATA error");
|
||||
DicConsole.WriteLine("ATA error");
|
||||
|
||||
#if DEBUG
|
||||
Console.WriteLine("STATUS = 0x{0:X2}", errorRegisters.status);
|
||||
Console.WriteLine("ERROR = 0x{0:X2}", errorRegisters.error);
|
||||
Console.WriteLine("NSECTOR = 0x{0:X2}", errorRegisters.sectorCount);
|
||||
Console.WriteLine("SECTOR = 0x{0:X2}", errorRegisters.sector);
|
||||
Console.WriteLine("CYLHIGH = 0x{0:X2}", errorRegisters.cylinderHigh);
|
||||
Console.WriteLine("CYLLOW = 0x{0:X2}", errorRegisters.cylinderLow);
|
||||
Console.WriteLine("DEVICE = 0x{0:X2}", errorRegisters.deviceHead);
|
||||
Console.WriteLine("COMMAND = 0x{0:X2}", errorRegisters.command);
|
||||
Console.WriteLine("Error code = {0}", dev.LastError);
|
||||
#endif
|
||||
DicConsole.DebugWriteLine("Device-Info command", "STATUS = 0x{0:X2}", errorRegisters.status);
|
||||
DicConsole.DebugWriteLine("Device-Info command", "ERROR = 0x{0:X2}", errorRegisters.error);
|
||||
DicConsole.DebugWriteLine("Device-Info command", "NSECTOR = 0x{0:X2}", errorRegisters.sectorCount);
|
||||
DicConsole.DebugWriteLine("Device-Info command", "SECTOR = 0x{0:X2}", errorRegisters.sector);
|
||||
DicConsole.DebugWriteLine("Device-Info command", "CYLHIGH = 0x{0:X2}", errorRegisters.cylinderHigh);
|
||||
DicConsole.DebugWriteLine("Device-Info command", "CYLLOW = 0x{0:X2}", errorRegisters.cylinderLow);
|
||||
DicConsole.DebugWriteLine("Device-Info command", "DEVICE = 0x{0:X2}", errorRegisters.deviceHead);
|
||||
DicConsole.DebugWriteLine("Device-Info command", "COMMAND = 0x{0:X2}", errorRegisters.command);
|
||||
DicConsole.DebugWriteLine("Device-Info command", "Error code = {0}", dev.LastError);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
Console.WriteLine("ATA OK");
|
||||
Console.WriteLine("{0}", Decoders.ATA.PrettifyIdentifyDevice(ataBuf));
|
||||
DicConsole.WriteLine("ATA OK");
|
||||
DicConsole.WriteLine("{0}", Decoders.ATA.PrettifyIdentifyDevice(ataBuf));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -39,6 +39,7 @@ using System;
|
||||
using DiscImageChef.ImagePlugins;
|
||||
using DiscImageChef.Checksums;
|
||||
using System.Collections.Generic;
|
||||
using DiscImageChef.Console;
|
||||
|
||||
namespace DiscImageChef.Commands
|
||||
{
|
||||
@@ -46,21 +47,18 @@ namespace DiscImageChef.Commands
|
||||
{
|
||||
public static void doEntropy(EntropySubOptions options)
|
||||
{
|
||||
if (MainClass.isDebug)
|
||||
{
|
||||
Console.WriteLine("--debug={0}", options.Debug);
|
||||
Console.WriteLine("--verbose={0}", options.Verbose);
|
||||
Console.WriteLine("--separated-tracks={0}", options.SeparatedTracks);
|
||||
Console.WriteLine("--whole-disc={0}", options.WholeDisc);
|
||||
Console.WriteLine("--input={0}", options.InputFile);
|
||||
Console.WriteLine("--duplicated-sectors={0}", options.DuplicatedSectors);
|
||||
}
|
||||
DicConsole.DebugWriteLine("Entropy command", "--debug={0}", options.Debug);
|
||||
DicConsole.DebugWriteLine("Entropy command", "--verbose={0}", options.Verbose);
|
||||
DicConsole.DebugWriteLine("Entropy command", "--separated-tracks={0}", options.SeparatedTracks);
|
||||
DicConsole.DebugWriteLine("Entropy command", "--whole-disc={0}", options.WholeDisc);
|
||||
DicConsole.DebugWriteLine("Entropy command", "--input={0}", options.InputFile);
|
||||
DicConsole.DebugWriteLine("Entropy command", "--duplicated-sectors={0}", options.DuplicatedSectors);
|
||||
|
||||
ImagePlugin inputFormat = ImageFormat.Detect(options.InputFile);
|
||||
|
||||
if (inputFormat == null)
|
||||
{
|
||||
Console.WriteLine("Unable to recognize image format, not checksumming");
|
||||
DicConsole.ErrorWriteLine("Unable to recognize image format, not checksumming");
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -80,11 +78,11 @@ namespace DiscImageChef.Commands
|
||||
List<string> uniqueSectorsPerTrack = new List<string>();
|
||||
|
||||
ulong sectors = currentTrack.TrackEndSector - currentTrack.TrackStartSector + 1;
|
||||
Console.WriteLine("Track {0} has {1} sectors", currentTrack.TrackSequence, sectors);
|
||||
DicConsole.WriteLine("Track {0} has {1} sectors", currentTrack.TrackSequence, sectors);
|
||||
|
||||
for (ulong i = currentTrack.TrackStartSector; i <= currentTrack.TrackEndSector; i++)
|
||||
{
|
||||
Console.Write("\rEntropying sector {0} of track {1}", i + 1, currentTrack.TrackSequence);
|
||||
DicConsole.Write("\rEntropying sector {0} of track {1}", i + 1, currentTrack.TrackSequence);
|
||||
byte[] sector = inputFormat.ReadSector(i, currentTrack.TrackSequence);
|
||||
|
||||
if(options.DuplicatedSectors)
|
||||
@@ -108,20 +106,20 @@ namespace DiscImageChef.Commands
|
||||
entropy += -(frequency * Math.Log(frequency, 2));
|
||||
}
|
||||
|
||||
Console.WriteLine("Entropy for track {0} is {1:F4}.", currentTrack.TrackSequence, entropy);
|
||||
DicConsole.WriteLine("Entropy for track {0} is {1:F4}.", currentTrack.TrackSequence, entropy);
|
||||
|
||||
if(options.DuplicatedSectors)
|
||||
Console.WriteLine("Track {0} has {1} unique sectors ({1:P3})", currentTrack.TrackSequence, uniqueSectorsPerTrack.Count, (double)uniqueSectorsPerTrack.Count/(double)sectors);
|
||||
DicConsole.WriteLine("Track {0} has {1} unique sectors ({1:P3})", currentTrack.TrackSequence, uniqueSectorsPerTrack.Count, (double)uniqueSectorsPerTrack.Count/(double)sectors);
|
||||
|
||||
Console.WriteLine();
|
||||
DicConsole.WriteLine();
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
if (options.Debug)
|
||||
Console.WriteLine("Could not get tracks because {0}", ex.Message);
|
||||
DicConsole.DebugWriteLine("Could not get tracks because {0}", ex.Message);
|
||||
else
|
||||
Console.WriteLine("Unable to get separate tracks, not calculating their entropy");
|
||||
DicConsole.ErrorWriteLine("Unable to get separate tracks, not calculating their entropy");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -134,13 +132,13 @@ namespace DiscImageChef.Commands
|
||||
List<string> uniqueSectors = new List<string>();
|
||||
|
||||
ulong sectors = inputFormat.GetSectors();
|
||||
Console.WriteLine("Sectors {0}", sectors);
|
||||
DicConsole.WriteLine("Sectors {0}", sectors);
|
||||
|
||||
sha1Ctx.Init();
|
||||
|
||||
for (ulong i = 0; i < sectors; i++)
|
||||
{
|
||||
Console.Write("\rEntropying sector {0}", i + 1);
|
||||
DicConsole.Write("\rEntropying sector {0}", i + 1);
|
||||
byte[] sector = inputFormat.ReadSector(i);
|
||||
|
||||
if(options.DuplicatedSectors)
|
||||
@@ -165,12 +163,12 @@ namespace DiscImageChef.Commands
|
||||
entropy += -(frequency * Math.Log(frequency, 2));
|
||||
}
|
||||
|
||||
Console.WriteLine();
|
||||
DicConsole.WriteLine();
|
||||
|
||||
Console.WriteLine("Entropy for disk is {0:F4}.", entropy);
|
||||
DicConsole.WriteLine("Entropy for disk is {0:F4}.", entropy);
|
||||
|
||||
if(options.DuplicatedSectors)
|
||||
Console.WriteLine("Disk has {0} unique sectors ({1:P3})", uniqueSectors.Count, (double)uniqueSectors.Count/(double)sectors);
|
||||
DicConsole.WriteLine("Disk has {0} unique sectors ({1:P3})", uniqueSectors.Count, (double)uniqueSectors.Count/(double)sectors);
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -40,47 +40,48 @@ using System.Collections.Generic;
|
||||
using DiscImageChef.ImagePlugins;
|
||||
using DiscImageChef.PartPlugins;
|
||||
using DiscImageChef.Plugins;
|
||||
using DiscImageChef.Console;
|
||||
|
||||
namespace DiscImageChef.Commands
|
||||
{
|
||||
public static class Formats
|
||||
{
|
||||
public static void ListFormats()
|
||||
public static void ListFormats(FormatsSubOptions FormatsOptions)
|
||||
{
|
||||
PluginBase plugins = new PluginBase();
|
||||
plugins.RegisterAllPlugins();
|
||||
|
||||
Console.WriteLine("Supported disc image formats:");
|
||||
if(MainClass.isVerbose)
|
||||
Console.WriteLine("GUID\t\t\t\t\tPlugin");
|
||||
DicConsole.WriteLine("Supported disc image formats:");
|
||||
if(FormatsOptions.Verbose)
|
||||
DicConsole.VerboseWriteLine("GUID\t\t\t\t\tPlugin");
|
||||
foreach (KeyValuePair<string, ImagePlugin> kvp in plugins.ImagePluginsList)
|
||||
{
|
||||
if(MainClass.isVerbose)
|
||||
Console.WriteLine("{0}\t{1}", kvp.Value.PluginUUID, kvp.Value.Name);
|
||||
if(FormatsOptions.Verbose)
|
||||
DicConsole.VerboseWriteLine("{0}\t{1}", kvp.Value.PluginUUID, kvp.Value.Name);
|
||||
else
|
||||
Console.WriteLine(kvp.Value.Name);
|
||||
DicConsole.WriteLine(kvp.Value.Name);
|
||||
}
|
||||
Console.WriteLine();
|
||||
Console.WriteLine("Supported filesystems:");
|
||||
if(MainClass.isVerbose)
|
||||
Console.WriteLine("GUID\t\t\t\t\tPlugin");
|
||||
DicConsole.WriteLine();
|
||||
DicConsole.WriteLine("Supported filesystems:");
|
||||
if(FormatsOptions.Verbose)
|
||||
DicConsole.VerboseWriteLine("GUID\t\t\t\t\tPlugin");
|
||||
foreach (KeyValuePair<string, Plugin> kvp in plugins.PluginsList)
|
||||
{
|
||||
if(MainClass.isVerbose)
|
||||
Console.WriteLine("{0}\t{1}", kvp.Value.PluginUUID, kvp.Value.Name);
|
||||
if(FormatsOptions.Verbose)
|
||||
DicConsole.VerboseWriteLine("{0}\t{1}", kvp.Value.PluginUUID, kvp.Value.Name);
|
||||
else
|
||||
Console.WriteLine(kvp.Value.Name);
|
||||
DicConsole.WriteLine(kvp.Value.Name);
|
||||
}
|
||||
Console.WriteLine();
|
||||
Console.WriteLine("Supported partitioning schemes:");
|
||||
if(MainClass.isVerbose)
|
||||
Console.WriteLine("GUID\t\t\t\t\tPlugin");
|
||||
DicConsole.WriteLine();
|
||||
DicConsole.WriteLine("Supported partitioning schemes:");
|
||||
if(FormatsOptions.Verbose)
|
||||
DicConsole.VerboseWriteLine("GUID\t\t\t\t\tPlugin");
|
||||
foreach (KeyValuePair<string, PartPlugin> kvp in plugins.PartPluginsList)
|
||||
{
|
||||
if(MainClass.isVerbose)
|
||||
Console.WriteLine("{0}\t{1}", kvp.Value.PluginUUID, kvp.Value.Name);
|
||||
if(FormatsOptions.Verbose)
|
||||
DicConsole.VerboseWriteLine("{0}\t{1}", kvp.Value.PluginUUID, kvp.Value.Name);
|
||||
else
|
||||
Console.WriteLine(kvp.Value.Name);
|
||||
DicConsole.WriteLine(kvp.Value.Name);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -37,6 +37,7 @@ Copyright (C) 2011-2014 Claunia.com
|
||||
//$Id$
|
||||
using System;
|
||||
using DiscImageChef.ImagePlugins;
|
||||
using DiscImageChef.Console;
|
||||
|
||||
namespace DiscImageChef.Commands
|
||||
{
|
||||
@@ -44,22 +45,19 @@ namespace DiscImageChef.Commands
|
||||
{
|
||||
public static void doPrintHex(PrintHexSubOptions options)
|
||||
{
|
||||
if (MainClass.isDebug)
|
||||
{
|
||||
Console.WriteLine("--debug={0}", options.Debug);
|
||||
Console.WriteLine("--verbose={0}", options.Verbose);
|
||||
Console.WriteLine("--input={0}", options.InputFile);
|
||||
Console.WriteLine("--start={0}", options.StartSector);
|
||||
Console.WriteLine("--length={0}", options.Length);
|
||||
Console.WriteLine("--long-sectors={0}", options.LongSectors);
|
||||
Console.WriteLine("--WidthBytes={0}", options.WidthBytes);
|
||||
}
|
||||
DicConsole.DebugWriteLine("PrintHex command", "--debug={0}", options.Debug);
|
||||
DicConsole.DebugWriteLine("PrintHex command", "--verbose={0}", options.Verbose);
|
||||
DicConsole.DebugWriteLine("PrintHex command", "--input={0}", options.InputFile);
|
||||
DicConsole.DebugWriteLine("PrintHex command", "--start={0}", options.StartSector);
|
||||
DicConsole.DebugWriteLine("PrintHex command", "--length={0}", options.Length);
|
||||
DicConsole.DebugWriteLine("PrintHex command", "--long-sectors={0}", options.LongSectors);
|
||||
DicConsole.DebugWriteLine("PrintHex command", "--WidthBytes={0}", options.WidthBytes);
|
||||
|
||||
ImagePlugin inputFormat = ImageFormat.Detect(options.InputFile);
|
||||
|
||||
if (inputFormat == null)
|
||||
{
|
||||
Console.WriteLine("Unable to recognize image format, not verifying");
|
||||
DicConsole.ErrorWriteLine("Unable to recognize image format, not verifying");
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -67,19 +65,19 @@ namespace DiscImageChef.Commands
|
||||
|
||||
for(ulong i = 0; i < options.Length; i++)
|
||||
{
|
||||
Console.WriteLine("Sector {0}", options.StartSector + i);
|
||||
DicConsole.WriteLine("Sector {0}", options.StartSector + i);
|
||||
byte[] sector;
|
||||
|
||||
if (inputFormat.ImageInfo.readableSectorTags == null)
|
||||
{
|
||||
Console.WriteLine("Requested sectors with tags, unsupported by underlying image format, printing only user data.");
|
||||
DicConsole.WriteLine("Requested sectors with tags, unsupported by underlying image format, printing only user data.");
|
||||
options.LongSectors = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (inputFormat.ImageInfo.readableSectorTags.Count == 0)
|
||||
{
|
||||
Console.WriteLine("Requested sectors with tags, unsupported by underlying image format, printing only user data.");
|
||||
DicConsole.WriteLine("Requested sectors with tags, unsupported by underlying image format, printing only user data.");
|
||||
options.LongSectors = false;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -38,6 +38,7 @@ Copyright (C) 2011-2014 Claunia.com
|
||||
using System;
|
||||
using DiscImageChef.ImagePlugins;
|
||||
using System.Collections.Generic;
|
||||
using DiscImageChef.Console;
|
||||
|
||||
namespace DiscImageChef.Commands
|
||||
{
|
||||
@@ -45,20 +46,17 @@ namespace DiscImageChef.Commands
|
||||
{
|
||||
public static void doVerify(VerifySubOptions options)
|
||||
{
|
||||
if (MainClass.isDebug)
|
||||
{
|
||||
Console.WriteLine("--debug={0}", options.Debug);
|
||||
Console.WriteLine("--verbose={0}", options.Verbose);
|
||||
Console.WriteLine("--input={0}", options.InputFile);
|
||||
Console.WriteLine("--verify-disc={0}", options.VerifyDisc);
|
||||
Console.WriteLine("--verify-sectors={0}", options.VerifySectors);
|
||||
}
|
||||
DicConsole.DebugWriteLine("Verify command", "--debug={0}", options.Debug);
|
||||
DicConsole.DebugWriteLine("Verify command", "--verbose={0}", options.Verbose);
|
||||
DicConsole.DebugWriteLine("Verify command", "--input={0}", options.InputFile);
|
||||
DicConsole.DebugWriteLine("Verify command", "--verify-disc={0}", options.VerifyDisc);
|
||||
DicConsole.DebugWriteLine("Verify command", "--verify-sectors={0}", options.VerifySectors);
|
||||
|
||||
ImagePlugin inputFormat = ImageFormat.Detect(options.InputFile);
|
||||
|
||||
if (inputFormat == null)
|
||||
{
|
||||
Console.WriteLine("Unable to recognize image format, not verifying");
|
||||
DicConsole.ErrorWriteLine("Unable to recognize image format, not verifying");
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -75,18 +73,17 @@ namespace DiscImageChef.Commands
|
||||
switch (discCheckStatus)
|
||||
{
|
||||
case true:
|
||||
Console.WriteLine("Disc image checksums are correct");
|
||||
DicConsole.WriteLine("Disc image checksums are correct");
|
||||
break;
|
||||
case false:
|
||||
Console.WriteLine("Disc image checksums are incorrect");
|
||||
DicConsole.WriteLine("Disc image checksums are incorrect");
|
||||
break;
|
||||
case null:
|
||||
Console.WriteLine("Disc image does not contain checksums");
|
||||
DicConsole.WriteLine("Disc image does not contain checksums");
|
||||
break;
|
||||
}
|
||||
|
||||
if (MainClass.isVerbose)
|
||||
Console.WriteLine("Checking disc image checksums took {0} seconds", CheckTime.TotalSeconds);
|
||||
DicConsole.VerboseWriteLine("Checking disc image checksums took {0} seconds", CheckTime.TotalSeconds);
|
||||
}
|
||||
|
||||
if (options.VerifySectors)
|
||||
@@ -124,7 +121,7 @@ namespace DiscImageChef.Commands
|
||||
|
||||
while (remainingSectors > 0)
|
||||
{
|
||||
Console.Write("\rChecking sector {0} of {1}, on track {2}", currentSectorAll, inputFormat.GetSectors(), currentTrack.TrackSequence);
|
||||
DicConsole.Write("\rChecking sector {0} of {1}, on track {2}", currentSectorAll, inputFormat.GetSectors(), currentTrack.TrackSequence);
|
||||
|
||||
List<UInt64> tempFailingLBAs;
|
||||
List<UInt64> tempUnknownLBAs;
|
||||
@@ -175,7 +172,7 @@ namespace DiscImageChef.Commands
|
||||
StartCheck = DateTime.UtcNow;
|
||||
while (remainingSectors > 0)
|
||||
{
|
||||
Console.Write("\rChecking sector {0} of {1}", currentSector, inputFormat.GetSectors());
|
||||
DicConsole.Write("\rChecking sector {0} of {1}", currentSector, inputFormat.GetSectors());
|
||||
|
||||
List<UInt64> tempFailingLBAs;
|
||||
List<UInt64> tempUnknownLBAs;
|
||||
@@ -218,45 +215,44 @@ namespace DiscImageChef.Commands
|
||||
|
||||
TimeSpan CheckTime = EndCheck - StartCheck;
|
||||
|
||||
Console.Write("\r");
|
||||
DicConsole.Write("\r");
|
||||
|
||||
switch (checkStatus)
|
||||
{
|
||||
case true:
|
||||
Console.WriteLine("All sector checksums are correct");
|
||||
DicConsole.WriteLine("All sector checksums are correct");
|
||||
break;
|
||||
case false:
|
||||
Console.WriteLine("There is at least one sector with incorrect checksum or errors");
|
||||
DicConsole.WriteLine("There is at least one sector with incorrect checksum or errors");
|
||||
break;
|
||||
case null:
|
||||
Console.WriteLine("There is at least one sector that does not contain a checksum");
|
||||
DicConsole.WriteLine("There is at least one sector that does not contain a checksum");
|
||||
break;
|
||||
}
|
||||
|
||||
if (MainClass.isVerbose)
|
||||
Console.WriteLine("Checking sector checksums took {0} seconds", CheckTime.TotalSeconds);
|
||||
DicConsole.VerboseWriteLine("Checking sector checksums took {0} seconds", CheckTime.TotalSeconds);
|
||||
|
||||
if (MainClass.isVerbose)
|
||||
if (options.Verbose)
|
||||
{
|
||||
Console.WriteLine("LBAs with error:");
|
||||
DicConsole.VerboseWriteLine("LBAs with error:");
|
||||
if (FailingLBAs.Count == (int)inputFormat.GetSectors())
|
||||
Console.WriteLine("\tall sectors.");
|
||||
DicConsole.VerboseWriteLine("\tall sectors.");
|
||||
else
|
||||
for (int i = 0; i < FailingLBAs.Count; i++)
|
||||
Console.WriteLine("\t{0}", FailingLBAs[i]);
|
||||
DicConsole.VerboseWriteLine("\t{0}", FailingLBAs[i]);
|
||||
|
||||
Console.WriteLine("LBAs without checksum:");
|
||||
DicConsole.WriteLine("LBAs without checksum:");
|
||||
if (UnknownLBAs.Count == (int)inputFormat.GetSectors())
|
||||
Console.WriteLine("\tall sectors.");
|
||||
DicConsole.VerboseWriteLine("\tall sectors.");
|
||||
else
|
||||
for (int i = 0; i < UnknownLBAs.Count; i++)
|
||||
Console.WriteLine("\t{0}", UnknownLBAs[i]);
|
||||
DicConsole.VerboseWriteLine("\t{0}", UnknownLBAs[i]);
|
||||
}
|
||||
|
||||
Console.WriteLine("Total sectors........... {0}", inputFormat.GetSectors());
|
||||
Console.WriteLine("Total errors............ {0}", FailingLBAs.Count);
|
||||
Console.WriteLine("Total unknowns.......... {0}", UnknownLBAs.Count);
|
||||
Console.WriteLine("Total errors+unknowns... {0}", FailingLBAs.Count + UnknownLBAs.Count);
|
||||
DicConsole.WriteLine("Total sectors........... {0}", inputFormat.GetSectors());
|
||||
DicConsole.WriteLine("Total errors............ {0}", FailingLBAs.Count);
|
||||
DicConsole.WriteLine("Total unknowns.......... {0}", UnknownLBAs.Count);
|
||||
DicConsole.WriteLine("Total errors+unknowns... {0}", FailingLBAs.Count + UnknownLBAs.Count);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -179,5 +179,9 @@
|
||||
<Project>{9183F2E0-A879-4F23-9EE3-C6908F1332B2}</Project>
|
||||
<Name>DiscImageChef.Interop</Name>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\DiscImageChef.Console\DiscImageChef.Console.csproj">
|
||||
<Project>{CCAA7AFE-C094-4D82-A66D-630DE8A3F545}</Project>
|
||||
<Name>DiscImageChef.Console</Name>
|
||||
</ProjectReference>
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
@@ -42,15 +42,12 @@ using DiscImageChef.ImagePlugins;
|
||||
using DiscImageChef.PartPlugins;
|
||||
using DiscImageChef.Plugins;
|
||||
using System.Reflection;
|
||||
using DiscImageChef.Console;
|
||||
|
||||
namespace DiscImageChef
|
||||
{
|
||||
class MainClass
|
||||
{
|
||||
|
||||
public static bool isDebug;
|
||||
public static bool isVerbose;
|
||||
|
||||
public static void Main(string[] args)
|
||||
{
|
||||
string invokedVerb = "";
|
||||
@@ -75,64 +72,85 @@ namespace DiscImageChef
|
||||
Version AssemblyVersion = typeof(MainClass).Assembly.GetName().Version;
|
||||
string AssemblyCopyright = ((AssemblyCopyrightAttribute) attributes[0]).Copyright;
|
||||
|
||||
Console.WriteLine("{0} {1}", AssemblyTitle, AssemblyVersion);
|
||||
Console.WriteLine("{0}", AssemblyCopyright);
|
||||
Console.WriteLine();
|
||||
DicConsole.WriteLineEvent += System.Console.WriteLine;
|
||||
DicConsole.ErrorWriteLineEvent += System.Console.Error.WriteLine;
|
||||
|
||||
DicConsole.WriteLine("{0} {1}", AssemblyTitle, AssemblyVersion);
|
||||
DicConsole.WriteLine("{0}", AssemblyCopyright);
|
||||
DicConsole.WriteLine();
|
||||
|
||||
switch (invokedVerb)
|
||||
{
|
||||
case "analyze":
|
||||
AnalyzeSubOptions AnalyzeOptions = (AnalyzeSubOptions)invokedVerbInstance;
|
||||
isDebug = AnalyzeOptions.Debug;
|
||||
isVerbose = AnalyzeOptions.Verbose;
|
||||
if (AnalyzeOptions.Debug)
|
||||
DicConsole.DebugWriteLineEvent += System.Console.Error.WriteLine;
|
||||
if (AnalyzeOptions.Verbose)
|
||||
DicConsole.VerboseWriteLineEvent += System.Console.WriteLine;
|
||||
Commands.Analyze.doAnalyze(AnalyzeOptions);
|
||||
break;
|
||||
case "compare":
|
||||
CompareSubOptions CompareOptions = (CompareSubOptions)invokedVerbInstance;
|
||||
isDebug = CompareOptions.Debug;
|
||||
isVerbose = CompareOptions.Verbose;
|
||||
if (CompareOptions.Debug)
|
||||
DicConsole.DebugWriteLineEvent += System.Console.Error.WriteLine;
|
||||
if (CompareOptions.Verbose)
|
||||
DicConsole.VerboseWriteLineEvent += System.Console.WriteLine;
|
||||
Commands.Compare.doCompare(CompareOptions);
|
||||
break;
|
||||
case "checksum":
|
||||
ChecksumSubOptions ChecksumOptions = (ChecksumSubOptions)invokedVerbInstance;
|
||||
isDebug = ChecksumOptions.Debug;
|
||||
isVerbose = ChecksumOptions.Verbose;
|
||||
if (ChecksumOptions.Debug)
|
||||
DicConsole.DebugWriteLineEvent += System.Console.Error.WriteLine;
|
||||
if (ChecksumOptions.Verbose)
|
||||
DicConsole.VerboseWriteLineEvent += System.Console.WriteLine;
|
||||
Commands.Checksum.doChecksum(ChecksumOptions);
|
||||
break;
|
||||
case "entropy":
|
||||
EntropySubOptions entropyOptions = (EntropySubOptions)invokedVerbInstance;
|
||||
isDebug = entropyOptions.Debug;
|
||||
isVerbose = entropyOptions.Verbose;
|
||||
if (entropyOptions.Debug)
|
||||
DicConsole.DebugWriteLineEvent += System.Console.Error.WriteLine;
|
||||
if (entropyOptions.Verbose)
|
||||
DicConsole.VerboseWriteLineEvent += System.Console.WriteLine;
|
||||
Commands.Entropy.doEntropy(entropyOptions);
|
||||
break;
|
||||
case "verify":
|
||||
VerifySubOptions VerifyOptions = (VerifySubOptions)invokedVerbInstance;
|
||||
isDebug = VerifyOptions.Debug;
|
||||
isVerbose = VerifyOptions.Verbose;
|
||||
if (VerifyOptions.Debug)
|
||||
DicConsole.DebugWriteLineEvent += System.Console.Error.WriteLine;
|
||||
if (VerifyOptions.Verbose)
|
||||
DicConsole.VerboseWriteLineEvent += System.Console.WriteLine;
|
||||
Commands.Verify.doVerify(VerifyOptions);
|
||||
break;
|
||||
case "printhex":
|
||||
PrintHexSubOptions PrintHexOptions = (PrintHexSubOptions)invokedVerbInstance;
|
||||
isDebug = PrintHexOptions.Debug;
|
||||
isVerbose = PrintHexOptions.Verbose;
|
||||
if (PrintHexOptions.Debug)
|
||||
DicConsole.DebugWriteLineEvent += System.Console.Error.WriteLine;
|
||||
if (PrintHexOptions.Verbose)
|
||||
DicConsole.VerboseWriteLineEvent += System.Console.WriteLine;
|
||||
Commands.PrintHex.doPrintHex(PrintHexOptions);
|
||||
break;
|
||||
case "decode":
|
||||
DecodeSubOptions DecodeOptions = (DecodeSubOptions)invokedVerbInstance;
|
||||
isDebug = DecodeOptions.Debug;
|
||||
isVerbose = DecodeOptions.Verbose;
|
||||
if (DecodeOptions.Debug)
|
||||
DicConsole.DebugWriteLineEvent += System.Console.Error.WriteLine;
|
||||
if (DecodeOptions.Verbose)
|
||||
DicConsole.VerboseWriteLineEvent += System.Console.WriteLine;
|
||||
Commands.Decode.doDecode(DecodeOptions);
|
||||
break;
|
||||
case "formats":
|
||||
FormatsSubOptions FormatsOptions = (FormatsSubOptions)invokedVerbInstance;
|
||||
isVerbose = FormatsOptions.Verbose;
|
||||
isDebug = FormatsOptions.Debug;
|
||||
Commands.Formats.ListFormats();
|
||||
if (FormatsOptions.Debug)
|
||||
DicConsole.DebugWriteLineEvent += System.Console.Error.WriteLine;
|
||||
if (FormatsOptions.Verbose)
|
||||
DicConsole.VerboseWriteLineEvent += System.Console.WriteLine;
|
||||
Commands.Formats.ListFormats(FormatsOptions);
|
||||
break;
|
||||
case "device-info":
|
||||
DeviceInfoSubOptions DeviceInfoOptions = (DeviceInfoSubOptions)invokedVerbInstance;
|
||||
isVerbose = DeviceInfoOptions.Verbose;
|
||||
isDebug = DeviceInfoOptions.Debug;
|
||||
if (DeviceInfoOptions.Debug)
|
||||
DicConsole.DebugWriteLineEvent += System.Console.Error.WriteLine;
|
||||
if (DeviceInfoOptions.Verbose)
|
||||
DicConsole.VerboseWriteLineEvent += System.Console.WriteLine;
|
||||
Commands.DeviceInfo.doDeviceInfo(DeviceInfoOptions);
|
||||
break;
|
||||
default:
|
||||
|
||||
@@ -76,7 +76,7 @@ namespace DiscImageChef
|
||||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
Console.WriteLine(exception);
|
||||
System.Console.Error.WriteLine(exception);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -94,7 +94,7 @@ namespace DiscImageChef
|
||||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
Console.WriteLine(exception);
|
||||
System.Console.Error.WriteLine(exception);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -112,7 +112,7 @@ namespace DiscImageChef
|
||||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
Console.WriteLine(exception);
|
||||
System.Console.Error.WriteLine(exception);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user