REFACTOR: Reformat code.

This commit is contained in:
2017-12-19 20:33:03 +00:00
parent 77edc7c91c
commit e6f6ace80b
704 changed files with 82627 additions and 83641 deletions

View File

@@ -54,5 +54,4 @@ using System.Reflection;
// if desired. See the Mono documentation for more information about signing.
//[assembly: AssemblyDelaySign(false)]
//[assembly: AssemblyKeyFile("")]
//[assembly: AssemblyKeyFile("")]

View File

@@ -68,8 +68,7 @@ namespace DiscImageChef.Commands
try
{
encoding = Claunia.Encoding.Encoding.GetEncoding(options.EncodingName);
if(options.Verbose)
DicConsole.VerboseWriteLine("Using encoding for {0}.", encoding.EncodingName);
if(options.Verbose) DicConsole.VerboseWriteLine("Using encoding for {0}.", encoding.EncodingName);
}
catch(ArgumentException)
{
@@ -100,9 +99,9 @@ namespace DiscImageChef.Commands
else
{
if(options.Verbose)
DicConsole.VerboseWriteLine("Image format identified by {0} ({1}).", _imageFormat.Name, _imageFormat.PluginUUID);
else
DicConsole.WriteLine("Image format identified by {0}.", _imageFormat.Name);
DicConsole.VerboseWriteLine("Image format identified by {0} ({1}).", _imageFormat.Name,
_imageFormat.PluginUUID);
else DicConsole.WriteLine("Image format identified by {0}.", _imageFormat.Name);
}
try
@@ -115,9 +114,11 @@ namespace DiscImageChef.Commands
}
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 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.GetMediaType());
DicConsole.DebugWriteLine("Analyze command", "Image identifies disk type as {0}.",
_imageFormat.GetMediaType());
Core.Statistics.AddMediaFormat(_imageFormat.GetImageFormat());
Core.Statistics.AddMedia(_imageFormat.ImageInfo.mediaType, false);
@@ -144,6 +145,7 @@ namespace DiscImageChef.Commands
DicConsole.WriteLine("No partitions founds, not searching for filesystems");
return;
}
checkraw = true;
}
else
@@ -156,8 +158,10 @@ namespace DiscImageChef.Commands
DicConsole.WriteLine("Partition {0}:", partitions[i].Sequence);
DicConsole.WriteLine("Partition name: {0}", partitions[i].Name);
DicConsole.WriteLine("Partition type: {0}", partitions[i].Type);
DicConsole.WriteLine("Partition start: sector {0}, byte {1}", partitions[i].Start, partitions[i].Offset);
DicConsole.WriteLine("Partition length: {0} sectors, {1} bytes", partitions[i].Length, partitions[i].Size);
DicConsole.WriteLine("Partition start: sector {0}, byte {1}", partitions[i].Start,
partitions[i].Offset);
DicConsole.WriteLine("Partition length: {0} sectors, {1} bytes", partitions[i].Length,
partitions[i].Size);
DicConsole.WriteLine("Partition scheme: {0}", partitions[i].Scheme);
DicConsole.WriteLine("Partition description:");
DicConsole.WriteLine(partitions[i].Description);
@@ -167,8 +171,7 @@ namespace DiscImageChef.Commands
DicConsole.WriteLine("Identifying filesystem on partition");
Core.Filesystems.Identify(_imageFormat, out id_plugins, partitions[i]);
if(id_plugins.Count == 0)
DicConsole.WriteLine("Filesystem not identified");
if(id_plugins.Count == 0) DicConsole.WriteLine("Filesystem not identified");
else if(id_plugins.Count > 1)
{
DicConsole.WriteLine(string.Format("Identified by {0} plugins", id_plugins.Count));
@@ -207,8 +210,7 @@ namespace DiscImageChef.Commands
};
Core.Filesystems.Identify(_imageFormat, out id_plugins, wholePart);
if(id_plugins.Count == 0)
DicConsole.WriteLine("Filesystem not identified");
if(id_plugins.Count == 0) DicConsole.WriteLine("Filesystem not identified");
else if(id_plugins.Count > 1)
{
DicConsole.WriteLine(string.Format("Identified by {0} plugins", id_plugins.Count));
@@ -243,5 +245,4 @@ namespace DiscImageChef.Commands
Core.Statistics.AddCommand("analyze");
}
}
}
}

View File

@@ -47,26 +47,32 @@ namespace DiscImageChef.Commands
BenchmarkResults results = Core.Benchmark.Do(options.BufferSize * 1024 * 1024, options.BlockSize);
DicConsole.WriteLine("Took {0} seconds to fill buffer, {1:F3} MiB/sec.", results.fillTime, results.fillSpeed);
DicConsole.WriteLine("Took {0} seconds to read buffer, {1:F3} MiB/sec.", results.readTime, results.readSpeed);
DicConsole.WriteLine("Took {0} seconds to entropy buffer, {1:F3} MiB/sec.", results.entropyTime, results.entropySpeed);
DicConsole.WriteLine("Took {0} seconds to fill buffer, {1:F3} MiB/sec.", results.fillTime,
results.fillSpeed);
DicConsole.WriteLine("Took {0} seconds to read buffer, {1:F3} MiB/sec.", results.readTime,
results.readSpeed);
DicConsole.WriteLine("Took {0} seconds to entropy buffer, {1:F3} MiB/sec.", results.entropyTime,
results.entropySpeed);
foreach(KeyValuePair<string, BenchmarkEntry> entry in results.entries)
{
checksumTimes.Add(entry.Key, entry.Value.timeSpan);
DicConsole.WriteLine("Took {0} seconds to {1} buffer, {2:F3} MiB/sec.", entry.Value.timeSpan, entry.Key, entry.Value.speed);
DicConsole.WriteLine("Took {0} seconds to {1} buffer, {2:F3} MiB/sec.", entry.Value.timeSpan, entry.Key,
entry.Value.speed);
}
DicConsole.WriteLine("Took {0} seconds to do all algorithms at the same time, {1} MiB/sec.", results.totalTime, results.totalSpeed);
DicConsole.WriteLine("Took {0} seconds to do all algorithms sequentially, {1} MiB/sec.", results.separateTime, results.separateSpeed);
DicConsole.WriteLine("Took {0} seconds to do all algorithms at the same time, {1} MiB/sec.",
results.totalTime, results.totalSpeed);
DicConsole.WriteLine("Took {0} seconds to do all algorithms sequentially, {1} MiB/sec.",
results.separateTime, results.separateSpeed);
DicConsole.WriteLine();
DicConsole.WriteLine("Max memory used is {0} bytes", results.maxMemory);
DicConsole.WriteLine("Min memory used is {0} bytes", results.minMemory);
Core.Statistics.AddCommand("benchmark");
Core.Statistics.AddBenchmark(checksumTimes, results.entropyTime, results.totalTime, results.separateTime, results.maxMemory, results.minMemory);
Core.Statistics.AddBenchmark(checksumTimes, results.entropyTime, results.totalTime, results.separateTime,
results.maxMemory, results.minMemory);
}
}
}
}

View File

@@ -87,28 +87,17 @@ namespace DiscImageChef.Commands
Core.Statistics.AddFilter(inputFilter.Name);
EnableChecksum enabledChecksums = new EnableChecksum();
if(options.DoAdler32)
enabledChecksums |= EnableChecksum.Adler32;
if(options.DoCRC16)
enabledChecksums |= EnableChecksum.CRC16;
if(options.DoCRC32)
enabledChecksums |= EnableChecksum.CRC32;
if(options.DoCRC64)
enabledChecksums |= EnableChecksum.CRC64;
if(options.DoMD5)
enabledChecksums |= EnableChecksum.MD5;
if(options.DoRIPEMD160)
enabledChecksums |= EnableChecksum.RIPEMD160;
if(options.DoSHA1)
enabledChecksums |= EnableChecksum.SHA1;
if(options.DoSHA256)
enabledChecksums |= EnableChecksum.SHA256;
if(options.DoSHA384)
enabledChecksums |= EnableChecksum.SHA384;
if(options.DoSHA512)
enabledChecksums |= EnableChecksum.SHA512;
if(options.DoSpamSum)
enabledChecksums |= EnableChecksum.SpamSum;
if(options.DoAdler32) enabledChecksums |= EnableChecksum.Adler32;
if(options.DoCRC16) enabledChecksums |= EnableChecksum.CRC16;
if(options.DoCRC32) enabledChecksums |= EnableChecksum.CRC32;
if(options.DoCRC64) enabledChecksums |= EnableChecksum.CRC64;
if(options.DoMD5) enabledChecksums |= EnableChecksum.MD5;
if(options.DoRIPEMD160) enabledChecksums |= EnableChecksum.RIPEMD160;
if(options.DoSHA1) enabledChecksums |= EnableChecksum.SHA1;
if(options.DoSHA256) enabledChecksums |= EnableChecksum.SHA256;
if(options.DoSHA384) enabledChecksums |= EnableChecksum.SHA384;
if(options.DoSHA512) enabledChecksums |= EnableChecksum.SHA512;
if(options.DoSpamSum) enabledChecksums |= EnableChecksum.SpamSum;
Core.Checksum mediaChecksum = null;
@@ -118,16 +107,14 @@ namespace DiscImageChef.Commands
{
Core.Checksum trackChecksum = null;
if(options.WholeDisc)
mediaChecksum = new Core.Checksum(enabledChecksums);
if(options.WholeDisc) mediaChecksum = new Core.Checksum(enabledChecksums);
ulong previousTrackEnd = 0;
List<Track> inputTracks = inputFormat.GetTracks();
foreach(Track currentTrack in inputTracks)
{
if((currentTrack.TrackStartSector - previousTrackEnd) != 0 &&
options.WholeDisc)
if((currentTrack.TrackStartSector - previousTrackEnd) != 0 && options.WholeDisc)
{
for(ulong i = previousTrackEnd + 1; i < currentTrack.TrackStartSector; i++)
{
@@ -139,11 +126,12 @@ namespace DiscImageChef.Commands
}
}
DicConsole.DebugWriteLine("Checksum command", "Track {0} starts at sector {1} and ends at sector {2}", currentTrack.TrackSequence,
currentTrack.TrackStartSector, currentTrack.TrackEndSector);
DicConsole.DebugWriteLine("Checksum command",
"Track {0} starts at sector {1} and ends at sector {2}",
currentTrack.TrackSequence, currentTrack.TrackStartSector,
currentTrack.TrackEndSector);
if(options.SeparatedTracks)
trackChecksum = new Core.Checksum(enabledChecksums);
if(options.SeparatedTracks) trackChecksum = new Core.Checksum(enabledChecksums);
ulong sectors = currentTrack.TrackEndSector - currentTrack.TrackStartSector + 1;
ulong doneSectors = 0;
@@ -155,22 +143,24 @@ namespace DiscImageChef.Commands
if((sectors - doneSectors) >= sectorsToRead)
{
sector = inputFormat.ReadSectors(doneSectors, sectorsToRead, currentTrack.TrackSequence);
DicConsole.Write("\rHashings sectors {0} to {2} of track {1}", doneSectors, currentTrack.TrackSequence, doneSectors + sectorsToRead);
sector = inputFormat.ReadSectors(doneSectors, sectorsToRead,
currentTrack.TrackSequence);
DicConsole.Write("\rHashings sectors {0} to {2} of track {1}", doneSectors,
currentTrack.TrackSequence, doneSectors + sectorsToRead);
doneSectors += sectorsToRead;
}
else
{
sector = inputFormat.ReadSectors(doneSectors, (uint)(sectors - doneSectors), currentTrack.TrackSequence);
DicConsole.Write("\rHashings sectors {0} to {2} of track {1}", doneSectors, currentTrack.TrackSequence, doneSectors + (sectors - doneSectors));
sector = inputFormat.ReadSectors(doneSectors, (uint)(sectors - doneSectors),
currentTrack.TrackSequence);
DicConsole.Write("\rHashings sectors {0} to {2} of track {1}", doneSectors,
currentTrack.TrackSequence, doneSectors + (sectors - doneSectors));
doneSectors += (sectors - doneSectors);
}
if(options.WholeDisc)
mediaChecksum.Update(sector);
if(options.WholeDisc) mediaChecksum.Update(sector);
if(options.SeparatedTracks)
trackChecksum.Update(sector);
if(options.SeparatedTracks) trackChecksum.Update(sector);
}
DicConsole.WriteLine();
@@ -178,14 +168,14 @@ namespace DiscImageChef.Commands
if(options.SeparatedTracks)
{
foreach(ChecksumType chk in trackChecksum.End())
DicConsole.WriteLine("Track {0}'s {1}: {2}", currentTrack.TrackSequence, chk.type, chk.Value);
DicConsole.WriteLine("Track {0}'s {1}: {2}", currentTrack.TrackSequence, chk.type,
chk.Value);
}
previousTrackEnd = currentTrack.TrackEndSector;
}
if((inputFormat.GetSectors() - previousTrackEnd) != 0 &&
options.WholeDisc)
if((inputFormat.GetSectors() - previousTrackEnd) != 0 && options.WholeDisc)
{
for(ulong i = previousTrackEnd + 1; i < inputFormat.GetSectors(); i++)
{
@@ -204,10 +194,8 @@ namespace DiscImageChef.Commands
}
catch(Exception ex)
{
if(options.Debug)
DicConsole.DebugWriteLine("Could not get tracks because {0}", ex.Message);
else
DicConsole.WriteLine("Unable to get separate tracks, not checksumming them");
if(options.Debug) DicConsole.DebugWriteLine("Could not get tracks because {0}", ex.Message);
else DicConsole.WriteLine("Unable to get separate tracks, not checksumming them");
}
}
else
@@ -231,7 +219,8 @@ namespace DiscImageChef.Commands
else
{
sector = inputFormat.ReadSectors(doneSectors, (uint)(sectors - doneSectors));
DicConsole.Write("\rHashings sectors {0} to {1}", doneSectors, doneSectors + (sectors - doneSectors));
DicConsole.Write("\rHashings sectors {0} to {1}", doneSectors,
doneSectors + (sectors - doneSectors));
doneSectors += (sectors - doneSectors);
}

View File

@@ -32,8 +32,5 @@
namespace DiscImageChef.Commands
{
public class Commands
{
}
}
public class Commands { }
}

View File

@@ -77,9 +77,9 @@ namespace DiscImageChef.Commands
else
{
if(options.Verbose)
DicConsole.VerboseWriteLine("Input file 1 format identified by {0} ({1}).", input1Format.Name, input1Format.PluginUUID);
else
DicConsole.WriteLine("Input file 1 format identified by {0}.", input1Format.Name);
DicConsole.VerboseWriteLine("Input file 1 format identified by {0} ({1}).", input1Format.Name,
input1Format.PluginUUID);
else DicConsole.WriteLine("Input file 1 format identified by {0}.", input1Format.Name);
}
if(input2Format == null)
@@ -90,9 +90,9 @@ namespace DiscImageChef.Commands
else
{
if(options.Verbose)
DicConsole.VerboseWriteLine("Input file 2 format identified by {0} ({1}).", input2Format.Name, input2Format.PluginUUID);
else
DicConsole.WriteLine("Input file 2 format identified by {0}.", input2Format.Name);
DicConsole.VerboseWriteLine("Input file 2 format identified by {0} ({1}).", input2Format.Name,
input2Format.PluginUUID);
else DicConsole.WriteLine("Input file 2 format identified by {0}.", input2Format.Name);
}
input1Format.OpenImage(inputFilter1);
@@ -131,7 +131,8 @@ namespace DiscImageChef.Commands
image1Info.imageHasPartitions = input1Format.ImageHasPartitions();
#pragma warning disable RECS0022 // A catch clause that catches System.Exception and has an empty body
try { image1Sessions = input1Format.GetSessions(); } catch { }
try { image1Sessions = input1Format.GetSessions(); }
catch { }
#pragma warning restore RECS0022 // A catch clause that catches System.Exception and has an empty body
image1Info.imageHasSessions |= image1Sessions.Count > 0;
image1Info.imageSize = input1Format.GetImageSize();
@@ -140,23 +141,40 @@ namespace DiscImageChef.Commands
image1Info.imageCreationTime = input1Format.GetImageCreationTime();
image1Info.imageLastModificationTime = input1Format.GetImageLastModificationTime();
image1Info.mediaType = input1Format.GetMediaType();
try { image1Info.imageVersion = input1Format.GetImageVersion(); } catch { image1Info.imageVersion = null; }
try { image1Info.imageApplication = input1Format.GetImageApplication(); } catch { image1Info.imageApplication = null; }
try { image1Info.imageApplicationVersion = input1Format.GetImageApplicationVersion(); } catch { image1Info.imageApplicationVersion = null; }
try { image1Info.imageCreator = input1Format.GetImageCreator(); } catch { image1Info.imageCreator = null; }
try { image1Info.imageName = input1Format.GetImageName(); } catch { image1Info.imageName = null; }
try { image1Info.imageComments = input1Format.GetImageComments(); } catch { image1Info.imageComments = null; }
try { image1Info.mediaManufacturer = input1Format.GetMediaManufacturer(); } catch { image1Info.mediaManufacturer = null; }
try { image1Info.mediaModel = input1Format.GetMediaModel(); } catch { image1Info.mediaModel = null; }
try { image1Info.mediaSerialNumber = input1Format.GetMediaSerialNumber(); } catch { image1Info.mediaSerialNumber = null; }
try { image1Info.mediaBarcode = input1Format.GetMediaBarcode(); } catch { image1Info.mediaBarcode = null; }
try { image1Info.mediaPartNumber = input1Format.GetMediaPartNumber(); } catch { image1Info.mediaPartNumber = null; }
try { image1Info.mediaSequence = input1Format.GetMediaSequence(); } catch { image1Info.mediaSequence = 0; }
try { image1Info.lastMediaSequence = input1Format.GetLastDiskSequence(); } catch { image1Info.lastMediaSequence = 0; }
try { image1Info.driveManufacturer = input1Format.GetDriveManufacturer(); } catch { image1Info.driveManufacturer = null; }
try { image1Info.driveModel = input1Format.GetDriveModel(); } catch { image1Info.driveModel = null; }
try { image1Info.driveSerialNumber = input1Format.GetDriveSerialNumber(); } catch { image1Info.driveSerialNumber = null; }
try { image1Info.driveFirmwareRevision = input1Format.ImageInfo.driveFirmwareRevision; } catch { image1Info.driveFirmwareRevision = null; }
try { image1Info.imageVersion = input1Format.GetImageVersion(); }
catch { image1Info.imageVersion = null; }
try { image1Info.imageApplication = input1Format.GetImageApplication(); }
catch { image1Info.imageApplication = null; }
try { image1Info.imageApplicationVersion = input1Format.GetImageApplicationVersion(); }
catch { image1Info.imageApplicationVersion = null; }
try { image1Info.imageCreator = input1Format.GetImageCreator(); }
catch { image1Info.imageCreator = null; }
try { image1Info.imageName = input1Format.GetImageName(); }
catch { image1Info.imageName = null; }
try { image1Info.imageComments = input1Format.GetImageComments(); }
catch { image1Info.imageComments = null; }
try { image1Info.mediaManufacturer = input1Format.GetMediaManufacturer(); }
catch { image1Info.mediaManufacturer = null; }
try { image1Info.mediaModel = input1Format.GetMediaModel(); }
catch { image1Info.mediaModel = null; }
try { image1Info.mediaSerialNumber = input1Format.GetMediaSerialNumber(); }
catch { image1Info.mediaSerialNumber = null; }
try { image1Info.mediaBarcode = input1Format.GetMediaBarcode(); }
catch { image1Info.mediaBarcode = null; }
try { image1Info.mediaPartNumber = input1Format.GetMediaPartNumber(); }
catch { image1Info.mediaPartNumber = null; }
try { image1Info.mediaSequence = input1Format.GetMediaSequence(); }
catch { image1Info.mediaSequence = 0; }
try { image1Info.lastMediaSequence = input1Format.GetLastDiskSequence(); }
catch { image1Info.lastMediaSequence = 0; }
try { image1Info.driveManufacturer = input1Format.GetDriveManufacturer(); }
catch { image1Info.driveManufacturer = null; }
try { image1Info.driveModel = input1Format.GetDriveModel(); }
catch { image1Info.driveModel = null; }
try { image1Info.driveSerialNumber = input1Format.GetDriveSerialNumber(); }
catch { image1Info.driveSerialNumber = null; }
try { image1Info.driveFirmwareRevision = input1Format.ImageInfo.driveFirmwareRevision; }
catch { image1Info.driveFirmwareRevision = null; }
foreach(MediaTagType disktag in Enum.GetValues(typeof(MediaTagType)))
{
try
@@ -165,15 +183,14 @@ namespace DiscImageChef.Commands
image1DiskTags.Add(disktag, temparray);
}
#pragma warning disable RECS0022 // A catch clause that catches System.Exception and has an empty body
catch
catch { }
#pragma warning restore RECS0022 // A catch clause that catches System.Exception and has an empty body
{
}
}
image2Info.imageHasPartitions = input2Format.ImageHasPartitions();
#pragma warning disable RECS0022 // A catch clause that catches System.Exception and has an empty body
try { image2Sessions = input2Format.GetSessions(); } catch { }
try { image2Sessions = input2Format.GetSessions(); }
catch { }
#pragma warning restore RECS0022 // A catch clause that catches System.Exception and has an empty body
image2Info.imageHasSessions |= image2Sessions.Count > 0;
image2Info.imageSize = input2Format.GetImageSize();
@@ -182,23 +199,40 @@ namespace DiscImageChef.Commands
image2Info.imageCreationTime = input2Format.GetImageCreationTime();
image2Info.imageLastModificationTime = input2Format.GetImageLastModificationTime();
image2Info.mediaType = input2Format.GetMediaType();
try { image2Info.imageVersion = input2Format.GetImageVersion(); } catch { image2Info.imageVersion = null; }
try { image2Info.imageApplication = input2Format.GetImageApplication(); } catch { image2Info.imageApplication = null; }
try { image2Info.imageApplicationVersion = input2Format.GetImageApplicationVersion(); } catch { image2Info.imageApplicationVersion = null; }
try { image2Info.imageCreator = input2Format.GetImageCreator(); } catch { image2Info.imageCreator = null; }
try { image2Info.imageName = input2Format.GetImageName(); } catch { image2Info.imageName = null; }
try { image2Info.imageComments = input2Format.GetImageComments(); } catch { image2Info.imageComments = null; }
try { image2Info.mediaManufacturer = input2Format.GetMediaManufacturer(); } catch { image2Info.mediaManufacturer = null; }
try { image2Info.mediaModel = input2Format.GetMediaModel(); } catch { image2Info.mediaModel = null; }
try { image2Info.mediaSerialNumber = input2Format.GetMediaSerialNumber(); } catch { image2Info.mediaSerialNumber = null; }
try { image2Info.mediaBarcode = input2Format.GetMediaBarcode(); } catch { image2Info.mediaBarcode = null; }
try { image2Info.mediaPartNumber = input2Format.GetMediaPartNumber(); } catch { image2Info.mediaPartNumber = null; }
try { image2Info.mediaSequence = input2Format.GetMediaSequence(); } catch { image2Info.mediaSequence = 0; }
try { image2Info.lastMediaSequence = input2Format.GetLastDiskSequence(); } catch { image2Info.lastMediaSequence = 0; }
try { image2Info.driveManufacturer = input2Format.GetDriveManufacturer(); } catch { image2Info.driveManufacturer = null; }
try { image2Info.driveModel = input2Format.GetDriveModel(); } catch { image2Info.driveModel = null; }
try { image2Info.driveSerialNumber = input2Format.GetDriveSerialNumber(); } catch { image2Info.driveSerialNumber = null; }
try { image2Info.driveFirmwareRevision = input2Format.ImageInfo.driveFirmwareRevision; } catch { image2Info.driveFirmwareRevision = null; }
try { image2Info.imageVersion = input2Format.GetImageVersion(); }
catch { image2Info.imageVersion = null; }
try { image2Info.imageApplication = input2Format.GetImageApplication(); }
catch { image2Info.imageApplication = null; }
try { image2Info.imageApplicationVersion = input2Format.GetImageApplicationVersion(); }
catch { image2Info.imageApplicationVersion = null; }
try { image2Info.imageCreator = input2Format.GetImageCreator(); }
catch { image2Info.imageCreator = null; }
try { image2Info.imageName = input2Format.GetImageName(); }
catch { image2Info.imageName = null; }
try { image2Info.imageComments = input2Format.GetImageComments(); }
catch { image2Info.imageComments = null; }
try { image2Info.mediaManufacturer = input2Format.GetMediaManufacturer(); }
catch { image2Info.mediaManufacturer = null; }
try { image2Info.mediaModel = input2Format.GetMediaModel(); }
catch { image2Info.mediaModel = null; }
try { image2Info.mediaSerialNumber = input2Format.GetMediaSerialNumber(); }
catch { image2Info.mediaSerialNumber = null; }
try { image2Info.mediaBarcode = input2Format.GetMediaBarcode(); }
catch { image2Info.mediaBarcode = null; }
try { image2Info.mediaPartNumber = input2Format.GetMediaPartNumber(); }
catch { image2Info.mediaPartNumber = null; }
try { image2Info.mediaSequence = input2Format.GetMediaSequence(); }
catch { image2Info.mediaSequence = 0; }
try { image2Info.lastMediaSequence = input2Format.GetLastDiskSequence(); }
catch { image2Info.lastMediaSequence = 0; }
try { image2Info.driveManufacturer = input2Format.GetDriveManufacturer(); }
catch { image2Info.driveManufacturer = null; }
try { image2Info.driveModel = input2Format.GetDriveModel(); }
catch { image2Info.driveModel = null; }
try { image2Info.driveSerialNumber = input2Format.GetDriveSerialNumber(); }
catch { image2Info.driveSerialNumber = null; }
try { image2Info.driveFirmwareRevision = input2Format.ImageInfo.driveFirmwareRevision; }
catch { image2Info.driveFirmwareRevision = null; }
foreach(MediaTagType disktag in Enum.GetValues(typeof(MediaTagType)))
{
try
@@ -207,42 +241,59 @@ namespace DiscImageChef.Commands
image2DiskTags.Add(disktag, temparray);
}
#pragma warning disable RECS0022 // A catch clause that catches System.Exception and has an empty body
catch
catch { }
#pragma warning restore RECS0022 // A catch clause that catches System.Exception and has an empty body
{
}
}
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();
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();
sb.AppendFormat("Image size\t{0}\t{1}", image1Info.imageSize, image2Info.imageSize).AppendLine();
sb.AppendFormat("Sectors\t{0}\t{1}", image1Info.sectors, image2Info.sectors).AppendLine();
sb.AppendFormat("Sector size\t{0}\t{1}", image1Info.sectorSize, image2Info.sectorSize).AppendLine();
sb.AppendFormat("Creation time\t{0}\t{1}", image1Info.imageCreationTime, image2Info.imageCreationTime).AppendLine();
sb.AppendFormat("Last modification time\t{0}\t{1}", image1Info.imageLastModificationTime, image2Info.imageLastModificationTime).AppendLine();
sb.AppendFormat("Creation time\t{0}\t{1}", image1Info.imageCreationTime, image2Info.imageCreationTime)
.AppendLine();
sb.AppendFormat("Last modification time\t{0}\t{1}", image1Info.imageLastModificationTime,
image2Info.imageLastModificationTime).AppendLine();
sb.AppendFormat("Disk type\t{0}\t{1}", image1Info.mediaType, image2Info.mediaType).AppendLine();
sb.AppendFormat("Image version\t{0}\t{1}", image1Info.imageVersion, image2Info.imageVersion).AppendLine();
sb.AppendFormat("Image application\t{0}\t{1}", image1Info.imageApplication, image2Info.imageApplication).AppendLine();
sb.AppendFormat("Image application version\t{0}\t{1}", image1Info.imageApplicationVersion, image2Info.imageApplicationVersion).AppendLine();
sb.AppendFormat("Image creator\t{0}\t{1}", image1Info.imageCreator, image2Info.imageCreator).AppendLine();
sb.AppendFormat("Image version\t{0}\t{1}", image1Info.imageVersion, image2Info.imageVersion)
.AppendLine();
sb.AppendFormat("Image application\t{0}\t{1}", image1Info.imageApplication, image2Info.imageApplication)
.AppendLine();
sb.AppendFormat("Image application version\t{0}\t{1}", image1Info.imageApplicationVersion,
image2Info.imageApplicationVersion).AppendLine();
sb.AppendFormat("Image creator\t{0}\t{1}", image1Info.imageCreator, image2Info.imageCreator)
.AppendLine();
sb.AppendFormat("Image name\t{0}\t{1}", image1Info.imageName, image2Info.imageName).AppendLine();
sb.AppendFormat("Image comments\t{0}\t{1}", image1Info.imageComments, image2Info.imageComments).AppendLine();
sb.AppendFormat("Disk manufacturer\t{0}\t{1}", image1Info.mediaManufacturer, image2Info.mediaManufacturer).AppendLine();
sb.AppendFormat("Image comments\t{0}\t{1}", image1Info.imageComments, image2Info.imageComments)
.AppendLine();
sb.AppendFormat("Disk manufacturer\t{0}\t{1}", image1Info.mediaManufacturer,
image2Info.mediaManufacturer).AppendLine();
sb.AppendFormat("Disk model\t{0}\t{1}", image1Info.mediaModel, image2Info.mediaModel).AppendLine();
sb.AppendFormat("Disk serial number\t{0}\t{1}", image1Info.mediaSerialNumber, image2Info.mediaSerialNumber).AppendLine();
sb.AppendFormat("Disk barcode\t{0}\t{1}", image1Info.mediaBarcode, image2Info.mediaBarcode).AppendLine();
sb.AppendFormat("Disk part no.\t{0}\t{1}", image1Info.mediaPartNumber, image2Info.mediaPartNumber).AppendLine();
sb.AppendFormat("Disk sequence\t{0}\t{1}", image1Info.mediaSequence, image2Info.mediaSequence).AppendLine();
sb.AppendFormat("Last disk on sequence\t{0}\t{1}", image1Info.lastMediaSequence, image2Info.lastMediaSequence).AppendLine();
sb.AppendFormat("Drive manufacturer\t{0}\t{1}", image1Info.driveManufacturer, image2Info.driveManufacturer).AppendLine();
sb.AppendFormat("Drive firmware revision\t{0}\t{1}", image1Info.driveFirmwareRevision, image2Info.driveFirmwareRevision).AppendLine();
sb.AppendFormat("Disk serial number\t{0}\t{1}", image1Info.mediaSerialNumber,
image2Info.mediaSerialNumber).AppendLine();
sb.AppendFormat("Disk barcode\t{0}\t{1}", image1Info.mediaBarcode, image2Info.mediaBarcode)
.AppendLine();
sb.AppendFormat("Disk part no.\t{0}\t{1}", image1Info.mediaPartNumber, image2Info.mediaPartNumber)
.AppendLine();
sb.AppendFormat("Disk sequence\t{0}\t{1}", image1Info.mediaSequence, image2Info.mediaSequence)
.AppendLine();
sb.AppendFormat("Last disk on sequence\t{0}\t{1}", image1Info.lastMediaSequence,
image2Info.lastMediaSequence).AppendLine();
sb.AppendFormat("Drive manufacturer\t{0}\t{1}", image1Info.driveManufacturer,
image2Info.driveManufacturer).AppendLine();
sb.AppendFormat("Drive firmware revision\t{0}\t{1}", image1Info.driveFirmwareRevision,
image2Info.driveFirmwareRevision).AppendLine();
sb.AppendFormat("Drive model\t{0}\t{1}", image1Info.driveModel, image2Info.driveModel).AppendLine();
sb.AppendFormat("Drive serial number\t{0}\t{1}", image1Info.driveSerialNumber, image2Info.driveSerialNumber).AppendLine();
sb.AppendFormat("Drive serial number\t{0}\t{1}", image1Info.driveSerialNumber,
image2Info.driveSerialNumber).AppendLine();
foreach(MediaTagType disktag in Enum.GetValues(typeof(MediaTagType)))
{
sb.AppendFormat("Has {0}?\t{1}\t{2}", disktag, image1DiskTags.ContainsKey(disktag), image2DiskTags.ContainsKey(disktag)).AppendLine();
sb.AppendFormat("Has {0}?\t{1}\t{2}", disktag, image1DiskTags.ContainsKey(disktag),
image2DiskTags.ContainsKey(disktag)).AppendLine();
}
}
@@ -251,152 +302,127 @@ namespace DiscImageChef.Commands
if(image1Info.imageHasPartitions != image2Info.imageHasPartitions)
{
imagesDiffer = true;
if(!options.Verbose)
sb.AppendLine("Image partitioned status differ");
if(!options.Verbose) sb.AppendLine("Image partitioned status differ");
}
if(image1Info.imageHasSessions != image2Info.imageHasSessions)
{
imagesDiffer = true;
if(!options.Verbose)
sb.AppendLine("Image session status differ");
if(!options.Verbose) sb.AppendLine("Image session status differ");
}
if(image1Info.imageSize != image2Info.imageSize)
{
imagesDiffer = true;
if(!options.Verbose)
sb.AppendLine("Image size differ");
if(!options.Verbose) sb.AppendLine("Image size differ");
}
if(image1Info.sectors != image2Info.sectors)
{
imagesDiffer = true;
if(!options.Verbose)
sb.AppendLine("Image sectors differ");
if(!options.Verbose) sb.AppendLine("Image sectors differ");
}
if(image1Info.sectorSize != image2Info.sectorSize)
{
imagesDiffer = true;
if(!options.Verbose)
sb.AppendLine("Image sector size differ");
if(!options.Verbose) sb.AppendLine("Image sector size differ");
}
if(image1Info.imageCreationTime != image2Info.imageCreationTime)
{
imagesDiffer = true;
if(!options.Verbose)
sb.AppendLine("Image creation time differ");
if(!options.Verbose) sb.AppendLine("Image creation time differ");
}
if(image1Info.imageLastModificationTime != image2Info.imageLastModificationTime)
{
imagesDiffer = true;
if(!options.Verbose)
sb.AppendLine("Image last modification time differ");
if(!options.Verbose) sb.AppendLine("Image last modification time differ");
}
if(image1Info.mediaType != image2Info.mediaType)
{
imagesDiffer = true;
if(!options.Verbose)
sb.AppendLine("Disk type differ");
if(!options.Verbose) sb.AppendLine("Disk type differ");
}
if(image1Info.imageVersion != image2Info.imageVersion)
{
imagesDiffer = true;
if(!options.Verbose)
sb.AppendLine("Image version differ");
if(!options.Verbose) sb.AppendLine("Image version differ");
}
if(image1Info.imageApplication != image2Info.imageApplication)
{
imagesDiffer = true;
if(!options.Verbose)
sb.AppendLine("Image application differ");
if(!options.Verbose) sb.AppendLine("Image application differ");
}
if(image1Info.imageApplicationVersion != image2Info.imageApplicationVersion)
{
imagesDiffer = true;
if(!options.Verbose)
sb.AppendLine("Image application version differ");
if(!options.Verbose) sb.AppendLine("Image application version differ");
}
if(image1Info.imageCreator != image2Info.imageCreator)
{
imagesDiffer = true;
if(!options.Verbose)
sb.AppendLine("Image creator differ");
if(!options.Verbose) sb.AppendLine("Image creator differ");
}
if(image1Info.imageName != image2Info.imageName)
{
imagesDiffer = true;
if(!options.Verbose)
sb.AppendLine("Image name differ");
if(!options.Verbose) sb.AppendLine("Image name differ");
}
if(image1Info.imageComments != image2Info.imageComments)
{
imagesDiffer = true;
if(!options.Verbose)
sb.AppendLine("Image comments differ");
if(!options.Verbose) sb.AppendLine("Image comments differ");
}
if(image1Info.mediaManufacturer != image2Info.mediaManufacturer)
{
imagesDiffer = true;
if(!options.Verbose)
sb.AppendLine("Disk manufacturer differ");
if(!options.Verbose) sb.AppendLine("Disk manufacturer differ");
}
if(image1Info.mediaModel != image2Info.mediaModel)
{
imagesDiffer = true;
if(!options.Verbose)
sb.AppendLine("Disk model differ");
if(!options.Verbose) sb.AppendLine("Disk model differ");
}
if(image1Info.mediaSerialNumber != image2Info.mediaSerialNumber)
{
imagesDiffer = true;
if(!options.Verbose)
sb.AppendLine("Disk serial number differ");
if(!options.Verbose) sb.AppendLine("Disk serial number differ");
}
if(image1Info.mediaBarcode != image2Info.mediaBarcode)
{
imagesDiffer = true;
if(!options.Verbose)
sb.AppendLine("Disk barcode differ");
if(!options.Verbose) sb.AppendLine("Disk barcode differ");
}
if(image1Info.mediaPartNumber != image2Info.mediaPartNumber)
{
imagesDiffer = true;
if(!options.Verbose)
sb.AppendLine("Disk part number differ");
if(!options.Verbose) sb.AppendLine("Disk part number differ");
}
if(image1Info.mediaSequence != image2Info.mediaSequence)
{
imagesDiffer = true;
if(!options.Verbose)
sb.AppendLine("Disk sequence differ");
if(!options.Verbose) sb.AppendLine("Disk sequence differ");
}
if(image1Info.lastMediaSequence != image2Info.lastMediaSequence)
{
imagesDiffer = true;
if(!options.Verbose)
sb.AppendLine("Last disk in sequence differ");
if(!options.Verbose) sb.AppendLine("Last disk in sequence differ");
}
if(image1Info.driveManufacturer != image2Info.driveManufacturer)
{
imagesDiffer = true;
if(!options.Verbose)
sb.AppendLine("Drive manufacturer differ");
if(!options.Verbose) sb.AppendLine("Drive manufacturer differ");
}
if(image1Info.driveModel != image2Info.driveModel)
{
imagesDiffer = true;
if(!options.Verbose)
sb.AppendLine("Drive model differ");
if(!options.Verbose) sb.AppendLine("Drive model differ");
}
if(image1Info.driveSerialNumber != image2Info.driveSerialNumber)
{
imagesDiffer = true;
if(!options.Verbose)
sb.AppendLine("Drive serial number differ");
if(!options.Verbose) sb.AppendLine("Drive serial number differ");
}
if(image1Info.driveFirmwareRevision != image2Info.driveFirmwareRevision)
{
imagesDiffer = true;
if(!options.Verbose)
sb.AppendLine("Drive firmware revision differ");
if(!options.Verbose) sb.AppendLine("Drive firmware revision differ");
}
ulong leastSectors;
@@ -404,18 +430,15 @@ namespace DiscImageChef.Commands
{
imagesDiffer = true;
leastSectors = image1Info.sectors;
if(!options.Verbose)
sb.AppendLine("Image 2 has more sectors");
if(!options.Verbose) sb.AppendLine("Image 2 has more sectors");
}
else if(image1Info.sectors > image2Info.sectors)
{
imagesDiffer = true;
leastSectors = image2Info.sectors;
if(!options.Verbose)
sb.AppendLine("Image 1 has more sectors");
if(!options.Verbose) sb.AppendLine("Image 1 has more sectors");
}
else
leastSectors = image1Info.sectors;
else leastSectors = image1Info.sectors;
DicConsole.WriteLine("Comparing sectors...");
@@ -436,25 +459,24 @@ namespace DiscImageChef.Commands
else if(!sameSize)
{
imagesDiffer = true;
sb.AppendFormat("Sector {0} has different sizes ({1} bytes in image 1, {2} in image 2) but are otherwise identical",
sector, image1Sector.LongLength, image2Sector.LongLength).AppendLine();
sb
.AppendFormat("Sector {0} has different sizes ({1} bytes in image 1, {2} in image 2) but are otherwise identical",
sector, image1Sector.LongLength, image2Sector.LongLength).AppendLine();
}
}
#pragma warning disable RECS0022 // A catch clause that catches System.Exception and has an empty body
catch { }
#pragma warning restore RECS0022 // A catch clause that catches System.Exception and has an empty body
}
DicConsole.WriteLine();
if(imagesDiffer)
sb.AppendLine("Images differ");
else
sb.AppendLine("Images do not differ");
if(imagesDiffer) sb.AppendLine("Images differ");
else sb.AppendLine("Images do not differ");
DicConsole.WriteLine(sb.ToString());
Core.Statistics.AddCommand("compare");
}
}
}
}

View File

@@ -71,6 +71,7 @@ namespace DiscImageChef.Commands
pressedKey = System.Console.ReadKey();
DicConsole.WriteLine();
}
Settings.Settings.Current.Stats.ShareStats = pressedKey.Key == ConsoleKey.Y;
pressedKey = new ConsoleKeyInfo();
@@ -80,6 +81,7 @@ namespace DiscImageChef.Commands
pressedKey = System.Console.ReadKey();
DicConsole.WriteLine();
}
Settings.Settings.Current.Stats.BenchmarkStats = pressedKey.Key == ConsoleKey.Y;
pressedKey = new ConsoleKeyInfo();
@@ -89,6 +91,7 @@ namespace DiscImageChef.Commands
pressedKey = System.Console.ReadKey();
DicConsole.WriteLine();
}
Settings.Settings.Current.Stats.CommandStats = pressedKey.Key == ConsoleKey.Y;
pressedKey = new ConsoleKeyInfo();
@@ -98,6 +101,7 @@ namespace DiscImageChef.Commands
pressedKey = System.Console.ReadKey();
DicConsole.WriteLine();
}
Settings.Settings.Current.Stats.DeviceStats = pressedKey.Key == ConsoleKey.Y;
pressedKey = new ConsoleKeyInfo();
@@ -107,6 +111,7 @@ namespace DiscImageChef.Commands
pressedKey = System.Console.ReadKey();
DicConsole.WriteLine();
}
Settings.Settings.Current.Stats.FilesystemStats = pressedKey.Key == ConsoleKey.Y;
pressedKey = new ConsoleKeyInfo();
@@ -116,6 +121,7 @@ namespace DiscImageChef.Commands
pressedKey = System.Console.ReadKey();
DicConsole.WriteLine();
}
Settings.Settings.Current.Stats.FilterStats = pressedKey.Key == ConsoleKey.Y;
pressedKey = new ConsoleKeyInfo();
@@ -125,6 +131,7 @@ namespace DiscImageChef.Commands
pressedKey = System.Console.ReadKey();
DicConsole.WriteLine();
}
Settings.Settings.Current.Stats.MediaImageStats = pressedKey.Key == ConsoleKey.Y;
pressedKey = new ConsoleKeyInfo();
@@ -134,6 +141,7 @@ namespace DiscImageChef.Commands
pressedKey = System.Console.ReadKey();
DicConsole.WriteLine();
}
Settings.Settings.Current.Stats.MediaScanStats = pressedKey.Key == ConsoleKey.Y;
pressedKey = new ConsoleKeyInfo();
@@ -143,6 +151,7 @@ namespace DiscImageChef.Commands
pressedKey = System.Console.ReadKey();
DicConsole.WriteLine();
}
Settings.Settings.Current.Stats.PartitionStats = pressedKey.Key == ConsoleKey.Y;
pressedKey = new ConsoleKeyInfo();
@@ -152,6 +161,7 @@ namespace DiscImageChef.Commands
pressedKey = System.Console.ReadKey();
DicConsole.WriteLine();
}
Settings.Settings.Current.Stats.MediaStats = pressedKey.Key == ConsoleKey.Y;
pressedKey = new ConsoleKeyInfo();
@@ -161,13 +171,12 @@ namespace DiscImageChef.Commands
pressedKey = System.Console.ReadKey();
DicConsole.WriteLine();
}
Settings.Settings.Current.Stats.VerifyStats = pressedKey.Key == ConsoleKey.Y;
}
else
Settings.Settings.Current.Stats = null;
else Settings.Settings.Current.Stats = null;
Settings.Settings.SaveSettings();
}
}
}
}

View File

@@ -54,7 +54,6 @@ namespace DiscImageChef.Commands
Sidecar.EndProgressEvent2 += Progress.EndProgress2;
Sidecar.UpdateStatusEvent += Progress.UpdateStatus;
Encoding encoding = null;
if(options.EncodingName != null)
@@ -62,8 +61,7 @@ namespace DiscImageChef.Commands
try
{
encoding = Claunia.Encoding.Encoding.GetEncoding(options.EncodingName);
if(options.Verbose)
DicConsole.VerboseWriteLine("Using encoding for {0}.", encoding.EncodingName);
if(options.Verbose) DicConsole.VerboseWriteLine("Using encoding for {0}.", encoding.EncodingName);
}
catch(ArgumentException)
{
@@ -104,9 +102,9 @@ namespace DiscImageChef.Commands
else
{
if(options.Verbose)
DicConsole.VerboseWriteLine("Image format identified by {0} ({1}).", _imageFormat.Name, _imageFormat.PluginUUID);
else
DicConsole.WriteLine("Image format identified by {0}.", _imageFormat.Name);
DicConsole.VerboseWriteLine("Image format identified by {0} ({1}).", _imageFormat.Name,
_imageFormat.PluginUUID);
else DicConsole.WriteLine("Image format identified by {0}.", _imageFormat.Name);
}
try
@@ -130,15 +128,18 @@ namespace DiscImageChef.Commands
Core.Statistics.AddMediaFormat(_imageFormat.GetImageFormat());
Core.Statistics.AddFilter(inputFilter.Name);
CICMMetadataType sidecar = Sidecar.Create(_imageFormat, options.InputFile, inputFilter.UUID, encoding);
CICMMetadataType sidecar =
Sidecar.Create(_imageFormat, options.InputFile, inputFilter.UUID, encoding);
DicConsole.WriteLine("Writing metadata sidecar");
FileStream xmlFs = new FileStream(Path.Combine(Path.GetDirectoryName(options.InputFile),
Path.GetFileNameWithoutExtension(options.InputFile) + ".cicm.xml"),
FileMode.CreateNew);
FileStream xmlFs =
new
FileStream(Path.Combine(Path.GetDirectoryName(options.InputFile), Path.GetFileNameWithoutExtension(options.InputFile) + ".cicm.xml"),
FileMode.CreateNew);
System.Xml.Serialization.XmlSerializer xmlSer = new System.Xml.Serialization.XmlSerializer(typeof(CICMMetadataType));
System.Xml.Serialization.XmlSerializer xmlSer =
new System.Xml.Serialization.XmlSerializer(typeof(CICMMetadataType));
xmlSer.Serialize(xmlFs, sidecar);
xmlFs.Close();
@@ -163,21 +164,23 @@ namespace DiscImageChef.Commands
foreach(string file in contents)
{
if(new FileInfo(file).Length % options.BlockSize == 0)
files.Add(file);
if(new FileInfo(file).Length % options.BlockSize == 0) files.Add(file);
}
files.Sort(StringComparer.CurrentCultureIgnoreCase);
CICMMetadataType sidecar = Sidecar.Create(Path.GetFileName(options.InputFile), files, options.BlockSize);
CICMMetadataType sidecar =
Sidecar.Create(Path.GetFileName(options.InputFile), files, options.BlockSize);
DicConsole.WriteLine("Writing metadata sidecar");
FileStream xmlFs = new FileStream(Path.Combine(Path.GetDirectoryName(options.InputFile),
Path.GetFileNameWithoutExtension(options.InputFile) + ".cicm.xml"),
FileMode.CreateNew);
FileStream xmlFs =
new
FileStream(Path.Combine(Path.GetDirectoryName(options.InputFile), Path.GetFileNameWithoutExtension(options.InputFile) + ".cicm.xml"),
FileMode.CreateNew);
System.Xml.Serialization.XmlSerializer xmlSer = new System.Xml.Serialization.XmlSerializer(typeof(CICMMetadataType));
System.Xml.Serialization.XmlSerializer xmlSer =
new System.Xml.Serialization.XmlSerializer(typeof(CICMMetadataType));
xmlSer.Serialize(xmlFs, sidecar);
xmlFs.Close();
@@ -190,5 +193,4 @@ namespace DiscImageChef.Commands
}
}
}
}
}

View File

@@ -82,133 +82,148 @@ namespace DiscImageChef.Commands
switch(tag)
{
case MediaTagType.SCSI_INQUIRY:
{
byte[] inquiry = inputFormat.ReadDiskTag(MediaTagType.SCSI_INQUIRY);
if(inquiry == null)
DicConsole.WriteLine("Error reading SCSI INQUIRY response from disc image");
else
{
byte[] inquiry = inputFormat.ReadDiskTag(MediaTagType.SCSI_INQUIRY);
if(inquiry == null)
DicConsole.WriteLine("Error reading SCSI INQUIRY response from disc image");
else
{
DicConsole.WriteLine("SCSI INQUIRY command response:");
DicConsole.WriteLine("================================================================================");
DicConsole.WriteLine(Decoders.SCSI.Inquiry.Prettify(inquiry));
DicConsole.WriteLine("================================================================================");
}
break;
DicConsole.WriteLine("SCSI INQUIRY command response:");
DicConsole
.WriteLine("================================================================================");
DicConsole.WriteLine(Decoders.SCSI.Inquiry.Prettify(inquiry));
DicConsole
.WriteLine("================================================================================");
}
break;
}
case MediaTagType.ATA_IDENTIFY:
{
byte[] identify = inputFormat.ReadDiskTag(MediaTagType.ATA_IDENTIFY);
if(identify == null)
DicConsole.WriteLine("Error reading ATA IDENTIFY DEVICE response from disc image");
else
{
byte[] identify = inputFormat.ReadDiskTag(MediaTagType.ATA_IDENTIFY);
if(identify == null)
DicConsole.WriteLine("Error reading ATA IDENTIFY DEVICE response from disc image");
else
{
DicConsole.WriteLine("ATA IDENTIFY DEVICE command response:");
DicConsole.WriteLine("================================================================================");
DicConsole.WriteLine(Decoders.ATA.Identify.Prettify(identify));
DicConsole.WriteLine("================================================================================");
}
break;
DicConsole.WriteLine("ATA IDENTIFY DEVICE command response:");
DicConsole
.WriteLine("================================================================================");
DicConsole.WriteLine(Decoders.ATA.Identify.Prettify(identify));
DicConsole
.WriteLine("================================================================================");
}
break;
}
case MediaTagType.ATAPI_IDENTIFY:
{
byte[] identify = inputFormat.ReadDiskTag(MediaTagType.ATAPI_IDENTIFY);
if(identify == null)
DicConsole
.WriteLine("Error reading ATA IDENTIFY PACKET DEVICE response from disc image");
else
{
byte[] identify = inputFormat.ReadDiskTag(MediaTagType.ATAPI_IDENTIFY);
if(identify == null)
DicConsole.WriteLine("Error reading ATA IDENTIFY PACKET DEVICE response from disc image");
else
{
DicConsole.WriteLine("ATA IDENTIFY PACKET DEVICE command response:");
DicConsole.WriteLine("================================================================================");
DicConsole.WriteLine(Decoders.ATA.Identify.Prettify(identify));
DicConsole.WriteLine("================================================================================");
}
break;
DicConsole.WriteLine("ATA IDENTIFY PACKET DEVICE command response:");
DicConsole
.WriteLine("================================================================================");
DicConsole.WriteLine(Decoders.ATA.Identify.Prettify(identify));
DicConsole
.WriteLine("================================================================================");
}
break;
}
case MediaTagType.CD_ATIP:
{
byte[] atip = inputFormat.ReadDiskTag(MediaTagType.CD_ATIP);
if(atip == null) DicConsole.WriteLine("Error reading CD ATIP from disc image");
else
{
byte[] atip = inputFormat.ReadDiskTag(MediaTagType.CD_ATIP);
if(atip == null)
DicConsole.WriteLine("Error reading CD ATIP from disc image");
else
{
DicConsole.WriteLine("CD ATIP:");
DicConsole.WriteLine("================================================================================");
DicConsole.WriteLine(Decoders.CD.ATIP.Prettify(atip));
DicConsole.WriteLine("================================================================================");
}
break;
DicConsole.WriteLine("CD ATIP:");
DicConsole
.WriteLine("================================================================================");
DicConsole.WriteLine(Decoders.CD.ATIP.Prettify(atip));
DicConsole
.WriteLine("================================================================================");
}
break;
}
case MediaTagType.CD_FullTOC:
{
byte[] fulltoc = inputFormat.ReadDiskTag(MediaTagType.CD_FullTOC);
if(fulltoc == null) DicConsole.WriteLine("Error reading CD full TOC from disc image");
else
{
byte[] fulltoc = inputFormat.ReadDiskTag(MediaTagType.CD_FullTOC);
if(fulltoc == null)
DicConsole.WriteLine("Error reading CD full TOC from disc image");
else
{
DicConsole.WriteLine("CD full TOC:");
DicConsole.WriteLine("================================================================================");
DicConsole.WriteLine(Decoders.CD.FullTOC.Prettify(fulltoc));
DicConsole.WriteLine("================================================================================");
}
break;
DicConsole.WriteLine("CD full TOC:");
DicConsole
.WriteLine("================================================================================");
DicConsole.WriteLine(Decoders.CD.FullTOC.Prettify(fulltoc));
DicConsole
.WriteLine("================================================================================");
}
break;
}
case MediaTagType.CD_PMA:
{
byte[] pma = inputFormat.ReadDiskTag(MediaTagType.CD_PMA);
if(pma == null) DicConsole.WriteLine("Error reading CD PMA from disc image");
else
{
byte[] pma = inputFormat.ReadDiskTag(MediaTagType.CD_PMA);
if(pma == null)
DicConsole.WriteLine("Error reading CD PMA from disc image");
else
{
DicConsole.WriteLine("CD PMA:");
DicConsole.WriteLine("================================================================================");
DicConsole.WriteLine(Decoders.CD.PMA.Prettify(pma));
DicConsole.WriteLine("================================================================================");
}
break;
DicConsole.WriteLine("CD PMA:");
DicConsole
.WriteLine("================================================================================");
DicConsole.WriteLine(Decoders.CD.PMA.Prettify(pma));
DicConsole
.WriteLine("================================================================================");
}
break;
}
case MediaTagType.CD_SessionInfo:
{
byte[] sessioninfo = inputFormat.ReadDiskTag(MediaTagType.CD_SessionInfo);
if(sessioninfo == null)
DicConsole.WriteLine("Error reading CD session information from disc image");
else
{
byte[] sessioninfo = inputFormat.ReadDiskTag(MediaTagType.CD_SessionInfo);
if(sessioninfo == null)
DicConsole.WriteLine("Error reading CD session information from disc image");
else
{
DicConsole.WriteLine("CD session information:");
DicConsole.WriteLine("================================================================================");
DicConsole.WriteLine(Decoders.CD.Session.Prettify(sessioninfo));
DicConsole.WriteLine("================================================================================");
}
break;
DicConsole.WriteLine("CD session information:");
DicConsole
.WriteLine("================================================================================");
DicConsole.WriteLine(Decoders.CD.Session.Prettify(sessioninfo));
DicConsole
.WriteLine("================================================================================");
}
break;
}
case MediaTagType.CD_TEXT:
{
byte[] cdtext = inputFormat.ReadDiskTag(MediaTagType.CD_TEXT);
if(cdtext == null) DicConsole.WriteLine("Error reading CD-TEXT from disc image");
else
{
byte[] cdtext = inputFormat.ReadDiskTag(MediaTagType.CD_TEXT);
if(cdtext == null)
DicConsole.WriteLine("Error reading CD-TEXT from disc image");
else
{
DicConsole.WriteLine("CD-TEXT:");
DicConsole.WriteLine("================================================================================");
DicConsole.WriteLine(Decoders.CD.CDTextOnLeadIn.Prettify(cdtext));
DicConsole.WriteLine("================================================================================");
}
break;
DicConsole.WriteLine("CD-TEXT:");
DicConsole
.WriteLine("================================================================================");
DicConsole.WriteLine(Decoders.CD.CDTextOnLeadIn.Prettify(cdtext));
DicConsole
.WriteLine("================================================================================");
}
break;
}
case MediaTagType.CD_TOC:
{
byte[] toc = inputFormat.ReadDiskTag(MediaTagType.CD_TOC);
if(toc == null) DicConsole.WriteLine("Error reading CD TOC from disc image");
else
{
byte[] toc = inputFormat.ReadDiskTag(MediaTagType.CD_TOC);
if(toc == null)
DicConsole.WriteLine("Error reading CD TOC from disc image");
else
{
DicConsole.WriteLine("CD TOC:");
DicConsole.WriteLine("================================================================================");
DicConsole.WriteLine(Decoders.CD.TOC.Prettify(toc));
DicConsole.WriteLine("================================================================================");
}
break;
DicConsole.WriteLine("CD TOC:");
DicConsole
.WriteLine("================================================================================");
DicConsole.WriteLine(Decoders.CD.TOC.Prettify(toc));
DicConsole
.WriteLine("================================================================================");
}
break;
}
default:
DicConsole.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;
}
}
@@ -219,8 +234,7 @@ namespace DiscImageChef.Commands
{
ulong length;
if(options.Length.ToLowerInvariant() == "all")
length = inputFormat.GetSectors() - 1;
if(options.Length.ToLowerInvariant() == "all") length = inputFormat.GetSectors() - 1;
else
{
if(!ulong.TryParse(options.Length, out length))
@@ -240,7 +254,8 @@ namespace DiscImageChef.Commands
switch(tag)
{
default:
DicConsole.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;
}
}
@@ -250,5 +265,4 @@ namespace DiscImageChef.Commands
Core.Statistics.AddCommand("decode");
}
}
}
}

File diff suppressed because it is too large Load Diff

View File

@@ -46,8 +46,8 @@ namespace DiscImageChef.Commands
DicConsole.DebugWriteLine("Device-Report command", "--verbose={0}", options.Verbose);
DicConsole.DebugWriteLine("Device-Report command", "--device={0}", options.DevicePath);
if(options.DevicePath.Length == 2 && options.DevicePath[1] == ':' &&
options.DevicePath[0] != '/' && char.IsLetter(options.DevicePath[0]))
if(options.DevicePath.Length == 2 && options.DevicePath[1] == ':' && options.DevicePath[0] != '/' &&
char.IsLetter(options.DevicePath[0]))
{
options.DevicePath = "\\\\.\\" + char.ToUpper(options.DevicePath[0]) + ':';
}
@@ -67,12 +67,9 @@ namespace DiscImageChef.Commands
string xmlFile;
if(!string.IsNullOrWhiteSpace(dev.Manufacturer) && !string.IsNullOrWhiteSpace(dev.Revision))
xmlFile = dev.Manufacturer + "_" + dev.Model + "_" + dev.Revision + ".xml";
else if(!string.IsNullOrWhiteSpace(dev.Manufacturer))
xmlFile = dev.Manufacturer + "_" + dev.Model + ".xml";
else if(!string.IsNullOrWhiteSpace(dev.Revision))
xmlFile = dev.Model + "_" + dev.Revision + ".xml";
else
xmlFile = dev.Model + ".xml";
else if(!string.IsNullOrWhiteSpace(dev.Manufacturer)) xmlFile = dev.Manufacturer + "_" + dev.Model + ".xml";
else if(!string.IsNullOrWhiteSpace(dev.Revision)) xmlFile = dev.Model + "_" + dev.Revision + ".xml";
else xmlFile = dev.Model + ".xml";
xmlFile = xmlFile.Replace('\\', '_').Replace('/', '_').Replace('?', '_');
@@ -92,22 +89,18 @@ namespace DiscImageChef.Commands
case DeviceType.SCSI:
Core.Devices.Report.SCSI.General.Report(dev, ref report, options.Debug, ref removable);
break;
default:
throw new NotSupportedException("Unknown device type.");
default: throw new NotSupportedException("Unknown device type.");
}
FileStream xmlFs = new FileStream(xmlFile, FileMode.Create);
System.Xml.Serialization.XmlSerializer xmlSer = new System.Xml.Serialization.XmlSerializer(typeof(Metadata.DeviceReport));
System.Xml.Serialization.XmlSerializer xmlSer =
new System.Xml.Serialization.XmlSerializer(typeof(Metadata.DeviceReport));
xmlSer.Serialize(xmlFs, report);
xmlFs.Close();
Core.Statistics.AddCommand("device-report");
if(Settings.Settings.Current.ShareReports)
{
Remote.SubmitReport(report);
}
if(Settings.Settings.Current.ShareReports) { Remote.SubmitReport(report); }
}
}
}
}

View File

@@ -67,8 +67,7 @@ namespace DiscImageChef.Commands
try
{
encoding = Claunia.Encoding.Encoding.GetEncoding(options.EncodingName);
if(options.Verbose)
DicConsole.VerboseWriteLine("Using encoding for {0}.", encoding.EncodingName);
if(options.Verbose) DicConsole.VerboseWriteLine("Using encoding for {0}.", encoding.EncodingName);
}
catch(ArgumentException)
{
@@ -78,8 +77,8 @@ namespace DiscImageChef.Commands
}
}
if(options.DevicePath.Length == 2 && options.DevicePath[1] == ':' &&
options.DevicePath[0] != '/' && char.IsLetter(options.DevicePath[0]))
if(options.DevicePath.Length == 2 && options.DevicePath[1] == ':' && options.DevicePath[0] != '/' &&
char.IsLetter(options.DevicePath[0]))
{
options.DevicePath = "\\\\.\\" + char.ToUpper(options.DevicePath[0]) + ':';
}
@@ -122,18 +121,24 @@ namespace DiscImageChef.Commands
switch(dev.Type)
{
case DeviceType.ATA:
ATA.Dump(dev, options.DevicePath, options.OutputPrefix, options.RetryPasses, options.Force, options.Raw, options.Persistent, options.StopOnError, ref resume, ref dumpLog, encoding);
ATA.Dump(dev, options.DevicePath, options.OutputPrefix, options.RetryPasses, options.Force,
options.Raw, options.Persistent, options.StopOnError, ref resume, ref dumpLog, encoding);
break;
case DeviceType.MMC:
case DeviceType.SecureDigital:
SecureDigital.Dump(dev, options.DevicePath, options.OutputPrefix, options.RetryPasses, options.Force, options.Raw, options.Persistent, options.StopOnError, ref resume, ref dumpLog, encoding);
SecureDigital.Dump(dev, options.DevicePath, options.OutputPrefix, options.RetryPasses,
options.Force, options.Raw, options.Persistent, options.StopOnError, ref resume,
ref dumpLog, encoding);
break;
case DeviceType.NVMe:
NVMe.Dump(dev, options.DevicePath, options.OutputPrefix, options.RetryPasses, options.Force, options.Raw, options.Persistent, options.StopOnError, ref resume, ref dumpLog, encoding);
NVMe.Dump(dev, options.DevicePath, options.OutputPrefix, options.RetryPasses, options.Force,
options.Raw, options.Persistent, options.StopOnError, ref resume, ref dumpLog, encoding);
break;
case DeviceType.ATAPI:
case DeviceType.SCSI:
SCSI.Dump(dev, options.DevicePath, options.OutputPrefix, options.RetryPasses, options.Force, options.Raw, options.Persistent, options.StopOnError, options.SeparateSubchannel, ref resume, ref dumpLog, options.LeadIn, encoding);
SCSI.Dump(dev, options.DevicePath, options.OutputPrefix, options.RetryPasses, options.Force,
options.Raw, options.Persistent, options.StopOnError, options.SeparateSubchannel,
ref resume, ref dumpLog, options.LeadIn, encoding);
break;
default:
dumpLog.WriteLine("Unknown device type.");
@@ -146,10 +151,10 @@ namespace DiscImageChef.Commands
resume.LastWriteDate = DateTime.UtcNow;
resume.BadBlocks.Sort();
if(File.Exists(options.OutputPrefix + ".resume.xml"))
File.Delete(options.OutputPrefix + ".resume.xml");
if(File.Exists(options.OutputPrefix + ".resume.xml")) File.Delete(options.OutputPrefix + ".resume.xml");
FileStream fs = new FileStream(options.OutputPrefix + ".resume.xml", FileMode.Create, FileAccess.ReadWrite);
FileStream fs = new FileStream(options.OutputPrefix + ".resume.xml", FileMode.Create,
FileAccess.ReadWrite);
xs = new XmlSerializer(resume.GetType());
xs.Serialize(fs, resume);
fs.Close();

View File

@@ -98,12 +98,10 @@ namespace DiscImageChef.Commands
{
byte[] garbage;
string sectorHash = sha1ctxTrack.Data(sector, out garbage);
if(!uniqueSectorsPerTrack.Contains(sectorHash))
uniqueSectorsPerTrack.Add(sectorHash);
if(!uniqueSectorsPerTrack.Contains(sectorHash)) uniqueSectorsPerTrack.Add(sectorHash);
}
foreach(byte b in sector)
entTable[b]++;
foreach(byte b in sector) entTable[b]++;
trackSize += (ulong)sector.LongLength;
}
@@ -121,7 +119,9 @@ namespace DiscImageChef.Commands
#pragma warning disable IDE0004 // Cast is necessary, otherwise incorrect value is created
if(options.DuplicatedSectors)
DicConsole.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);
#pragma warning restore IDE0004 // Cast is necessary, otherwise incorrect value is created
DicConsole.WriteLine();
@@ -129,14 +129,11 @@ namespace DiscImageChef.Commands
}
catch(Exception ex)
{
if(options.Debug)
DicConsole.DebugWriteLine("Could not get tracks because {0}", ex.Message);
else
DicConsole.ErrorWriteLine("Unable to get separate tracks, not calculating their entropy");
if(options.Debug) DicConsole.DebugWriteLine("Could not get tracks because {0}", ex.Message);
else DicConsole.ErrorWriteLine("Unable to get separate tracks, not calculating their entropy");
}
}
if(options.WholeDisc)
{
SHA1Context sha1Ctx = new SHA1Context();
@@ -158,15 +155,12 @@ namespace DiscImageChef.Commands
{
byte[] garbage;
string sectorHash = sha1Ctx.Data(sector, out garbage);
if(!uniqueSectors.Contains(sectorHash))
uniqueSectors.Add(sectorHash);
if(!uniqueSectors.Contains(sectorHash)) uniqueSectors.Add(sectorHash);
}
foreach(byte b in sector)
entTable[b]++;
foreach(byte b in sector) entTable[b]++;
diskSize += (ulong)sector.LongLength;
}
double entropy = 0;
@@ -184,12 +178,12 @@ namespace DiscImageChef.Commands
if(options.DuplicatedSectors)
#pragma warning disable IDE0004 // Cast is necessary, otherwise incorrect value is created
DicConsole.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);
#pragma warning restore IDE0004 // Cast is necessary, otherwise incorrect value is created
Core.Statistics.AddCommand("entropy");
}
}
}
}
}

View File

@@ -70,8 +70,7 @@ namespace DiscImageChef.Commands
try
{
encoding = Claunia.Encoding.Encoding.GetEncoding(options.EncodingName);
if(options.Verbose)
DicConsole.VerboseWriteLine("Using encoding for {0}.", encoding.EncodingName);
if(options.Verbose) DicConsole.VerboseWriteLine("Using encoding for {0}.", encoding.EncodingName);
}
catch(ArgumentException)
{
@@ -101,9 +100,9 @@ namespace DiscImageChef.Commands
else
{
if(options.Verbose)
DicConsole.VerboseWriteLine("Image format identified by {0} ({1}).", _imageFormat.Name, _imageFormat.PluginUUID);
else
DicConsole.WriteLine("Image format identified by {0}.", _imageFormat.Name);
DicConsole.VerboseWriteLine("Image format identified by {0} ({1}).", _imageFormat.Name,
_imageFormat.PluginUUID);
else DicConsole.WriteLine("Image format identified by {0}.", _imageFormat.Name);
}
if(Directory.Exists(options.OutputDir) || File.Exists(options.OutputDir))
@@ -124,9 +123,12 @@ namespace DiscImageChef.Commands
}
DicConsole.DebugWriteLine("Extract-Files command", "Correctly opened image file.");
DicConsole.DebugWriteLine("Extract-Files command", "Image without headers is {0} bytes.", _imageFormat.GetImageSize());
DicConsole.DebugWriteLine("Extract-Files command", "Image has {0} sectors.", _imageFormat.GetSectors());
DicConsole.DebugWriteLine("Extract-Files command", "Image identifies disk type as {0}.", _imageFormat.GetMediaType());
DicConsole.DebugWriteLine("Extract-Files command", "Image without headers is {0} bytes.",
_imageFormat.GetImageSize());
DicConsole.DebugWriteLine("Extract-Files command", "Image has {0} sectors.",
_imageFormat.GetSectors());
DicConsole.DebugWriteLine("Extract-Files command", "Image identifies disk type as {0}.",
_imageFormat.GetMediaType());
Core.Statistics.AddMediaFormat(_imageFormat.GetImageFormat());
Core.Statistics.AddMedia(_imageFormat.ImageInfo.mediaType, false);
@@ -142,8 +144,7 @@ namespace DiscImageChef.Commands
List<Partition> partitions = Partitions.GetAll(_imageFormat);
Partitions.AddSchemesToStats(partitions);
if(partitions.Count == 0)
DicConsole.DebugWriteLine("Extract-Files command", "No partitions found");
if(partitions.Count == 0) DicConsole.DebugWriteLine("Extract-Files command", "No partitions found");
else
{
DicConsole.WriteLine("{0} partitions found.", partitions.Count);
@@ -156,8 +157,7 @@ namespace DiscImageChef.Commands
DicConsole.WriteLine("Identifying filesystem on partition");
Core.Filesystems.Identify(_imageFormat, out id_plugins, partitions[i]);
if(id_plugins.Count == 0)
DicConsole.WriteLine("Filesystem not identified");
if(id_plugins.Count == 0) DicConsole.WriteLine("Filesystem not identified");
else if(id_plugins.Count > 1)
{
DicConsole.WriteLine(string.Format("Identified by {0} plugins", id_plugins.Count));
@@ -167,7 +167,11 @@ namespace DiscImageChef.Commands
if(plugins.PluginsList.TryGetValue(plugin_name, out _plugin))
{
DicConsole.WriteLine(string.Format("As identified by {0}.", _plugin.Name));
Filesystem fs = (Filesystem)_plugin.GetType().GetConstructor(new Type[] { typeof(ImagePlugin), typeof(Partition), typeof(System.Text.Encoding) }).Invoke(new object[] { _imageFormat, partitions[i], null });
Filesystem fs = (Filesystem)_plugin
.GetType().GetConstructor(new Type[]
{
typeof(ImagePlugin), typeof(Partition), typeof(System.Text.Encoding)
}).Invoke(new object[] {_imageFormat, partitions[i], null});
error = fs.Mount(options.Debug);
if(error == Errno.NoError)
@@ -185,8 +189,7 @@ namespace DiscImageChef.Commands
string volumeName;
if(string.IsNullOrEmpty(fs.XmlFSType.VolumeName))
volumeName = "NO NAME";
else
volumeName = fs.XmlFSType.VolumeName;
else volumeName = fs.XmlFSType.VolumeName;
error = fs.Stat(entry, ref stat);
if(error == Errno.NoError)
@@ -204,25 +207,25 @@ namespace DiscImageChef.Commands
error = fs.GetXattr(entry, xattr, ref xattrBuf);
if(error == Errno.NoError)
{
Directory.CreateDirectory(Path.Combine(
options.OutputDir,
fs.XmlFSType.Type,
volumeName,
".xattrs",
xattr));
Directory
.CreateDirectory(Path.Combine(options.OutputDir,
fs.XmlFSType.Type,
volumeName,
".xattrs",
xattr));
outputPath = Path.Combine(options.OutputDir,
fs.XmlFSType.Type,
volumeName,
".xattrs",
xattr,
entry);
outputPath =
Path.Combine(options.OutputDir,
fs.XmlFSType.Type, volumeName,
".xattrs", xattr, entry);
if(!File.Exists(outputPath))
{
outputFile = new FileStream(outputPath,
FileMode.CreateNew, FileAccess.ReadWrite,
FileShare.None);
outputFile =
new FileStream(outputPath,
FileMode.CreateNew,
FileAccess.ReadWrite,
FileShare.None);
outputFile.Write(xattrBuf, 0, xattrBuf.Length);
outputFile.Close();
FileInfo fi = new FileInfo(outputPath);
@@ -231,46 +234,39 @@ namespace DiscImageChef.Commands
{
fi.CreationTimeUtc = stat.CreationTimeUtc;
}
catch
{
}
catch { }
try
{
fi.LastWriteTimeUtc = stat.LastWriteTimeUtc;
}
catch
{
}
catch { }
try
{
fi.LastAccessTimeUtc = stat.AccessTimeUtc;
}
catch
{
}
catch { }
#pragma warning restore RECS0022 // A catch clause that catches System.Exception and has an empty body
DicConsole.WriteLine(
"Written {0} bytes of xattr {1} from file {2} to {3}",
xattrBuf.Length, xattr, entry, outputPath);
DicConsole
.WriteLine("Written {0} bytes of xattr {1} from file {2} to {3}",
xattrBuf.Length, xattr, entry,
outputPath);
}
else
DicConsole.ErrorWriteLine(
"Cannot write xattr {0} for {1}, output exists",
xattr, entry);
DicConsole
.ErrorWriteLine("Cannot write xattr {0} for {1}, output exists",
xattr, entry);
}
}
}
}
Directory.CreateDirectory(Path.Combine(options.OutputDir,
fs.XmlFSType.Type,
volumeName));
fs.XmlFSType.Type,
volumeName));
outputPath = Path.Combine(options.OutputDir,
fs.XmlFSType.Type,
volumeName,
entry);
outputPath =
Path.Combine(options.OutputDir, fs.XmlFSType.Type, volumeName,
entry);
if(!File.Exists(outputPath))
{
@@ -280,57 +276,44 @@ namespace DiscImageChef.Commands
if(error == Errno.NoError)
{
outputFile = new FileStream(outputPath, FileMode.CreateNew,
FileAccess.ReadWrite,
FileShare.None);
outputFile =
new FileStream(outputPath, FileMode.CreateNew,
FileAccess.ReadWrite, FileShare.None);
outputFile.Write(outBuf, 0, outBuf.Length);
outputFile.Close();
FileInfo fi = new FileInfo(outputPath);
#pragma warning disable RECS0022 // A catch clause that catches System.Exception and has an empty body
try
{
fi.CreationTimeUtc = stat.CreationTimeUtc;
}
catch
{
}
try
{
fi.LastWriteTimeUtc = stat.LastWriteTimeUtc;
}
catch
{
}
try
{
fi.LastAccessTimeUtc = stat.AccessTimeUtc;
}
catch
{
}
try { fi.CreationTimeUtc = stat.CreationTimeUtc; }
catch { }
try { fi.LastWriteTimeUtc = stat.LastWriteTimeUtc; }
catch { }
try { fi.LastAccessTimeUtc = stat.AccessTimeUtc; }
catch { }
#pragma warning restore RECS0022 // A catch clause that catches System.Exception and has an empty body
DicConsole.WriteLine("Written {0} bytes of file {1} to {2}",
outBuf.Length, entry, outputPath);
outBuf.Length, entry, outputPath);
}
else
DicConsole.ErrorWriteLine("Error {0} reading file {1}",
error, entry);
error, entry);
}
else
DicConsole.ErrorWriteLine(
"Cannot write file {0}, output exists", entry);
DicConsole
.ErrorWriteLine("Cannot write file {0}, output exists",
entry);
}
else
DicConsole.ErrorWriteLine("Error reading file {0}", entry);
else DicConsole.ErrorWriteLine("Error reading file {0}", entry);
}
}
else
DicConsole.ErrorWriteLine("Error {0} reading root directory {0}", error.ToString());
DicConsole.ErrorWriteLine("Error {0} reading root directory {0}",
error.ToString());
Core.Statistics.AddFilesystem(fs.XmlFSType.Type);
}
else
DicConsole.ErrorWriteLine("Unable to mount device, error {0}", error.ToString());
DicConsole.ErrorWriteLine("Unable to mount device, error {0}",
error.ToString());
}
}
}
@@ -338,7 +321,11 @@ namespace DiscImageChef.Commands
{
plugins.PluginsList.TryGetValue(id_plugins[0], out _plugin);
DicConsole.WriteLine(string.Format("Identified by {0}.", _plugin.Name));
Filesystem fs = (Filesystem)_plugin.GetType().GetConstructor(new Type[] { typeof(ImagePlugin), typeof(Partition), typeof(System.Text.Encoding) }).Invoke(new object[] { _imageFormat, partitions[i], null });
Filesystem fs = (Filesystem)_plugin
.GetType().GetConstructor(new Type[]
{
typeof(ImagePlugin), typeof(Partition), typeof(System.Text.Encoding)
}).Invoke(new object[] {_imageFormat, partitions[i], null});
error = fs.Mount(options.Debug);
if(error == Errno.NoError)
{
@@ -353,10 +340,8 @@ namespace DiscImageChef.Commands
FileStream outputFile;
string volumeName;
if(string.IsNullOrEmpty(fs.XmlFSType.VolumeName))
volumeName = "NO NAME";
else
volumeName = fs.XmlFSType.VolumeName;
if(string.IsNullOrEmpty(fs.XmlFSType.VolumeName)) volumeName = "NO NAME";
else volumeName = fs.XmlFSType.VolumeName;
error = fs.Stat(entry, ref stat);
if(error == Errno.NoError)
@@ -375,71 +360,50 @@ namespace DiscImageChef.Commands
if(error == Errno.NoError)
{
Directory.CreateDirectory(Path.Combine(options.OutputDir,
fs.XmlFSType.Type,
volumeName,
".xattrs",
xattr));
fs.XmlFSType.Type,
volumeName,
".xattrs", xattr));
outputPath = Path.Combine(options.OutputDir,
fs.XmlFSType.Type,
volumeName,
".xattrs",
xattr,
entry);
outputPath =
Path.Combine(options.OutputDir, fs.XmlFSType.Type,
volumeName, ".xattrs", xattr, entry);
if(!File.Exists(outputPath))
{
outputFile = new FileStream(outputPath,
FileMode.CreateNew, FileAccess.ReadWrite,
FileShare.None);
outputFile =
new FileStream(outputPath, FileMode.CreateNew,
FileAccess.ReadWrite,
FileShare.None);
outputFile.Write(xattrBuf, 0, xattrBuf.Length);
outputFile.Close();
FileInfo fi = new FileInfo(outputPath);
#pragma warning disable RECS0022 // A catch clause that catches System.Exception and has an empty body
try
{
fi.CreationTimeUtc = stat.CreationTimeUtc;
}
catch
{
}
try
{
fi.LastWriteTimeUtc = stat.LastWriteTimeUtc;
}
catch
{
}
try
{
fi.LastAccessTimeUtc = stat.AccessTimeUtc;
}
catch
{
}
try { fi.CreationTimeUtc = stat.CreationTimeUtc; }
catch { }
try { fi.LastWriteTimeUtc = stat.LastWriteTimeUtc; }
catch { }
try { fi.LastAccessTimeUtc = stat.AccessTimeUtc; }
catch { }
#pragma warning restore RECS0022 // A catch clause that catches System.Exception and has an empty body
DicConsole.WriteLine(
"Written {0} bytes of xattr {1} from file {2} to {3}",
xattrBuf.Length, xattr, entry, outputPath);
DicConsole
.WriteLine("Written {0} bytes of xattr {1} from file {2} to {3}",
xattrBuf.Length, xattr, entry,
outputPath);
}
else
DicConsole.ErrorWriteLine(
"Cannot write xattr {0} for {1}, output exists",
xattr, entry);
DicConsole
.ErrorWriteLine("Cannot write xattr {0} for {1}, output exists",
xattr, entry);
}
}
}
}
Directory.CreateDirectory(Path.Combine(options.OutputDir,
fs.XmlFSType.Type,
volumeName));
Directory.CreateDirectory(Path.Combine(options.OutputDir, fs.XmlFSType.Type,
volumeName));
outputPath = Path.Combine(options.OutputDir,
fs.XmlFSType.Type,
volumeName,
entry);
outputPath =
Path.Combine(options.OutputDir, fs.XmlFSType.Type, volumeName, entry);
if(!File.Exists(outputPath))
{
@@ -449,48 +413,32 @@ namespace DiscImageChef.Commands
if(error == Errno.NoError)
{
outputFile = new FileStream(outputPath, FileMode.CreateNew,
FileAccess.ReadWrite,
FileShare.None);
outputFile =
new FileStream(outputPath, FileMode.CreateNew,
FileAccess.ReadWrite, FileShare.None);
outputFile.Write(outBuf, 0, outBuf.Length);
outputFile.Close();
FileInfo fi = new FileInfo(outputPath);
#pragma warning disable RECS0022 // A catch clause that catches System.Exception and has an empty body
try
{
fi.CreationTimeUtc = stat.CreationTimeUtc;
}
catch
{
}
try
{
fi.LastWriteTimeUtc = stat.LastWriteTimeUtc;
}
catch
{
}
try
{
fi.LastAccessTimeUtc = stat.AccessTimeUtc;
}
catch
{
}
try { fi.CreationTimeUtc = stat.CreationTimeUtc; }
catch { }
try { fi.LastWriteTimeUtc = stat.LastWriteTimeUtc; }
catch { }
try { fi.LastAccessTimeUtc = stat.AccessTimeUtc; }
catch { }
#pragma warning restore RECS0022 // A catch clause that catches System.Exception and has an empty body
DicConsole.WriteLine("Written {0} bytes of file {1} to {2}",
outBuf.Length, entry, outputPath);
outBuf.Length, entry, outputPath);
}
else
DicConsole.ErrorWriteLine("Error {0} reading file {1}", error,
entry);
entry);
}
else
DicConsole.ErrorWriteLine("Cannot write file {0}, output exists",
entry);
entry);
}
else
DicConsole.ErrorWriteLine("Error reading file {0}", entry);
else DicConsole.ErrorWriteLine("Error reading file {0}", entry);
}
}
else
@@ -498,8 +446,7 @@ namespace DiscImageChef.Commands
Core.Statistics.AddFilesystem(fs.XmlFSType.Type);
}
else
DicConsole.ErrorWriteLine("Unable to mount device, error {0}", error.ToString());
else DicConsole.ErrorWriteLine("Unable to mount device, error {0}", error.ToString());
}
}
}
@@ -512,8 +459,7 @@ namespace DiscImageChef.Commands
};
Core.Filesystems.Identify(_imageFormat, out id_plugins, wholePart);
if(id_plugins.Count == 0)
DicConsole.WriteLine("Filesystem not identified");
if(id_plugins.Count == 0) DicConsole.WriteLine("Filesystem not identified");
else if(id_plugins.Count > 1)
{
DicConsole.WriteLine(string.Format("Identified by {0} plugins", id_plugins.Count));
@@ -523,7 +469,11 @@ namespace DiscImageChef.Commands
if(plugins.PluginsList.TryGetValue(plugin_name, out _plugin))
{
DicConsole.WriteLine(string.Format("As identified by {0}.", _plugin.Name));
Filesystem fs = (Filesystem)_plugin.GetType().GetConstructor(new Type[] { typeof(ImagePlugin), typeof(Partition), typeof(System.Text.Encoding) }).Invoke(new object[] { _imageFormat, wholePart, null });
Filesystem fs = (Filesystem)_plugin
.GetType().GetConstructor(new Type[]
{
typeof(ImagePlugin), typeof(Partition), typeof(System.Text.Encoding)
}).Invoke(new object[] {_imageFormat, wholePart, null});
error = fs.Mount(options.Debug);
if(error == Errno.NoError)
{
@@ -538,10 +488,8 @@ namespace DiscImageChef.Commands
FileStream outputFile;
string volumeName;
if(string.IsNullOrEmpty(fs.XmlFSType.VolumeName))
volumeName = "NO NAME";
else
volumeName = fs.XmlFSType.VolumeName;
if(string.IsNullOrEmpty(fs.XmlFSType.VolumeName)) volumeName = "NO NAME";
else volumeName = fs.XmlFSType.VolumeName;
error = fs.Stat(entry, ref stat);
if(error == Errno.NoError)
@@ -560,71 +508,50 @@ namespace DiscImageChef.Commands
if(error == Errno.NoError)
{
Directory.CreateDirectory(Path.Combine(options.OutputDir,
fs.XmlFSType.Type,
volumeName,
".xattrs",
xattr));
fs.XmlFSType.Type,
volumeName,
".xattrs", xattr));
outputPath = Path.Combine(options.OutputDir,
fs.XmlFSType.Type,
volumeName,
".xattrs",
xattr,
entry);
outputPath =
Path.Combine(options.OutputDir, fs.XmlFSType.Type,
volumeName, ".xattrs", xattr, entry);
if(!File.Exists(outputPath))
{
outputFile = new FileStream(outputPath,
FileMode.CreateNew, FileAccess.ReadWrite,
FileShare.None);
outputFile =
new FileStream(outputPath, FileMode.CreateNew,
FileAccess.ReadWrite,
FileShare.None);
outputFile.Write(xattrBuf, 0, xattrBuf.Length);
outputFile.Close();
FileInfo fi = new FileInfo(outputPath);
#pragma warning disable RECS0022 // A catch clause that catches System.Exception and has an empty body
try
{
fi.CreationTimeUtc = stat.CreationTimeUtc;
}
catch
{
}
try
{
fi.LastWriteTimeUtc = stat.LastWriteTimeUtc;
}
catch
{
}
try
{
fi.LastAccessTimeUtc = stat.AccessTimeUtc;
}
catch
{
}
try { fi.CreationTimeUtc = stat.CreationTimeUtc; }
catch { }
try { fi.LastWriteTimeUtc = stat.LastWriteTimeUtc; }
catch { }
try { fi.LastAccessTimeUtc = stat.AccessTimeUtc; }
catch { }
#pragma warning restore RECS0022 // A catch clause that catches System.Exception and has an empty body
DicConsole.WriteLine(
"Written {0} bytes of xattr {1} from file {2} to {3}",
xattrBuf.Length, xattr, entry, outputPath);
DicConsole
.WriteLine("Written {0} bytes of xattr {1} from file {2} to {3}",
xattrBuf.Length, xattr, entry,
outputPath);
}
else
DicConsole.ErrorWriteLine(
"Cannot write xattr {0} for {1}, output exists",
xattr, entry);
DicConsole
.ErrorWriteLine("Cannot write xattr {0} for {1}, output exists",
xattr, entry);
}
}
}
}
Directory.CreateDirectory(Path.Combine(options.OutputDir,
fs.XmlFSType.Type,
volumeName));
Directory.CreateDirectory(Path.Combine(options.OutputDir, fs.XmlFSType.Type,
volumeName));
outputPath = Path.Combine(options.OutputDir,
fs.XmlFSType.Type,
volumeName,
entry);
outputPath =
Path.Combine(options.OutputDir, fs.XmlFSType.Type, volumeName, entry);
if(!File.Exists(outputPath))
{
@@ -634,48 +561,32 @@ namespace DiscImageChef.Commands
if(error == Errno.NoError)
{
outputFile = new FileStream(outputPath, FileMode.CreateNew,
FileAccess.ReadWrite,
FileShare.None);
outputFile =
new FileStream(outputPath, FileMode.CreateNew,
FileAccess.ReadWrite, FileShare.None);
outputFile.Write(outBuf, 0, outBuf.Length);
outputFile.Close();
FileInfo fi = new FileInfo(outputPath);
#pragma warning disable RECS0022 // A catch clause that catches System.Exception and has an empty body
try
{
fi.CreationTimeUtc = stat.CreationTimeUtc;
}
catch
{
}
try
{
fi.LastWriteTimeUtc = stat.LastWriteTimeUtc;
}
catch
{
}
try
{
fi.LastAccessTimeUtc = stat.AccessTimeUtc;
}
catch
{
}
try { fi.CreationTimeUtc = stat.CreationTimeUtc; }
catch { }
try { fi.LastWriteTimeUtc = stat.LastWriteTimeUtc; }
catch { }
try { fi.LastAccessTimeUtc = stat.AccessTimeUtc; }
catch { }
#pragma warning restore RECS0022 // A catch clause that catches System.Exception and has an empty body
DicConsole.WriteLine("Written {0} bytes of file {1} to {2}",
outBuf.Length, entry, outputPath);
outBuf.Length, entry, outputPath);
}
else
DicConsole.ErrorWriteLine("Error {0} reading file {1}", error,
entry);
entry);
}
else
DicConsole.ErrorWriteLine("Cannot write file {0}, output exists",
entry);
entry);
}
else
DicConsole.ErrorWriteLine("Error reading file {0}", entry);
else DicConsole.ErrorWriteLine("Error reading file {0}", entry);
}
}
else
@@ -683,8 +594,7 @@ namespace DiscImageChef.Commands
Core.Statistics.AddFilesystem(fs.XmlFSType.Type);
}
else
DicConsole.ErrorWriteLine("Unable to mount device, error {0}", error.ToString());
else DicConsole.ErrorWriteLine("Unable to mount device, error {0}", error.ToString());
}
}
}
@@ -692,7 +602,11 @@ namespace DiscImageChef.Commands
{
plugins.PluginsList.TryGetValue(id_plugins[0], out _plugin);
DicConsole.WriteLine(string.Format("Identified by {0}.", _plugin.Name));
Filesystem fs = (Filesystem)_plugin.GetType().GetConstructor(new Type[] { typeof(ImagePlugin), typeof(Partition), typeof(System.Text.Encoding) }).Invoke(new object[] { _imageFormat, wholePart, null });
Filesystem fs = (Filesystem)_plugin
.GetType().GetConstructor(new Type[]
{
typeof(ImagePlugin), typeof(Partition), typeof(System.Text.Encoding)
}).Invoke(new object[] {_imageFormat, wholePart, null});
error = fs.Mount(options.Debug);
if(error == Errno.NoError)
{
@@ -707,10 +621,8 @@ namespace DiscImageChef.Commands
FileStream outputFile;
string volumeName;
if(string.IsNullOrEmpty(fs.XmlFSType.VolumeName))
volumeName = "NO NAME";
else
volumeName = fs.XmlFSType.VolumeName;
if(string.IsNullOrEmpty(fs.XmlFSType.VolumeName)) volumeName = "NO NAME";
else volumeName = fs.XmlFSType.VolumeName;
error = fs.Stat(entry, ref stat);
if(error == Errno.NoError)
@@ -730,49 +642,46 @@ namespace DiscImageChef.Commands
{
Directory.CreateDirectory(Path.Combine(options.OutputDir,
fs.XmlFSType.Type,
volumeName,
".xattrs",
volumeName, ".xattrs",
xattr));
outputPath = Path.Combine(options.OutputDir,
fs.XmlFSType.Type,
volumeName,
".xattrs",
xattr,
entry);
outputPath =
Path.Combine(options.OutputDir, fs.XmlFSType.Type, volumeName,
".xattrs", xattr, entry);
if(!File.Exists(outputPath))
{
outputFile = new FileStream(outputPath, FileMode.CreateNew, FileAccess.ReadWrite,
FileShare.None);
outputFile =
new FileStream(outputPath, FileMode.CreateNew,
FileAccess.ReadWrite, FileShare.None);
outputFile.Write(xattrBuf, 0, xattrBuf.Length);
outputFile.Close();
FileInfo fi = new FileInfo(outputPath);
#pragma warning disable RECS0022 // A catch clause that catches System.Exception and has an empty body
try { fi.CreationTimeUtc = stat.CreationTimeUtc; } catch { }
try { fi.LastWriteTimeUtc = stat.LastWriteTimeUtc; } catch { }
try { fi.LastAccessTimeUtc = stat.AccessTimeUtc; } catch { }
try { fi.CreationTimeUtc = stat.CreationTimeUtc; }
catch { }
try { fi.LastWriteTimeUtc = stat.LastWriteTimeUtc; }
catch { }
try { fi.LastAccessTimeUtc = stat.AccessTimeUtc; }
catch { }
#pragma warning restore RECS0022 // A catch clause that catches System.Exception and has an empty body
DicConsole.WriteLine("Written {0} bytes of xattr {1} from file {2} to {3}",
xattrBuf.Length, xattr, entry, outputPath);
DicConsole
.WriteLine("Written {0} bytes of xattr {1} from file {2} to {3}",
xattrBuf.Length, xattr, entry, outputPath);
}
else
DicConsole.ErrorWriteLine("Cannot write xattr {0} for {1}, output exists",
xattr, entry);
DicConsole
.ErrorWriteLine("Cannot write xattr {0} for {1}, output exists",
xattr, entry);
}
}
}
}
Directory.CreateDirectory(Path.Combine(options.OutputDir,
fs.XmlFSType.Type,
Directory.CreateDirectory(Path.Combine(options.OutputDir, fs.XmlFSType.Type,
volumeName));
outputPath = Path.Combine(options.OutputDir,
fs.XmlFSType.Type,
volumeName,
entry);
outputPath = Path.Combine(options.OutputDir, fs.XmlFSType.Type, volumeName, entry);
if(!File.Exists(outputPath))
{
@@ -782,36 +691,34 @@ namespace DiscImageChef.Commands
if(error == Errno.NoError)
{
outputFile = new FileStream(outputPath, FileMode.CreateNew, FileAccess.ReadWrite,
FileShare.None);
outputFile = new FileStream(outputPath, FileMode.CreateNew,
FileAccess.ReadWrite, FileShare.None);
outputFile.Write(outBuf, 0, outBuf.Length);
outputFile.Close();
FileInfo fi = new FileInfo(outputPath);
#pragma warning disable RECS0022 // A catch clause that catches System.Exception and has an empty body
try { fi.CreationTimeUtc = stat.CreationTimeUtc; } catch { }
try { fi.LastWriteTimeUtc = stat.LastWriteTimeUtc; } catch { }
try { fi.LastAccessTimeUtc = stat.AccessTimeUtc; } catch { }
try { fi.CreationTimeUtc = stat.CreationTimeUtc; }
catch { }
try { fi.LastWriteTimeUtc = stat.LastWriteTimeUtc; }
catch { }
try { fi.LastAccessTimeUtc = stat.AccessTimeUtc; }
catch { }
#pragma warning restore RECS0022 // A catch clause that catches System.Exception and has an empty body
DicConsole.WriteLine("Written {0} bytes of file {1} to {2}",
outBuf.Length, entry, outputPath);
DicConsole.WriteLine("Written {0} bytes of file {1} to {2}", outBuf.Length,
entry, outputPath);
}
else
DicConsole.ErrorWriteLine("Error {0} reading file {1}", error, entry);
else DicConsole.ErrorWriteLine("Error {0} reading file {1}", error, entry);
}
else
DicConsole.ErrorWriteLine("Cannot write file {0}, output exists", entry);
else DicConsole.ErrorWriteLine("Cannot write file {0}, output exists", entry);
}
else
DicConsole.ErrorWriteLine("Error reading file {0}", entry);
else DicConsole.ErrorWriteLine("Error reading file {0}", entry);
}
}
else
DicConsole.ErrorWriteLine("Error {0} reading root directory {0}", error.ToString());
else DicConsole.ErrorWriteLine("Error {0} reading root directory {0}", error.ToString());
Core.Statistics.AddFilesystem(fs.XmlFSType.Type);
}
else
DicConsole.ErrorWriteLine("Unable to mount device, error {0}", error.ToString());
else DicConsole.ErrorWriteLine("Unable to mount device, error {0}", error.ToString());
}
}
catch(Exception ex)
@@ -823,5 +730,4 @@ namespace DiscImageChef.Commands
Core.Statistics.AddCommand("extract-files");
}
}
}
}

View File

@@ -49,51 +49,44 @@ namespace DiscImageChef.Commands
FiltersList filtersList = new FiltersList();
DicConsole.WriteLine("Supported filters:");
if(FormatsOptions.Verbose)
DicConsole.VerboseWriteLine("GUID\t\t\t\t\tFilter");
if(FormatsOptions.Verbose) DicConsole.VerboseWriteLine("GUID\t\t\t\t\tFilter");
foreach(KeyValuePair<string, Filter> kvp in filtersList.filtersList)
{
if(FormatsOptions.Verbose)
DicConsole.VerboseWriteLine("{0}\t{1}", kvp.Value.UUID, kvp.Value.Name);
else
DicConsole.WriteLine(kvp.Value.Name);
if(FormatsOptions.Verbose) DicConsole.VerboseWriteLine("{0}\t{1}", kvp.Value.UUID, kvp.Value.Name);
else DicConsole.WriteLine(kvp.Value.Name);
}
DicConsole.WriteLine();
DicConsole.WriteLine("Supported disc image formats:");
if(FormatsOptions.Verbose)
DicConsole.VerboseWriteLine("GUID\t\t\t\t\tPlugin");
if(FormatsOptions.Verbose) DicConsole.VerboseWriteLine("GUID\t\t\t\t\tPlugin");
foreach(KeyValuePair<string, ImagePlugin> kvp in plugins.ImagePluginsList)
{
if(FormatsOptions.Verbose)
DicConsole.VerboseWriteLine("{0}\t{1}", kvp.Value.PluginUUID, kvp.Value.Name);
else
DicConsole.WriteLine(kvp.Value.Name);
else DicConsole.WriteLine(kvp.Value.Name);
}
DicConsole.WriteLine();
DicConsole.WriteLine("Supported filesystems:");
if(FormatsOptions.Verbose)
DicConsole.VerboseWriteLine("GUID\t\t\t\t\tPlugin");
if(FormatsOptions.Verbose) DicConsole.VerboseWriteLine("GUID\t\t\t\t\tPlugin");
foreach(KeyValuePair<string, Filesystem> kvp in plugins.PluginsList)
{
if(FormatsOptions.Verbose)
DicConsole.VerboseWriteLine("{0}\t{1}", kvp.Value.PluginUUID, kvp.Value.Name);
else
DicConsole.WriteLine(kvp.Value.Name);
else DicConsole.WriteLine(kvp.Value.Name);
}
DicConsole.WriteLine();
DicConsole.WriteLine("Supported partitioning schemes:");
if(FormatsOptions.Verbose)
DicConsole.VerboseWriteLine("GUID\t\t\t\t\tPlugin");
if(FormatsOptions.Verbose) DicConsole.VerboseWriteLine("GUID\t\t\t\t\tPlugin");
foreach(KeyValuePair<string, PartPlugin> kvp in plugins.PartPluginsList)
{
if(FormatsOptions.Verbose)
DicConsole.VerboseWriteLine("{0}\t{1}", kvp.Value.PluginUUID, kvp.Value.Name);
else
DicConsole.WriteLine(kvp.Value.Name);
else DicConsole.WriteLine(kvp.Value.Name);
}
Core.Statistics.AddCommand("formats");
}
}
}
}

View File

@@ -45,23 +45,22 @@ namespace DiscImageChef.Commands
Devices.DeviceInfo[] devices = Device.ListDevices();
if(devices == null || devices.Length == 0)
DicConsole.WriteLine("No known devices attached.");
if(devices == null || devices.Length == 0) DicConsole.WriteLine("No known devices attached.");
else
{
devices = devices.OrderBy(d => d.path).ToArray();
DicConsole.WriteLine("{0,-22}|{1,-16}|{2,-24}|{3,-24}|{4,-10}|{5,-10}",
"Path", "Vendor", "Model", "Serial", "Bus", "Supported?");
DicConsole.WriteLine("{0,-22}+{1,-16}+{2,-24}+{3,-24}+{4,-10}+{5,-10}",
"----------------------", "----------------", "------------------------",
"------------------------", "----------", "----------");
DicConsole.WriteLine("{0,-22}|{1,-16}|{2,-24}|{3,-24}|{4,-10}|{5,-10}", "Path", "Vendor", "Model",
"Serial", "Bus", "Supported?");
DicConsole.WriteLine("{0,-22}+{1,-16}+{2,-24}+{3,-24}+{4,-10}+{5,-10}", "----------------------",
"----------------", "------------------------", "------------------------",
"----------", "----------");
foreach(Devices.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);
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);
}
Core.Statistics.AddCommand("list-devices");
}
}
}
}

View File

@@ -49,17 +49,16 @@ namespace DiscImageChef.Commands
List<CommonEncodingInfo> encodings = new List<CommonEncodingInfo>();
foreach(System.Text.EncodingInfo info in System.Text.Encoding.GetEncodings())
encodings.Add(new CommonEncodingInfo { Name = info.Name, DisplayName = info.GetEncoding().EncodingName });
encodings.Add(new CommonEncodingInfo {Name = info.Name, DisplayName = info.GetEncoding().EncodingName});
foreach(Claunia.Encoding.EncodingInfo info in Claunia.Encoding.Encoding.GetEncodings())
encodings.Add(new CommonEncodingInfo { Name = info.Name, DisplayName = info.DisplayName });
encodings.Add(new CommonEncodingInfo {Name = info.Name, DisplayName = info.DisplayName});
DicConsole.WriteLine("{0,-16} {1,-8}", "Name", "Description");
foreach(CommonEncodingInfo info in encodings.OrderBy(t => t.DisplayName))
DicConsole.WriteLine("{0,-16} {1,-8}", info.Name, info.DisplayName);
DicConsole.WriteLine("{0,-16} {1,-8}", info.Name, info.DisplayName);
Core.Statistics.AddCommand("list-encodings");
}
}
}
}

View File

@@ -66,8 +66,7 @@ namespace DiscImageChef.Commands
try
{
encoding = Claunia.Encoding.Encoding.GetEncoding(options.EncodingName);
if(options.Verbose)
DicConsole.VerboseWriteLine("Using encoding for {0}.", encoding.EncodingName);
if(options.Verbose) DicConsole.VerboseWriteLine("Using encoding for {0}.", encoding.EncodingName);
}
catch(ArgumentException)
{
@@ -97,9 +96,9 @@ namespace DiscImageChef.Commands
else
{
if(options.Verbose)
DicConsole.VerboseWriteLine("Image format identified by {0} ({1}).", _imageFormat.Name, _imageFormat.PluginUUID);
else
DicConsole.WriteLine("Image format identified by {0}.", _imageFormat.Name);
DicConsole.VerboseWriteLine("Image format identified by {0} ({1}).", _imageFormat.Name,
_imageFormat.PluginUUID);
else DicConsole.WriteLine("Image format identified by {0}.", _imageFormat.Name);
}
try
@@ -112,9 +111,11 @@ namespace DiscImageChef.Commands
}
DicConsole.DebugWriteLine("Ls command", "Correctly opened image file.");
DicConsole.DebugWriteLine("Ls command", "Image without headers is {0} bytes.", _imageFormat.GetImageSize());
DicConsole.DebugWriteLine("Ls command", "Image without headers is {0} bytes.",
_imageFormat.GetImageSize());
DicConsole.DebugWriteLine("Ls command", "Image has {0} sectors.", _imageFormat.GetSectors());
DicConsole.DebugWriteLine("Ls command", "Image identifies disk type as {0}.", _imageFormat.GetMediaType());
DicConsole.DebugWriteLine("Ls command", "Image identifies disk type as {0}.",
_imageFormat.GetMediaType());
Core.Statistics.AddMediaFormat(_imageFormat.GetImageFormat());
Core.Statistics.AddMedia(_imageFormat.ImageInfo.mediaType, false);
@@ -130,8 +131,7 @@ namespace DiscImageChef.Commands
List<Partition> partitions = Partitions.GetAll(_imageFormat);
Partitions.AddSchemesToStats(partitions);
if(partitions.Count == 0)
DicConsole.DebugWriteLine("Ls command", "No partitions found");
if(partitions.Count == 0) DicConsole.DebugWriteLine("Ls command", "No partitions found");
else
{
DicConsole.WriteLine("{0} partitions found.", partitions.Count);
@@ -144,8 +144,7 @@ namespace DiscImageChef.Commands
DicConsole.WriteLine("Identifying filesystem on partition");
Core.Filesystems.Identify(_imageFormat, out id_plugins, partitions[i]);
if(id_plugins.Count == 0)
DicConsole.WriteLine("Filesystem not identified");
if(id_plugins.Count == 0) DicConsole.WriteLine("Filesystem not identified");
else if(id_plugins.Count > 1)
{
DicConsole.WriteLine(string.Format("Identified by {0} plugins", id_plugins.Count));
@@ -155,7 +154,11 @@ namespace DiscImageChef.Commands
if(plugins.PluginsList.TryGetValue(plugin_name, out _plugin))
{
DicConsole.WriteLine(string.Format("As identified by {0}.", _plugin.Name));
Filesystem fs = (Filesystem)_plugin.GetType().GetConstructor(new Type[] { typeof(ImagePlugin), typeof(Partition), typeof(System.Text.Encoding) }).Invoke(new object[] { _imageFormat, partitions[i], null });
Filesystem fs = (Filesystem)_plugin
.GetType().GetConstructor(new Type[]
{
typeof(ImagePlugin), typeof(Partition), typeof(System.Text.Encoding)
}).Invoke(new object[] {_imageFormat, partitions[i], null});
error = fs.Mount(options.Debug);
if(error == Errno.NoError)
@@ -164,16 +167,17 @@ namespace DiscImageChef.Commands
error = fs.ReadDir("/", ref rootDir);
if(error == Errno.NoError)
{
foreach(string entry in rootDir)
DicConsole.WriteLine("{0}", entry);
foreach(string entry in rootDir) DicConsole.WriteLine("{0}", entry);
}
else
DicConsole.ErrorWriteLine("Error {0} reading root directory {0}", error.ToString());
DicConsole.ErrorWriteLine("Error {0} reading root directory {0}",
error.ToString());
Core.Statistics.AddFilesystem(fs.XmlFSType.Type);
}
else
DicConsole.ErrorWriteLine("Unable to mount device, error {0}", error.ToString());
DicConsole.ErrorWriteLine("Unable to mount device, error {0}",
error.ToString());
}
}
}
@@ -181,7 +185,11 @@ namespace DiscImageChef.Commands
{
plugins.PluginsList.TryGetValue(id_plugins[0], out _plugin);
DicConsole.WriteLine(string.Format("Identified by {0}.", _plugin.Name));
Filesystem fs = (Filesystem)_plugin.GetType().GetConstructor(new Type[] { typeof(ImagePlugin), typeof(Partition), typeof(System.Text.Encoding) }).Invoke(new object[] { _imageFormat, partitions[i], null });
Filesystem fs = (Filesystem)_plugin
.GetType().GetConstructor(new Type[]
{
typeof(ImagePlugin), typeof(Partition), typeof(System.Text.Encoding)
}).Invoke(new object[] {_imageFormat, partitions[i], null});
error = fs.Mount(options.Debug);
if(error == Errno.NoError)
{
@@ -189,16 +197,14 @@ namespace DiscImageChef.Commands
error = fs.ReadDir("/", ref rootDir);
if(error == Errno.NoError)
{
foreach(string entry in rootDir)
DicConsole.WriteLine("{0}", entry);
foreach(string entry in rootDir) DicConsole.WriteLine("{0}", entry);
}
else
DicConsole.ErrorWriteLine("Error {0} reading root directory {0}", error.ToString());
Core.Statistics.AddFilesystem(fs.XmlFSType.Type);
}
else
DicConsole.ErrorWriteLine("Unable to mount device, error {0}", error.ToString());
else DicConsole.ErrorWriteLine("Unable to mount device, error {0}", error.ToString());
}
}
}
@@ -211,8 +217,7 @@ namespace DiscImageChef.Commands
};
Core.Filesystems.Identify(_imageFormat, out id_plugins, wholePart);
if(id_plugins.Count == 0)
DicConsole.WriteLine("Filesystem not identified");
if(id_plugins.Count == 0) DicConsole.WriteLine("Filesystem not identified");
else if(id_plugins.Count > 1)
{
DicConsole.WriteLine(string.Format("Identified by {0} plugins", id_plugins.Count));
@@ -222,7 +227,11 @@ namespace DiscImageChef.Commands
if(plugins.PluginsList.TryGetValue(plugin_name, out _plugin))
{
DicConsole.WriteLine(string.Format("As identified by {0}.", _plugin.Name));
Filesystem fs = (Filesystem)_plugin.GetType().GetConstructor(new Type[] { typeof(ImagePlugin), typeof(Partition), typeof(System.Text.Encoding) }).Invoke(new object[] { _imageFormat, wholePart, null });
Filesystem fs = (Filesystem)_plugin
.GetType().GetConstructor(new Type[]
{
typeof(ImagePlugin), typeof(Partition), typeof(System.Text.Encoding)
}).Invoke(new object[] {_imageFormat, wholePart, null});
error = fs.Mount(options.Debug);
if(error == Errno.NoError)
{
@@ -230,16 +239,14 @@ namespace DiscImageChef.Commands
error = fs.ReadDir("/", ref rootDir);
if(error == Errno.NoError)
{
foreach(string entry in rootDir)
DicConsole.WriteLine("{0}", entry);
foreach(string entry in rootDir) DicConsole.WriteLine("{0}", entry);
}
else
DicConsole.ErrorWriteLine("Error {0} reading root directory {0}", error.ToString());
Core.Statistics.AddFilesystem(fs.XmlFSType.Type);
}
else
DicConsole.ErrorWriteLine("Unable to mount device, error {0}", error.ToString());
else DicConsole.ErrorWriteLine("Unable to mount device, error {0}", error.ToString());
}
}
}
@@ -247,7 +254,11 @@ namespace DiscImageChef.Commands
{
plugins.PluginsList.TryGetValue(id_plugins[0], out _plugin);
DicConsole.WriteLine(string.Format("Identified by {0}.", _plugin.Name));
Filesystem fs = (Filesystem)_plugin.GetType().GetConstructor(new Type[] { typeof(ImagePlugin), typeof(Partition), typeof(System.Text.Encoding) }).Invoke(new object[] { _imageFormat, wholePart, null });
Filesystem fs = (Filesystem)_plugin
.GetType().GetConstructor(new Type[]
{
typeof(ImagePlugin), typeof(Partition), typeof(System.Text.Encoding)
}).Invoke(new object[] {_imageFormat, wholePart, null});
error = fs.Mount(options.Debug);
if(error == Errno.NoError)
{
@@ -265,11 +276,8 @@ namespace DiscImageChef.Commands
error = fs.Stat(entry, ref stat);
if(error == Errno.NoError)
{
DicConsole.WriteLine("{0}\t{1}\t{2} bytes\t{3}",
stat.CreationTimeUtc,
stat.Inode,
stat.Length,
entry);
DicConsole.WriteLine("{0}\t{1}\t{2} bytes\t{3}", stat.CreationTimeUtc,
stat.Inode, stat.Length, entry);
error = fs.ListXAttr(entry, ref xattrs);
if(error == Errno.NoError)
@@ -280,26 +288,21 @@ namespace DiscImageChef.Commands
error = fs.GetXattr(entry, xattr, ref xattrBuf);
if(error == Errno.NoError)
{
DicConsole.WriteLine("\t\t{0}\t{1} bytes",
xattr, xattrBuf.Length);
DicConsole.WriteLine("\t\t{0}\t{1} bytes", xattr, xattrBuf.Length);
}
}
}
}
else
DicConsole.WriteLine("{0}", entry);
else DicConsole.WriteLine("{0}", entry);
}
else
DicConsole.WriteLine("{0}", entry);
else DicConsole.WriteLine("{0}", entry);
}
}
else
DicConsole.ErrorWriteLine("Error {0} reading root directory {0}", error.ToString());
else DicConsole.ErrorWriteLine("Error {0} reading root directory {0}", error.ToString());
Core.Statistics.AddFilesystem(fs.XmlFSType.Type);
}
else
DicConsole.ErrorWriteLine("Unable to mount device, error {0}", error.ToString());
else DicConsole.ErrorWriteLine("Unable to mount device, error {0}", error.ToString());
}
}
catch(Exception ex)
@@ -311,5 +314,4 @@ namespace DiscImageChef.Commands
Core.Statistics.AddCommand("ls");
}
}
}
}

File diff suppressed because it is too large Load Diff

View File

@@ -47,8 +47,8 @@ namespace DiscImageChef.Commands
DicConsole.DebugWriteLine("Media-Scan command", "--mhdd-log={0}", options.MHDDLogPath);
DicConsole.DebugWriteLine("Media-Scan command", "--ibg-log={0}", options.IBGLogPath);
if(options.DevicePath.Length == 2 && options.DevicePath[1] == ':' &&
options.DevicePath[0] != '/' && char.IsLetter(options.DevicePath[0]))
if(options.DevicePath.Length == 2 && options.DevicePath[1] == ':' && options.DevicePath[0] != '/' &&
char.IsLetter(options.DevicePath[0]))
{
options.DevicePath = "\\\\.\\" + char.ToUpper(options.DevicePath[0]) + ':';
}
@@ -81,11 +81,11 @@ namespace DiscImageChef.Commands
case DeviceType.SCSI:
results = SCSI.Scan(options.MHDDLogPath, options.IBGLogPath, options.DevicePath, dev);
break;
default:
throw new NotSupportedException("Unknown device type.");
default: throw new NotSupportedException("Unknown device type.");
}
DicConsole.WriteLine("Took a total of {0} seconds ({1} processing commands).", results.totalTime, results.processingTime);
DicConsole.WriteLine("Took a total of {0} seconds ({1} processing commands).", results.totalTime,
results.processingTime);
DicConsole.WriteLine("Avegare 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);
@@ -102,17 +102,19 @@ namespace DiscImageChef.Commands
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);
results.seekTimes, results.seekMax, results.seekMin, results.seekTotal / 1000);
Core.Statistics.AddMediaScan((long)results.A, (long)results.B, (long)results.C, (long)results.D, (long)results.E, (long)results.F, (long)results.blocks, (long)results.errored, (long)(results.blocks - results.errored));
Core.Statistics.AddMediaScan((long)results.A, (long)results.B, (long)results.C, (long)results.D,
(long)results.E, (long)results.F, (long)results.blocks, (long)results.errored,
(long)(results.blocks - results.errored));
Core.Statistics.AddCommand("media-scan");
}
}
}
}

View File

@@ -75,22 +75,22 @@ namespace DiscImageChef.Commands
if(inputFormat.ImageInfo.readableSectorTags == null)
{
DicConsole.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)
{
DicConsole.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;
}
}
if(options.LongSectors)
sector = inputFormat.ReadSectorLong(options.StartSector + i);
else
sector = inputFormat.ReadSector(options.StartSector + i);
if(options.LongSectors) sector = inputFormat.ReadSectorLong(options.StartSector + i);
else sector = inputFormat.ReadSector(options.StartSector + i);
DiscImageChef.PrintHex.PrintHexArray(sector, options.WidthBytes);
}
@@ -98,5 +98,4 @@ namespace DiscImageChef.Commands
Core.Statistics.AddCommand("print-hex");
}
}
}
}

View File

@@ -52,35 +52,50 @@ namespace DiscImageChef.Commands
DicConsole.WriteLine("Commands statistics");
DicConsole.WriteLine("===================");
if(Core.Statistics.AllStats.Commands.Analyze > 0)
DicConsole.WriteLine("You have called the Analyze command {0} times", Core.Statistics.AllStats.Commands.Analyze);
DicConsole.WriteLine("You have called the Analyze command {0} times",
Core.Statistics.AllStats.Commands.Analyze);
if(Core.Statistics.AllStats.Commands.Benchmark > 0)
DicConsole.WriteLine("You have called the Benchmark command {0} times", Core.Statistics.AllStats.Commands.Benchmark);
DicConsole.WriteLine("You have called the Benchmark command {0} times",
Core.Statistics.AllStats.Commands.Benchmark);
if(Core.Statistics.AllStats.Commands.Checksum > 0)
DicConsole.WriteLine("You have called the Checksum command {0} times", Core.Statistics.AllStats.Commands.Checksum);
DicConsole.WriteLine("You have called the Checksum command {0} times",
Core.Statistics.AllStats.Commands.Checksum);
if(Core.Statistics.AllStats.Commands.Compare > 0)
DicConsole.WriteLine("You have called the Compare command {0} times", Core.Statistics.AllStats.Commands.Compare);
DicConsole.WriteLine("You have called the Compare command {0} times",
Core.Statistics.AllStats.Commands.Compare);
if(Core.Statistics.AllStats.Commands.CreateSidecar > 0)
DicConsole.WriteLine("You have called the Create-Sidecar command {0} times", Core.Statistics.AllStats.Commands.CreateSidecar);
DicConsole.WriteLine("You have called the Create-Sidecar command {0} times",
Core.Statistics.AllStats.Commands.CreateSidecar);
if(Core.Statistics.AllStats.Commands.Decode > 0)
DicConsole.WriteLine("You have called the Decode command {0} times", Core.Statistics.AllStats.Commands.Decode);
DicConsole.WriteLine("You have called the Decode command {0} times",
Core.Statistics.AllStats.Commands.Decode);
if(Core.Statistics.AllStats.Commands.DeviceInfo > 0)
DicConsole.WriteLine("You have called the Device-Info command {0} times", Core.Statistics.AllStats.Commands.DeviceInfo);
DicConsole.WriteLine("You have called the Device-Info command {0} times",
Core.Statistics.AllStats.Commands.DeviceInfo);
if(Core.Statistics.AllStats.Commands.DeviceReport > 0)
DicConsole.WriteLine("You have called the Device-Report command {0} times", Core.Statistics.AllStats.Commands.DeviceReport);
DicConsole.WriteLine("You have called the Device-Report command {0} times",
Core.Statistics.AllStats.Commands.DeviceReport);
if(Core.Statistics.AllStats.Commands.DumpMedia > 0)
DicConsole.WriteLine("You have called the Dump-Media command {0} times", Core.Statistics.AllStats.Commands.DumpMedia);
DicConsole.WriteLine("You have called the Dump-Media command {0} times",
Core.Statistics.AllStats.Commands.DumpMedia);
if(Core.Statistics.AllStats.Commands.Entropy > 0)
DicConsole.WriteLine("You have called the Entropy command {0} times", Core.Statistics.AllStats.Commands.Entropy);
DicConsole.WriteLine("You have called the Entropy command {0} times",
Core.Statistics.AllStats.Commands.Entropy);
if(Core.Statistics.AllStats.Commands.Formats > 0)
DicConsole.WriteLine("You have called the Formats command {0} times", Core.Statistics.AllStats.Commands.Formats);
DicConsole.WriteLine("You have called the Formats command {0} times",
Core.Statistics.AllStats.Commands.Formats);
if(Core.Statistics.AllStats.Commands.MediaInfo > 0)
DicConsole.WriteLine("You have called the Media-Info command {0} times", Core.Statistics.AllStats.Commands.MediaInfo);
DicConsole.WriteLine("You have called the Media-Info command {0} times",
Core.Statistics.AllStats.Commands.MediaInfo);
if(Core.Statistics.AllStats.Commands.MediaScan > 0)
DicConsole.WriteLine("You have called the Media-Scan command {0} times", Core.Statistics.AllStats.Commands.MediaScan);
DicConsole.WriteLine("You have called the Media-Scan command {0} times",
Core.Statistics.AllStats.Commands.MediaScan);
if(Core.Statistics.AllStats.Commands.PrintHex > 0)
DicConsole.WriteLine("You have called the Print-Hex command {0} times", Core.Statistics.AllStats.Commands.PrintHex);
DicConsole.WriteLine("You have called the Print-Hex command {0} times",
Core.Statistics.AllStats.Commands.PrintHex);
if(Core.Statistics.AllStats.Commands.Verify > 0)
DicConsole.WriteLine("You have called the Verify command {0} times", Core.Statistics.AllStats.Commands.Verify);
DicConsole.WriteLine("You have called the Verify command {0} times",
Core.Statistics.AllStats.Commands.Verify);
DicConsole.WriteLine();
thereAreStats = true;
}
@@ -93,11 +108,17 @@ namespace DiscImageChef.Commands
{
DicConsole.WriteLine("Took {0} seconds to calculate {1} algorithm", chk.Value, chk.algorithm);
}
DicConsole.WriteLine("Took {0} seconds to calculate all algorithms sequentially", Core.Statistics.AllStats.Benchmark.Sequential);
DicConsole.WriteLine("Took {0} seconds to calculate all algorithms at the same time", Core.Statistics.AllStats.Benchmark.All);
DicConsole.WriteLine("Took {0} seconds to calculate entropy", Core.Statistics.AllStats.Benchmark.Entropy);
DicConsole.WriteLine("Used a maximum of {0} bytes of memory", Core.Statistics.AllStats.Benchmark.MaxMemory);
DicConsole.WriteLine("Used a minimum of {0} bytes of memory", Core.Statistics.AllStats.Benchmark.MinMemory);
DicConsole.WriteLine("Took {0} seconds to calculate all algorithms sequentially",
Core.Statistics.AllStats.Benchmark.Sequential);
DicConsole.WriteLine("Took {0} seconds to calculate all algorithms at the same time",
Core.Statistics.AllStats.Benchmark.All);
DicConsole.WriteLine("Took {0} seconds to calculate entropy",
Core.Statistics.AllStats.Benchmark.Entropy);
DicConsole.WriteLine("Used a maximum of {0} bytes of memory",
Core.Statistics.AllStats.Benchmark.MaxMemory);
DicConsole.WriteLine("Used a minimum of {0} bytes of memory",
Core.Statistics.AllStats.Benchmark.MinMemory);
DicConsole.WriteLine();
thereAreStats = true;
}
@@ -108,6 +129,7 @@ namespace DiscImageChef.Commands
DicConsole.WriteLine("==================");
foreach(NameValueStats nvs in Core.Statistics.AllStats.Filters)
DicConsole.WriteLine("Filter {0} has been found {1} times.", nvs.name, nvs.Value);
DicConsole.WriteLine();
thereAreStats = true;
}
@@ -118,6 +140,7 @@ namespace DiscImageChef.Commands
DicConsole.WriteLine("======================");
foreach(NameValueStats nvs in Core.Statistics.AllStats.MediaImages)
DicConsole.WriteLine("Format {0} has been found {1} times.", nvs.name, nvs.Value);
DicConsole.WriteLine();
thereAreStats = true;
}
@@ -128,6 +151,7 @@ namespace DiscImageChef.Commands
DicConsole.WriteLine("====================");
foreach(NameValueStats nvs in Core.Statistics.AllStats.Partitions)
DicConsole.WriteLine("Partitioning scheme {0} has been found {1} times.", nvs.name, nvs.Value);
DicConsole.WriteLine();
thereAreStats = true;
}
@@ -138,6 +162,7 @@ namespace DiscImageChef.Commands
DicConsole.WriteLine("=====================");
foreach(NameValueStats nvs in Core.Statistics.AllStats.Filesystems)
DicConsole.WriteLine("Filesystem {0} has been found {1} times.", nvs.name, nvs.Value);
DicConsole.WriteLine();
thereAreStats = true;
}
@@ -147,7 +172,10 @@ namespace DiscImageChef.Commands
DicConsole.WriteLine("Device statistics");
DicConsole.WriteLine("=================");
foreach(DeviceStats ds in Core.Statistics.AllStats.Devices)
DicConsole.WriteLine("Device model {0}, manufactured by {1}, with revision {2} and attached via {3}.", ds.Model, ds.Manufacturer, ds.Revision, ds.Bus);
DicConsole
.WriteLine("Device model {0}, manufactured by {1}, with revision {2} and attached via {3}.",
ds.Model, ds.Manufacturer, ds.Revision, ds.Bus);
DicConsole.WriteLine();
thereAreStats = true;
}
@@ -159,10 +187,13 @@ namespace DiscImageChef.Commands
foreach(MediaStats ms in Core.Statistics.AllStats.Medias)
{
if(ms.real)
DicConsole.WriteLine("Media type {0} has been found {1} times in a real device.", ms.type, ms.Value);
DicConsole.WriteLine("Media type {0} has been found {1} times in a real device.", ms.type,
ms.Value);
else
DicConsole.WriteLine("Media type {0} has been found {1} times in a media image.", ms.type, ms.Value);
DicConsole.WriteLine("Media type {0} has been found {1} times in a media image.", ms.type,
ms.Value);
}
DicConsole.WriteLine();
thereAreStats = true;
}
@@ -171,15 +202,22 @@ namespace DiscImageChef.Commands
{
DicConsole.WriteLine("Media scan statistics");
DicConsole.WriteLine("=====================");
DicConsole.WriteLine("Scanned a total of {0} sectors", Core.Statistics.AllStats.MediaScan.Sectors.Total);
DicConsole.WriteLine("Scanned a total of {0} sectors",
Core.Statistics.AllStats.MediaScan.Sectors.Total);
DicConsole.WriteLine("{0} of them correctly", Core.Statistics.AllStats.MediaScan.Sectors.Correct);
DicConsole.WriteLine("{0} of them had errors", Core.Statistics.AllStats.MediaScan.Sectors.Error);
DicConsole.WriteLine("{0} of them took less than 3 ms", Core.Statistics.AllStats.MediaScan.Times.LessThan3ms);
DicConsole.WriteLine("{0} of them took less than 10 ms but more than 3 ms", Core.Statistics.AllStats.MediaScan.Times.LessThan10ms);
DicConsole.WriteLine("{0} of them took less than 50 ms but more than 10 ms", Core.Statistics.AllStats.MediaScan.Times.LessThan50ms);
DicConsole.WriteLine("{0} of them took less than 150 ms but more than 50 ms", Core.Statistics.AllStats.MediaScan.Times.LessThan150ms);
DicConsole.WriteLine("{0} of them took less than 500 ms but more than 150 ms", Core.Statistics.AllStats.MediaScan.Times.LessThan500ms);
DicConsole.WriteLine("{0} of them took less than more than 500 ms", Core.Statistics.AllStats.MediaScan.Times.MoreThan500ms);
DicConsole.WriteLine("{0} of them took less than 3 ms",
Core.Statistics.AllStats.MediaScan.Times.LessThan3ms);
DicConsole.WriteLine("{0} of them took less than 10 ms but more than 3 ms",
Core.Statistics.AllStats.MediaScan.Times.LessThan10ms);
DicConsole.WriteLine("{0} of them took less than 50 ms but more than 10 ms",
Core.Statistics.AllStats.MediaScan.Times.LessThan50ms);
DicConsole.WriteLine("{0} of them took less than 150 ms but more than 50 ms",
Core.Statistics.AllStats.MediaScan.Times.LessThan150ms);
DicConsole.WriteLine("{0} of them took less than 500 ms but more than 150 ms",
Core.Statistics.AllStats.MediaScan.Times.LessThan500ms);
DicConsole.WriteLine("{0} of them took less than more than 500 ms",
Core.Statistics.AllStats.MediaScan.Times.MoreThan500ms);
thereAreStats = true;
}
@@ -187,18 +225,21 @@ namespace DiscImageChef.Commands
{
DicConsole.WriteLine("Verification statistics");
DicConsole.WriteLine("=======================");
DicConsole.WriteLine("{0} media images has been correctly verified", Core.Statistics.AllStats.Verify.MediaImages.Correct);
DicConsole.WriteLine("{0} media images has been determined as containing errors", Core.Statistics.AllStats.Verify.MediaImages.Failed);
DicConsole.WriteLine("{0} media images has been correctly verified",
Core.Statistics.AllStats.Verify.MediaImages.Correct);
DicConsole.WriteLine("{0} media images has been determined as containing errors",
Core.Statistics.AllStats.Verify.MediaImages.Failed);
DicConsole.WriteLine("{0} sectors has been verified", Core.Statistics.AllStats.Verify.Sectors.Total);
DicConsole.WriteLine("{0} sectors has been determined correct", Core.Statistics.AllStats.Verify.Sectors.Correct);
DicConsole.WriteLine("{0} sectors has been determined to contain errors", Core.Statistics.AllStats.Verify.Sectors.Error);
DicConsole.WriteLine("{0} sectors could not be determined as correct or not", Core.Statistics.AllStats.Verify.Sectors.Unverifiable);
DicConsole.WriteLine("{0} sectors has been determined correct",
Core.Statistics.AllStats.Verify.Sectors.Correct);
DicConsole.WriteLine("{0} sectors has been determined to contain errors",
Core.Statistics.AllStats.Verify.Sectors.Error);
DicConsole.WriteLine("{0} sectors could not be determined as correct or not",
Core.Statistics.AllStats.Verify.Sectors.Unverifiable);
thereAreStats = true;
}
if(!thereAreStats)
DicConsole.WriteLine("There are no statistics.");
if(!thereAreStats) DicConsole.WriteLine("There are no statistics.");
}
}
}
}

View File

@@ -108,15 +108,10 @@ namespace DiscImageChef.Commands
try
{
List<Track> inputTracks = inputFormat.GetTracks();
if(inputTracks.Count > 0)
formatHasTracks = true;
else
formatHasTracks = false;
}
catch
{
formatHasTracks = false;
if(inputTracks.Count > 0) formatHasTracks = true;
else formatHasTracks = false;
}
catch { formatHasTracks = false; }
DateTime StartCheck;
DateTime EndCheck;
@@ -137,31 +132,29 @@ namespace DiscImageChef.Commands
while(remainingSectors > 0)
{
DicConsole.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<ulong> tempFailingLBAs;
List<ulong> tempUnknownLBAs;
bool? tempStatus;
if(remainingSectors < 512)
tempStatus = inputFormat.VerifySectors(currentSector, (uint)remainingSectors, currentTrack.TrackSequence, out tempFailingLBAs, out tempUnknownLBAs);
tempStatus = inputFormat.VerifySectors(currentSector, (uint)remainingSectors,
currentTrack.TrackSequence, out tempFailingLBAs,
out tempUnknownLBAs);
else
tempStatus = inputFormat.VerifySectors(currentSector, 512, currentTrack.TrackSequence, out tempFailingLBAs, out tempUnknownLBAs);
tempStatus = inputFormat.VerifySectors(currentSector, 512, currentTrack.TrackSequence,
out tempFailingLBAs, out tempUnknownLBAs);
if(checkStatus == null || tempStatus == null)
checkStatus = null;
else if(checkStatus == false || tempStatus == false)
checkStatus = false;
else if(checkStatus == true && tempStatus == true)
checkStatus = true;
else
checkStatus = null;
if(checkStatus == null || tempStatus == null) checkStatus = null;
else if(checkStatus == false || tempStatus == false) checkStatus = false;
else if(checkStatus == true && tempStatus == true) checkStatus = true;
else checkStatus = null;
foreach(ulong failLBA in tempFailingLBAs)
FailingLBAs.Add(failLBA);
foreach(ulong failLBA in tempFailingLBAs) FailingLBAs.Add(failLBA);
foreach(ulong unknownLBA in tempUnknownLBAs)
UnknownLBAs.Add(unknownLBA);
foreach(ulong unknownLBA in tempUnknownLBAs) UnknownLBAs.Add(unknownLBA);
if(remainingSectors < 512)
{
@@ -175,9 +168,9 @@ namespace DiscImageChef.Commands
currentSectorAll += 512;
remainingSectors -= 512;
}
}
}
EndCheck = DateTime.UtcNow;
}
else
@@ -195,24 +188,20 @@ namespace DiscImageChef.Commands
bool? tempStatus;
if(remainingSectors < 512)
tempStatus = inputFormat.VerifySectors(currentSector, (uint)remainingSectors, out tempFailingLBAs, out tempUnknownLBAs);
tempStatus = inputFormat.VerifySectors(currentSector, (uint)remainingSectors,
out tempFailingLBAs, out tempUnknownLBAs);
else
tempStatus = inputFormat.VerifySectors(currentSector, 512, out tempFailingLBAs, out tempUnknownLBAs);
tempStatus =
inputFormat.VerifySectors(currentSector, 512, out tempFailingLBAs, out tempUnknownLBAs);
if(checkStatus == null || tempStatus == null)
checkStatus = null;
else if(checkStatus == false || tempStatus == false)
checkStatus = false;
else if(checkStatus == true && tempStatus == true)
checkStatus = true;
else
checkStatus = null;
if(checkStatus == null || tempStatus == null) checkStatus = null;
else if(checkStatus == false || tempStatus == false) checkStatus = false;
else if(checkStatus == true && tempStatus == true) checkStatus = true;
else checkStatus = null;
foreach(ulong failLBA in tempFailingLBAs)
FailingLBAs.Add(failLBA);
foreach(ulong failLBA in tempFailingLBAs) FailingLBAs.Add(failLBA);
foreach(ulong unknownLBA in tempUnknownLBAs)
UnknownLBAs.Add(unknownLBA);
foreach(ulong unknownLBA in tempUnknownLBAs) UnknownLBAs.Add(unknownLBA);
if(remainingSectors < 512)
{
@@ -224,8 +213,8 @@ namespace DiscImageChef.Commands
currentSector += 512;
remainingSectors -= 512;
}
}
EndCheck = DateTime.UtcNow;
}
@@ -254,15 +243,13 @@ namespace DiscImageChef.Commands
if(FailingLBAs.Count == (int)inputFormat.GetSectors())
DicConsole.VerboseWriteLine("\tall sectors.");
else
for(int i = 0; i < FailingLBAs.Count; i++)
DicConsole.VerboseWriteLine("\t{0}", FailingLBAs[i]);
for(int i = 0; i < FailingLBAs.Count; i++) DicConsole.VerboseWriteLine("\t{0}", FailingLBAs[i]);
DicConsole.WriteLine("LBAs without checksum:");
if(UnknownLBAs.Count == (int)inputFormat.GetSectors())
DicConsole.VerboseWriteLine("\tall sectors.");
else
for(int i = 0; i < UnknownLBAs.Count; i++)
DicConsole.VerboseWriteLine("\t{0}", UnknownLBAs[i]);
for(int i = 0; i < UnknownLBAs.Count; i++) DicConsole.VerboseWriteLine("\t{0}", UnknownLBAs[i]);
}
DicConsole.WriteLine("Total sectors........... {0}", inputFormat.GetSectors());
@@ -280,5 +267,4 @@ namespace DiscImageChef.Commands
Core.Statistics.AddVerify(correctDisc, correctSectors, errorSectors, unknownSectors, totalSectors);
}
}
}
}

View File

@@ -47,208 +47,143 @@ namespace DiscImageChef
Settings.Settings.LoadSettings();
Core.Statistics.LoadStats();
if(Settings.Settings.Current.Stats.ShareStats)
Core.Statistics.SubmitStats();
if(Settings.Settings.Current.Stats.ShareStats) Core.Statistics.SubmitStats();
Parser.Default.ParseArguments(args, new[] {typeof(AnalyzeOptions), typeof(CompareOptions), typeof(ChecksumOptions),
typeof(EntropyOptions), typeof(VerifyOptions), typeof(PrintHexOptions),
typeof(DecodeOptions), typeof(DeviceInfoOptions), typeof(MediaInfoOptions),
typeof(MediaScanOptions), typeof(FormatsOptions), typeof(BenchmarkOptions),
typeof(CreateSidecarOptions),
typeof(DumpMediaOptions), typeof(DeviceReportOptions),
typeof(ConfigureOptions), typeof(StatsOptions), typeof(LsOptions),
typeof(ExtractFilesOptions), typeof(ListDevicesOptions), typeof(ListEncodingsOptions)})
.WithParsed<AnalyzeOptions>(opts =>
Parser.Default
.ParseArguments(args,
new[]
{
typeof(AnalyzeOptions), typeof(CompareOptions), typeof(ChecksumOptions),
typeof(EntropyOptions), typeof(VerifyOptions), typeof(PrintHexOptions),
typeof(DecodeOptions), typeof(DeviceInfoOptions), typeof(MediaInfoOptions),
typeof(MediaScanOptions), typeof(FormatsOptions), typeof(BenchmarkOptions),
typeof(CreateSidecarOptions), typeof(DumpMediaOptions),
typeof(DeviceReportOptions), typeof(ConfigureOptions), typeof(StatsOptions),
typeof(LsOptions), typeof(ExtractFilesOptions), typeof(ListDevicesOptions),
typeof(ListEncodingsOptions)
}).WithParsed<AnalyzeOptions>(opts =>
{
if(opts.Debug)
DicConsole.DebugWriteLineEvent += System.Console.Error.WriteLine;
if(opts.Verbose)
DicConsole.VerboseWriteLineEvent += System.Console.WriteLine;
if(opts.Debug) DicConsole.DebugWriteLineEvent += System.Console.Error.WriteLine;
if(opts.Verbose) DicConsole.VerboseWriteLineEvent += System.Console.WriteLine;
PrintCopyright();
Commands.Analyze.doAnalyze(opts);
})
.WithParsed<CompareOptions>(opts =>
{
if(opts.Debug)
DicConsole.DebugWriteLineEvent += System.Console.Error.WriteLine;
if(opts.Verbose)
DicConsole.VerboseWriteLineEvent += System.Console.WriteLine;
PrintCopyright();
Commands.Compare.doCompare(opts);
})
.WithParsed<ChecksumOptions>(opts =>
{
if(opts.Debug)
DicConsole.DebugWriteLineEvent += System.Console.Error.WriteLine;
if(opts.Verbose)
DicConsole.VerboseWriteLineEvent += System.Console.WriteLine;
PrintCopyright();
Commands.Checksum.doChecksum(opts);
})
.WithParsed<EntropyOptions>(opts =>
{
if(opts.Debug)
DicConsole.DebugWriteLineEvent += System.Console.Error.WriteLine;
if(opts.Verbose)
DicConsole.VerboseWriteLineEvent += System.Console.WriteLine;
PrintCopyright();
Commands.Entropy.doEntropy(opts);
})
.WithParsed<VerifyOptions>(opts =>
{
if(opts.Debug)
DicConsole.DebugWriteLineEvent += System.Console.Error.WriteLine;
if(opts.Verbose)
DicConsole.VerboseWriteLineEvent += System.Console.WriteLine;
PrintCopyright();
Commands.Verify.doVerify(opts);
})
.WithParsed<PrintHexOptions>(opts =>
{
if(opts.Debug)
DicConsole.DebugWriteLineEvent += System.Console.Error.WriteLine;
if(opts.Verbose)
DicConsole.VerboseWriteLineEvent += System.Console.WriteLine;
PrintCopyright();
Commands.PrintHex.doPrintHex(opts);
})
.WithParsed<DecodeOptions>(opts =>
{
if(opts.Debug)
DicConsole.DebugWriteLineEvent += System.Console.Error.WriteLine;
if(opts.Verbose)
DicConsole.VerboseWriteLineEvent += System.Console.WriteLine;
PrintCopyright();
Commands.Decode.doDecode(opts);
})
.WithParsed<DeviceInfoOptions>(opts =>
{
if(opts.Debug)
DicConsole.DebugWriteLineEvent += System.Console.Error.WriteLine;
if(opts.Verbose)
DicConsole.VerboseWriteLineEvent += System.Console.WriteLine;
PrintCopyright();
Commands.DeviceInfo.doDeviceInfo(opts);
})
.WithParsed<MediaInfoOptions>(opts =>
{
if(opts.Debug)
DicConsole.DebugWriteLineEvent += System.Console.Error.WriteLine;
if(opts.Verbose)
DicConsole.VerboseWriteLineEvent += System.Console.WriteLine;
PrintCopyright();
Commands.MediaInfo.doMediaInfo(opts);
})
.WithParsed<MediaScanOptions>(opts =>
{
if(opts.Debug)
DicConsole.DebugWriteLineEvent += System.Console.Error.WriteLine;
if(opts.Verbose)
DicConsole.VerboseWriteLineEvent += System.Console.WriteLine;
PrintCopyright();
Commands.MediaScan.doMediaScan(opts);
})
.WithParsed<FormatsOptions>(opts =>
{
if(opts.Debug)
DicConsole.DebugWriteLineEvent += System.Console.Error.WriteLine;
if(opts.Verbose)
DicConsole.VerboseWriteLineEvent += System.Console.WriteLine;
PrintCopyright();
Commands.Formats.ListFormats(opts);
})
.WithParsed<BenchmarkOptions>(opts =>
{
if(opts.Debug)
DicConsole.DebugWriteLineEvent += System.Console.Error.WriteLine;
if(opts.Verbose)
DicConsole.VerboseWriteLineEvent += System.Console.WriteLine;
PrintCopyright();
Commands.Benchmark.doBenchmark(opts);
})
.WithParsed<CreateSidecarOptions>(opts =>
{
if(opts.Debug)
DicConsole.DebugWriteLineEvent += System.Console.Error.WriteLine;
if(opts.Verbose)
DicConsole.VerboseWriteLineEvent += System.Console.WriteLine;
PrintCopyright();
Commands.CreateSidecar.doSidecar(opts);
})
.WithParsed<DumpMediaOptions>(opts =>
{
if(opts.Debug)
DicConsole.DebugWriteLineEvent += System.Console.Error.WriteLine;
if(opts.Verbose)
DicConsole.VerboseWriteLineEvent += System.Console.WriteLine;
PrintCopyright();
Commands.DumpMedia.doDumpMedia(opts);
})
.WithParsed<DeviceReportOptions>(opts =>
{
if(opts.Debug)
DicConsole.DebugWriteLineEvent += System.Console.Error.WriteLine;
if(opts.Verbose)
DicConsole.VerboseWriteLineEvent += System.Console.WriteLine;
PrintCopyright();
Commands.DeviceReport.doDeviceReport(opts);
})
.WithParsed<LsOptions>(opts =>
{
if(opts.Debug)
DicConsole.DebugWriteLineEvent += System.Console.Error.WriteLine;
if(opts.Verbose)
DicConsole.VerboseWriteLineEvent += System.Console.WriteLine;
PrintCopyright();
Commands.Ls.doLs(opts);
})
.WithParsed<ExtractFilesOptions>(opts =>
{
if(opts.Debug)
DicConsole.DebugWriteLineEvent += System.Console.Error.WriteLine;
if(opts.Verbose)
DicConsole.VerboseWriteLineEvent += System.Console.WriteLine;
PrintCopyright();
Commands.ExtractFiles.doExtractFiles(opts);
})
.WithParsed<ListDevicesOptions>(opts =>
{
if(opts.Debug)
DicConsole.DebugWriteLineEvent += System.Console.Error.WriteLine;
if(opts.Verbose)
DicConsole.VerboseWriteLineEvent += System.Console.WriteLine;
PrintCopyright();
Commands.ListDevices.doListDevices(opts);
})
.WithParsed<ListEncodingsOptions>(opts =>
{
if(opts.Debug)
DicConsole.DebugWriteLineEvent += System.Console.Error.WriteLine;
if(opts.Verbose)
DicConsole.VerboseWriteLineEvent += System.Console.WriteLine;
PrintCopyright();
Commands.ListEncodings.DoList(opts);
})
.WithParsed<ConfigureOptions>(opts => { PrintCopyright(); Commands.Configure.doConfigure(); })
.WithParsed<StatsOptions>(opts => { PrintCopyright(); Commands.Statistics.showStats(); })
.WithNotParsed(errs => Environment.Exit(1));
}).WithParsed<CompareOptions>(opts =>
{
if(opts.Debug) DicConsole.DebugWriteLineEvent += System.Console.Error.WriteLine;
if(opts.Verbose) DicConsole.VerboseWriteLineEvent += System.Console.WriteLine;
PrintCopyright();
Commands.Compare.doCompare(opts);
}).WithParsed<ChecksumOptions>(opts =>
{
if(opts.Debug) DicConsole.DebugWriteLineEvent += System.Console.Error.WriteLine;
if(opts.Verbose) DicConsole.VerboseWriteLineEvent += System.Console.WriteLine;
PrintCopyright();
Commands.Checksum.doChecksum(opts);
}).WithParsed<EntropyOptions>(opts =>
{
if(opts.Debug) DicConsole.DebugWriteLineEvent += System.Console.Error.WriteLine;
if(opts.Verbose) DicConsole.VerboseWriteLineEvent += System.Console.WriteLine;
PrintCopyright();
Commands.Entropy.doEntropy(opts);
}).WithParsed<VerifyOptions>(opts =>
{
if(opts.Debug) DicConsole.DebugWriteLineEvent += System.Console.Error.WriteLine;
if(opts.Verbose) DicConsole.VerboseWriteLineEvent += System.Console.WriteLine;
PrintCopyright();
Commands.Verify.doVerify(opts);
}).WithParsed<PrintHexOptions>(opts =>
{
if(opts.Debug) DicConsole.DebugWriteLineEvent += System.Console.Error.WriteLine;
if(opts.Verbose) DicConsole.VerboseWriteLineEvent += System.Console.WriteLine;
PrintCopyright();
Commands.PrintHex.doPrintHex(opts);
}).WithParsed<DecodeOptions>(opts =>
{
if(opts.Debug) DicConsole.DebugWriteLineEvent += System.Console.Error.WriteLine;
if(opts.Verbose) DicConsole.VerboseWriteLineEvent += System.Console.WriteLine;
PrintCopyright();
Commands.Decode.doDecode(opts);
}).WithParsed<DeviceInfoOptions>(opts =>
{
if(opts.Debug) DicConsole.DebugWriteLineEvent += System.Console.Error.WriteLine;
if(opts.Verbose) DicConsole.VerboseWriteLineEvent += System.Console.WriteLine;
PrintCopyright();
Commands.DeviceInfo.doDeviceInfo(opts);
}).WithParsed<MediaInfoOptions>(opts =>
{
if(opts.Debug) DicConsole.DebugWriteLineEvent += System.Console.Error.WriteLine;
if(opts.Verbose) DicConsole.VerboseWriteLineEvent += System.Console.WriteLine;
PrintCopyright();
Commands.MediaInfo.doMediaInfo(opts);
}).WithParsed<MediaScanOptions>(opts =>
{
if(opts.Debug) DicConsole.DebugWriteLineEvent += System.Console.Error.WriteLine;
if(opts.Verbose) DicConsole.VerboseWriteLineEvent += System.Console.WriteLine;
PrintCopyright();
Commands.MediaScan.doMediaScan(opts);
}).WithParsed<FormatsOptions>(opts =>
{
if(opts.Debug) DicConsole.DebugWriteLineEvent += System.Console.Error.WriteLine;
if(opts.Verbose) DicConsole.VerboseWriteLineEvent += System.Console.WriteLine;
PrintCopyright();
Commands.Formats.ListFormats(opts);
}).WithParsed<BenchmarkOptions>(opts =>
{
if(opts.Debug) DicConsole.DebugWriteLineEvent += System.Console.Error.WriteLine;
if(opts.Verbose) DicConsole.VerboseWriteLineEvent += System.Console.WriteLine;
PrintCopyright();
Commands.Benchmark.doBenchmark(opts);
}).WithParsed<CreateSidecarOptions>(opts =>
{
if(opts.Debug) DicConsole.DebugWriteLineEvent += System.Console.Error.WriteLine;
if(opts.Verbose) DicConsole.VerboseWriteLineEvent += System.Console.WriteLine;
PrintCopyright();
Commands.CreateSidecar.doSidecar(opts);
}).WithParsed<DumpMediaOptions>(opts =>
{
if(opts.Debug) DicConsole.DebugWriteLineEvent += System.Console.Error.WriteLine;
if(opts.Verbose) DicConsole.VerboseWriteLineEvent += System.Console.WriteLine;
PrintCopyright();
Commands.DumpMedia.doDumpMedia(opts);
}).WithParsed<DeviceReportOptions>(opts =>
{
if(opts.Debug) DicConsole.DebugWriteLineEvent += System.Console.Error.WriteLine;
if(opts.Verbose) DicConsole.VerboseWriteLineEvent += System.Console.WriteLine;
PrintCopyright();
Commands.DeviceReport.doDeviceReport(opts);
}).WithParsed<LsOptions>(opts =>
{
if(opts.Debug) DicConsole.DebugWriteLineEvent += System.Console.Error.WriteLine;
if(opts.Verbose) DicConsole.VerboseWriteLineEvent += System.Console.WriteLine;
PrintCopyright();
Commands.Ls.doLs(opts);
}).WithParsed<ExtractFilesOptions>(opts =>
{
if(opts.Debug) DicConsole.DebugWriteLineEvent += System.Console.Error.WriteLine;
if(opts.Verbose) DicConsole.VerboseWriteLineEvent += System.Console.WriteLine;
PrintCopyright();
Commands.ExtractFiles.doExtractFiles(opts);
}).WithParsed<ListDevicesOptions>(opts =>
{
if(opts.Debug) DicConsole.DebugWriteLineEvent += System.Console.Error.WriteLine;
if(opts.Verbose) DicConsole.VerboseWriteLineEvent += System.Console.WriteLine;
PrintCopyright();
Commands.ListDevices.doListDevices(opts);
}).WithParsed<ListEncodingsOptions>(opts =>
{
if(opts.Debug) DicConsole.DebugWriteLineEvent += System.Console.Error.WriteLine;
if(opts.Verbose) DicConsole.VerboseWriteLineEvent += System.Console.WriteLine;
PrintCopyright();
Commands.ListEncodings.DoList(opts);
}).WithParsed<ConfigureOptions>(opts =>
{
PrintCopyright();
Commands.Configure.doConfigure();
}).WithParsed<StatsOptions>(opts =>
{
PrintCopyright();
Commands.Statistics.showStats();
}).WithNotParsed(errs => Environment.Exit(1));
Core.Statistics.SaveStats();
}
@@ -266,5 +201,4 @@ namespace DiscImageChef
DicConsole.WriteLine();
}
}
}
}

View File

@@ -46,12 +46,10 @@ namespace DiscImageChef
[Verb("analyze", HelpText = "Analyzes a disc image and searches for partitions and/or filesystems.")]
public class AnalyzeOptions : CommonOptions
{
[Option('p', "partitions", Default = true,
HelpText = "Searches and interprets partitions.")]
[Option('p', "partitions", Default = true, HelpText = "Searches and interprets partitions.")]
public bool SearchForPartitions { get; set; }
[Option('f', "filesystems", Default = true,
HelpText = "Searches and interprets partitions.")]
[Option('f', "filesystems", Default = true, HelpText = "Searches and interprets partitions.")]
public bool SearchForFilesystems { get; set; }
[Option('i', "input", Required = true, HelpText = "Disc image.")]
@@ -74,28 +72,22 @@ namespace DiscImageChef
[Verb("checksum", HelpText = "Checksums an image.")]
public class ChecksumOptions : CommonOptions
{
[Option('t', "separated-tracks", Default = true,
HelpText = "Checksums each track separately.")]
[Option('t', "separated-tracks", Default = true, HelpText = "Checksums each track separately.")]
public bool SeparatedTracks { get; set; }
[Option('w', "whole-disc", Default = true,
HelpText = "Checksums the whole disc.")]
[Option('w', "whole-disc", Default = true, HelpText = "Checksums the whole disc.")]
public bool WholeDisc { get; set; }
[Option('a', "adler32", Default = true,
HelpText = "Calculates Adler-32.")]
[Option('a', "adler32", Default = true, HelpText = "Calculates Adler-32.")]
public bool DoAdler32 { get; set; }
[Option("crc16", Default = true,
HelpText = "Calculates CRC16.")]
[Option("crc16", Default = true, HelpText = "Calculates CRC16.")]
public bool DoCRC16 { get; set; }
[Option('c', "crc32", Default = true,
HelpText = "Calculates CRC32.")]
[Option('c', "crc32", Default = true, HelpText = "Calculates CRC32.")]
public bool DoCRC32 { get; set; }
[Option("crc64", Default = false,
HelpText = "Calculates CRC64 (ECMA).")]
[Option("crc64", Default = false, HelpText = "Calculates CRC64 (ECMA).")]
public bool DoCRC64 { get; set; }
/*[Option("fletcher16", Default = false,
@@ -106,32 +98,25 @@ namespace DiscImageChef
HelpText = "Calculates Fletcher-32.")]
public bool DoFletcher32 { get; set; }*/
[Option('m', "md5", Default = true,
HelpText = "Calculates MD5.")]
[Option('m', "md5", Default = true, HelpText = "Calculates MD5.")]
public bool DoMD5 { get; set; }
[Option("ripemd160", Default = false,
HelpText = "Calculates RIPEMD160.")]
[Option("ripemd160", Default = false, HelpText = "Calculates RIPEMD160.")]
public bool DoRIPEMD160 { get; set; }
[Option('s', "sha1", Default = true,
HelpText = "Calculates SHA1.")]
[Option('s', "sha1", Default = true, HelpText = "Calculates SHA1.")]
public bool DoSHA1 { get; set; }
[Option("sha256", Default = false,
HelpText = "Calculates SHA256.")]
[Option("sha256", Default = false, HelpText = "Calculates SHA256.")]
public bool DoSHA256 { get; set; }
[Option("sha384", Default = false,
HelpText = "Calculates SHA384.")]
[Option("sha384", Default = false, HelpText = "Calculates SHA384.")]
public bool DoSHA384 { get; set; }
[Option("sha512", Default = false,
HelpText = "Calculates SHA512.")]
[Option("sha512", Default = false, HelpText = "Calculates SHA512.")]
public bool DoSHA512 { get; set; }
[Option('f', "spamsum", Default = true,
HelpText = "Calculates SpamSum fuzzy hash.")]
[Option('f', "spamsum", Default = true, HelpText = "Calculates SpamSum fuzzy hash.")]
public bool DoSpamSum { get; set; }
[Option('i', "input", Required = true, HelpText = "Disc image.")]
@@ -145,12 +130,10 @@ namespace DiscImageChef
HelpText = "Calculates how many sectors are duplicated (have same exact data in user area).")]
public bool DuplicatedSectors { get; set; }
[Option('t', "separated-tracks", Default = true,
HelpText = "Calculates entropy for each track separately.")]
[Option('t', "separated-tracks", Default = true, HelpText = "Calculates entropy for each track separately.")]
public bool SeparatedTracks { get; set; }
[Option('w', "whole-disc", Default = true,
HelpText = "Calculates entropy for the whole disc.")]
[Option('w', "whole-disc", Default = true, HelpText = "Calculates entropy for the whole disc.")]
public bool WholeDisc { get; set; }
[Option('i', "input", Required = true, HelpText = "Disc image.")]
@@ -160,12 +143,10 @@ namespace DiscImageChef
[Verb("verify", HelpText = "Verifies a disc image integrity, and if supported, sector integrity.")]
public class VerifyOptions : CommonOptions
{
[Option('w', "verify-disc", Default = true,
HelpText = "Verify disc image if supported.")]
[Option('w', "verify-disc", Default = true, HelpText = "Verify disc image if supported.")]
public bool VerifyDisc { get; set; }
[Option('s', "verify-sectors", Default = true,
HelpText = "Verify all sectors if supported.")]
[Option('s', "verify-sectors", Default = true, HelpText = "Verify all sectors if supported.")]
public bool VerifySectors { get; set; }
[Option('i', "input", Required = true, HelpText = "Disc image.")]
@@ -175,20 +156,16 @@ namespace DiscImageChef
[Verb("printhex", HelpText = "Prints a sector, in hexadecimal values, to the console.")]
public class PrintHexOptions : CommonOptions
{
[Option('s', "start", Required = true,
HelpText = "Start sector.")]
[Option('s', "start", Required = true, HelpText = "Start sector.")]
public ulong StartSector { get; set; }
[Option('l', "length", Default = (ulong)1,
HelpText = "How many sectors to print.")]
[Option('l', "length", Default = (ulong)1, HelpText = "How many sectors to print.")]
public ulong Length { get; set; }
[Option('r', "long-sectors", Default = false,
HelpText = "Print sectors with tags included.")]
[Option('r', "long-sectors", Default = false, HelpText = "Print sectors with tags included.")]
public bool LongSectors { get; set; }
[Option('w', "width", Default = (ushort)32,
HelpText = "How many bytes to print per line.")]
[Option('w', "width", Default = (ushort)32, HelpText = "How many bytes to print per line.")]
public ushort WidthBytes { get; set; }
[Option('i', "input", Required = true, HelpText = "Disc image.")]
@@ -198,20 +175,16 @@ namespace DiscImageChef
[Verb("decode", HelpText = "Decodes and pretty prints disk and/or sector tags.")]
public class DecodeOptions : CommonOptions
{
[Option('s', "start", Default = (ulong)0,
HelpText = "Start sector.")]
[Option('s', "start", Default = (ulong)0, HelpText = "Start sector.")]
public ulong StartSector { get; set; }
[Option('l', "length", Default = "all",
HelpText = "How many sectors to decode, or \"all\".")]
[Option('l', "length", Default = "all", HelpText = "How many sectors to decode, or \"all\".")]
public string Length { get; set; }
[Option('k', "disk-tags", Default = true,
HelpText = "Decode disk tags.")]
[Option('k', "disk-tags", Default = true, HelpText = "Decode disk tags.")]
public bool DiskTags { get; set; }
[Option('t', "sector-tags", Default = true,
HelpText = "Decode sector tags.")]
[Option('t', "sector-tags", Default = true, HelpText = "Decode sector tags.")]
public bool SectorTags { get; set; }
[Option('i', "input", Required = true, HelpText = "Disc image.")]
@@ -224,7 +197,8 @@ namespace DiscImageChef
[Option('i', "device", Required = true, HelpText = "Device path.")]
public string DevicePath { get; set; }
[Option('w', "output-prefix", Required = false, Default = "", HelpText = "Write binary responses from device with that prefix.")]
[Option('w', "output-prefix", Required = false, Default = "",
HelpText = "Write binary responses from device with that prefix.")]
public string OutputPrefix { get; set; }
}
@@ -234,7 +208,8 @@ namespace DiscImageChef
[Option('i', "device", Required = true, HelpText = "Device path.")]
public string DevicePath { get; set; }
[Option('w', "output-prefix", Required = false, Default = "", HelpText = "Write binary responses from device with that prefix.")]
[Option('w', "output-prefix", Required = false, Default = "",
HelpText = "Write binary responses from device with that prefix.")]
public string OutputPrefix { get; set; }
}
@@ -244,17 +219,17 @@ namespace DiscImageChef
[Option('i', "device", Required = true, HelpText = "Device path.")]
public string DevicePath { get; set; }
[Option('m', "mhdd-log", Required = false, Default = "", HelpText = "Write a log of the scan in the format used by MHDD.")]
[Option('m', "mhdd-log", Required = false, Default = "",
HelpText = "Write a log of the scan in the format used by MHDD.")]
public string MHDDLogPath { get; set; }
[Option('b', "ibg-log", Required = false, Default = "", HelpText = "Write a log of the scan in the format used by ImgBurn.")]
[Option('b', "ibg-log", Required = false, Default = "",
HelpText = "Write a log of the scan in the format used by ImgBurn.")]
public string IBGLogPath { get; set; }
}
[Verb("formats", HelpText = "Lists all supported disc images, partition schemes and file systems.")]
public class FormatsOptions : CommonOptions
{
}
public class FormatsOptions : CommonOptions { }
[Verb("benchmark", HelpText = "Benchmarks hashing and entropy calculation.")]
public class BenchmarkOptions : CommonOptions
@@ -271,9 +246,13 @@ namespace DiscImageChef
{
[Option('i', "input", Required = true, HelpText = "Disc image.")]
public string InputFile { get; set; }
[Option('t', "tape", Required = false, Default = false, HelpText = "When used indicates that input is a folder containing alphabetically sorted files extracted from a linear block-based tape with fixed block size (e.g. a SCSI tape device).")]
[Option('t', "tape", Required = false, Default = false,
HelpText =
"When used indicates that input is a folder containing alphabetically sorted files extracted from a linear block-based tape with fixed block size (e.g. a SCSI tape device).")]
public bool Tape { get; set; }
[Option('b', "block-size", Required = false, Default = 512, HelpText = "Only used for tapes, indicates block size. Files in the folder whose size is not a multiple of this value will simply be ignored.")]
[Option('b', "block-size", Required = false, Default = 512,
HelpText =
"Only used for tapes, indicates block size. Files in the folder whose size is not a multiple of this value will simply be ignored.")]
public int BlockSize { get; set; }
[Option('e', "encoding", Default = null, HelpText = "Name of character encoding to use.")]
@@ -293,28 +272,23 @@ namespace DiscImageChef
HelpText = "Dump sectors with tags included. For optical media, dump scrambled sectors")]
public bool Raw { get; set; }
[Option('s', "stop-on-error", Default = false,
HelpText = "Stop media dump on first error.")]
[Option('s', "stop-on-error", Default = false, HelpText = "Stop media dump on first error.")]
public bool StopOnError { get; set; }
[Option('f', "force", Default = false,
HelpText = "Continue dump whatever happens.")]
[Option('f', "force", Default = false, HelpText = "Continue dump whatever happens.")]
public bool Force { get; set; }
[Option('p', "retry-passes", Default = (ushort)5,
HelpText = "How many retry passes to do.")]
[Option('p', "retry-passes", Default = (ushort)5, HelpText = "How many retry passes to do.")]
public ushort RetryPasses { get; set; }
[Option("persistent", Default = false,
HelpText = "Try to recover partial or incorrect data.")]
[Option("persistent", Default = false, HelpText = "Try to recover partial or incorrect data.")]
public bool Persistent { get; set; }
[Option("separate-subchannel", Default = false,
HelpText = "Save subchannel in a separate file. Only applicable to CD/DDCD/GD.")]
HelpText = "Save subchannel in a separate file. Only applicable to CD/DDCD/GD.")]
public bool SeparateSubchannel { get; set; }
[Option('m', "resume", Default = true,
HelpText = "Create/use resume mapfile.")]
[Option('m', "resume", Default = true, HelpText = "Create/use resume mapfile.")]
public bool Resume { get; set; }
[Option("lead-in", Default = false, HelpText = "Try to read lead-in. Only applicable to CD/DDCD/GD.")]
@@ -332,14 +306,10 @@ namespace DiscImageChef
}
[Verb("configure", HelpText = "Configures user settings and statistics.")]
public class ConfigureOptions
{
}
public class ConfigureOptions { }
[Verb("stats", HelpText = "Shows statistics.")]
public class StatsOptions
{
}
public class StatsOptions { }
[Verb("ls", HelpText = "Lists files in disc image.")]
public class LsOptions : CommonOptions
@@ -360,7 +330,8 @@ namespace DiscImageChef
[Option('i', "input", Required = true, HelpText = "Disc image.")]
public string InputFile { get; set; }
[Option('o', "output", Required = true, HelpText = "Directory where extracted files will be created. Will abort if it exists.")]
[Option('o', "output", Required = true,
HelpText = "Directory where extracted files will be created. Will abort if it exists.")]
public string OutputDir { get; set; }
[Option('x', "xattrs", Default = false, HelpText = "Extract extended attributes if present.")]
@@ -371,13 +342,8 @@ namespace DiscImageChef
}
[Verb("list-devices", HelpText = "Lists all connected devices.")]
public class ListDevicesOptions : CommonOptions
{
}
public class ListDevicesOptions : CommonOptions { }
[Verb("list-encodings", HelpText = "Lists all supported text encodings and code pages.")]
public class ListEncodingsOptions : CommonOptions
{
}
}
public class ListEncodingsOptions : CommonOptions { }
}

View File

@@ -36,9 +36,7 @@ namespace DiscImageChef
{
public static class Progress
{
public static void InitProgress()
{
}
public static void InitProgress() { }
public static void EndProgress()
{
@@ -50,9 +48,7 @@ namespace DiscImageChef
DicConsole.Write("\r" + text);
}
public static void InitProgress2()
{
}
public static void InitProgress2() { }
public static void EndProgress2()
{
@@ -64,16 +60,15 @@ namespace DiscImageChef
DicConsole.Write("\r" + text);
}
public static void InitTwoProgress()
{
}
public static void InitTwoProgress() { }
public static void EndTwoProgress()
{
DicConsole.WriteLine();
}
public static void UpdateTwoProgress(string text, long current, long maximum, string text2, long current2, long maximum2)
public static void UpdateTwoProgress(string text, long current, long maximum, string text2, long current2,
long maximum2)
{
DicConsole.Write("\r" + text + ": " + text2);
}
@@ -83,4 +78,4 @@ namespace DiscImageChef
DicConsole.WriteLine(text);
}
}
}
}

View File

@@ -1,6 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="Claunia.Encoding" version="1.2.9.1" targetFramework="net40" />
<package id="CommandLineParser" version="2.1.1-beta" targetFramework="net40" />
<package id="SharpCompress" version="0.19.2" targetFramework="net40" />
<package id="Claunia.Encoding" version="1.2.9.1" targetFramework="net40" />
<package id="CommandLineParser" version="2.1.1-beta" targetFramework="net40" />
<package id="SharpCompress" version="0.19.2" targetFramework="net40" />
</packages>