Code cleanup.

This commit is contained in:
2018-06-22 08:08:38 +01:00
parent 82f474c7e3
commit 88da8fc019
581 changed files with 22423 additions and 20839 deletions

View File

@@ -46,15 +46,15 @@ namespace DiscImageChef.Commands
{
internal static void DoAnalyze(AnalyzeOptions options)
{
DicConsole.DebugWriteLine("Analyze command", "--debug={0}", options.Debug);
DicConsole.DebugWriteLine("Analyze command", "--verbose={0}", options.Verbose);
DicConsole.DebugWriteLine("Analyze command", "--input={0}", options.InputFile);
DicConsole.DebugWriteLine("Analyze command", "--debug={0}", options.Debug);
DicConsole.DebugWriteLine("Analyze command", "--verbose={0}", options.Verbose);
DicConsole.DebugWriteLine("Analyze command", "--input={0}", options.InputFile);
DicConsole.DebugWriteLine("Analyze command", "--filesystems={0}", options.SearchForFilesystems);
DicConsole.DebugWriteLine("Analyze command", "--partitions={0}", options.SearchForPartitions);
DicConsole.DebugWriteLine("Analyze command", "--encoding={0}", options.EncodingName);
DicConsole.DebugWriteLine("Analyze command", "--partitions={0}", options.SearchForPartitions);
DicConsole.DebugWriteLine("Analyze command", "--encoding={0}", options.EncodingName);
FiltersList filtersList = new FiltersList();
IFilter inputFilter = filtersList.GetFilter(options.InputFile);
IFilter inputFilter = filtersList.GetFilter(options.InputFile);
if(inputFilter == null)
{
@@ -124,8 +124,8 @@ namespace DiscImageChef.Commands
}
List<string> idPlugins;
IFilesystem plugin;
string information;
IFilesystem plugin;
string information;
if(options.SearchForPartitions)
{
List<Partition> partitions = Core.Partitions.GetAll(imageFormat);
@@ -149,7 +149,7 @@ namespace DiscImageChef.Commands
for(int i = 0; i < partitions.Count; i++)
{
DicConsole.WriteLine();
DicConsole.WriteLine("Partition {0}:", partitions[i].Sequence);
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,
@@ -165,7 +165,7 @@ namespace DiscImageChef.Commands
DicConsole.WriteLine("Identifying filesystem on partition");
Core.Filesystems.Identify(imageFormat, out idPlugins, partitions[i]);
if(idPlugins.Count == 0) DicConsole.WriteLine("Filesystem not identified");
if(idPlugins.Count == 0) DicConsole.WriteLine("Filesystem not identified");
else if(idPlugins.Count > 1)
{
DicConsole.WriteLine($"Identified by {idPlugins.Count} plugins");
@@ -197,13 +197,13 @@ namespace DiscImageChef.Commands
{
Partition wholePart = new Partition
{
Name = "Whole device",
Name = "Whole device",
Length = imageFormat.Info.Sectors,
Size = imageFormat.Info.Sectors * imageFormat.Info.SectorSize
Size = imageFormat.Info.Sectors * imageFormat.Info.SectorSize
};
Core.Filesystems.Identify(imageFormat, out idPlugins, wholePart);
if(idPlugins.Count == 0) DicConsole.WriteLine("Filesystem not identified");
if(idPlugins.Count == 0) DicConsole.WriteLine("Filesystem not identified");
else if(idPlugins.Count > 1)
{
DicConsole.WriteLine($"Identified by {idPlugins.Count} plugins");

View File

@@ -41,9 +41,9 @@ namespace DiscImageChef.Commands
internal static void DoBenchmark(BenchmarkOptions options)
{
Dictionary<string, double> checksumTimes = new Dictionary<string, double>();
Core.Benchmark.InitProgressEvent += Progress.InitProgress;
Core.Benchmark.InitProgressEvent += Progress.InitProgress;
Core.Benchmark.UpdateProgressEvent += Progress.UpdateProgress;
Core.Benchmark.EndProgressEvent += Progress.EndProgress;
Core.Benchmark.EndProgressEvent += Progress.EndProgress;
BenchmarkResults results = Core.Benchmark.Do(options.BufferSize * 1024 * 1024, options.BlockSize);

View File

@@ -47,27 +47,27 @@ namespace DiscImageChef.Commands
internal static void DoChecksum(ChecksumOptions options)
{
DicConsole.DebugWriteLine("Checksum command", "--debug={0}", options.Debug);
DicConsole.DebugWriteLine("Checksum command", "--verbose={0}", options.Verbose);
DicConsole.DebugWriteLine("Checksum command", "--debug={0}", options.Debug);
DicConsole.DebugWriteLine("Checksum command", "--verbose={0}", options.Verbose);
DicConsole.DebugWriteLine("Checksum command", "--separated-tracks={0}", options.SeparatedTracks);
DicConsole.DebugWriteLine("Checksum command", "--whole-disc={0}", options.WholeDisc);
DicConsole.DebugWriteLine("Checksum command", "--input={0}", options.InputFile);
DicConsole.DebugWriteLine("Checksum command", "--adler32={0}", options.DoAdler32);
DicConsole.DebugWriteLine("Checksum command", "--crc16={0}", options.DoCrc16);
DicConsole.DebugWriteLine("Checksum command", "--crc32={0}", options.DoCrc32);
DicConsole.DebugWriteLine("Checksum command", "--crc64={0}", options.DoCrc64);
DicConsole.DebugWriteLine("Checksum command", "--md5={0}", options.DoMd5);
DicConsole.DebugWriteLine("Checksum command", "--ripemd160={0}", options.DoRipemd160);
DicConsole.DebugWriteLine("Checksum command", "--sha1={0}", options.DoSha1);
DicConsole.DebugWriteLine("Checksum command", "--sha256={0}", options.DoSha256);
DicConsole.DebugWriteLine("Checksum command", "--sha384={0}", options.DoSha384);
DicConsole.DebugWriteLine("Checksum command", "--sha512={0}", options.DoSha512);
DicConsole.DebugWriteLine("Checksum command", "--spamsum={0}", options.DoSpamSum);
DicConsole.DebugWriteLine("Checksum command", "--fletcher16={0}", options.DoFletcher16);
DicConsole.DebugWriteLine("Checksum command", "--fletcher32={0}", options.DoFletcher32);
DicConsole.DebugWriteLine("Checksum command", "--whole-disc={0}", options.WholeDisc);
DicConsole.DebugWriteLine("Checksum command", "--input={0}", options.InputFile);
DicConsole.DebugWriteLine("Checksum command", "--adler32={0}", options.DoAdler32);
DicConsole.DebugWriteLine("Checksum command", "--crc16={0}", options.DoCrc16);
DicConsole.DebugWriteLine("Checksum command", "--crc32={0}", options.DoCrc32);
DicConsole.DebugWriteLine("Checksum command", "--crc64={0}", options.DoCrc64);
DicConsole.DebugWriteLine("Checksum command", "--md5={0}", options.DoMd5);
DicConsole.DebugWriteLine("Checksum command", "--ripemd160={0}", options.DoRipemd160);
DicConsole.DebugWriteLine("Checksum command", "--sha1={0}", options.DoSha1);
DicConsole.DebugWriteLine("Checksum command", "--sha256={0}", options.DoSha256);
DicConsole.DebugWriteLine("Checksum command", "--sha384={0}", options.DoSha384);
DicConsole.DebugWriteLine("Checksum command", "--sha512={0}", options.DoSha512);
DicConsole.DebugWriteLine("Checksum command", "--spamsum={0}", options.DoSpamSum);
DicConsole.DebugWriteLine("Checksum command", "--fletcher16={0}", options.DoFletcher16);
DicConsole.DebugWriteLine("Checksum command", "--fletcher32={0}", options.DoFletcher32);
FiltersList filtersList = new FiltersList();
IFilter inputFilter = filtersList.GetFilter(options.InputFile);
IFilter inputFilter = filtersList.GetFilter(options.InputFile);
if(inputFilter == null)
{
@@ -89,17 +89,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;
if(options.DoFletcher16) enabledChecksums |= EnableChecksum.Fletcher16;
if(options.DoFletcher32) enabledChecksums |= EnableChecksum.Fletcher32;
@@ -134,7 +134,7 @@ namespace DiscImageChef.Commands
if(options.SeparatedTracks) trackChecksum = new Core.Checksum(enabledChecksums);
ulong sectors = currentTrack.TrackEndSector - currentTrack.TrackStartSector + 1;
ulong sectors = currentTrack.TrackEndSector - currentTrack.TrackStartSector + 1;
ulong doneSectors = 0;
DicConsole.WriteLine("Track {0} has {1} sectors", currentTrack.TrackSequence, sectors);

View File

@@ -51,8 +51,8 @@ namespace DiscImageChef.Commands
FiltersList filtersList = new FiltersList();
IFilter inputFilter1 = filtersList.GetFilter(options.InputFile1);
filtersList = new FiltersList();
IFilter inputFilter2 = filtersList.GetFilter(options.InputFile2);
filtersList = new FiltersList();
IFilter inputFilter2 = filtersList.GetFilter(options.InputFile2);
if(inputFilter1 == null)
{
@@ -107,8 +107,8 @@ namespace DiscImageChef.Commands
{
sb.AppendLine("\tDisc image 1\tDisc image 2");
sb.AppendLine("================================");
sb.AppendFormat("File\t{0}\t{1}", options.InputFile1, options.InputFile2).AppendLine();
sb.AppendFormat("Disc image format\t{0}\t{1}", input1Format.Name, input2Format.Name).AppendLine();
sb.AppendFormat("File\t{0}\t{1}", options.InputFile1, options.InputFile2).AppendLine();
sb.AppendFormat("Disc image format\t{0}\t{1}", input1Format.Name, input2Format.Name).AppendLine();
}
else
{
@@ -223,25 +223,23 @@ namespace DiscImageChef.Commands
{
sb.AppendFormat("Has partitions?\t{0}\t{1}", image1Info.HasPartitions, image2Info.HasPartitions)
.AppendLine();
sb.AppendFormat("Has sessions?\t{0}\t{1}", image1Info.HasSessions, image2Info.HasSessions)
.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("Has sessions?\t{0}\t{1}", image1Info.HasSessions, image2Info.HasSessions).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.CreationTime, image2Info.CreationTime)
.AppendLine();
sb.AppendFormat("Last modification time\t{0}\t{1}", image1Info.LastModificationTime,
image2Info.LastModificationTime).AppendLine();
sb.AppendFormat("Disk type\t{0}\t{1}", image1Info.MediaType, image2Info.MediaType)
.AppendLine();
sb.AppendFormat("Image version\t{0}\t{1}", image1Info.Version, image2Info.Version).AppendLine();
sb.AppendFormat("Disk type\t{0}\t{1}", image1Info.MediaType, image2Info.MediaType).AppendLine();
sb.AppendFormat("Image version\t{0}\t{1}", image1Info.Version, image2Info.Version).AppendLine();
sb.AppendFormat("Image application\t{0}\t{1}", image1Info.Application, image2Info.Application)
.AppendLine();
sb.AppendFormat("Image application version\t{0}\t{1}", image1Info.ApplicationVersion,
image2Info.ApplicationVersion).AppendLine();
sb.AppendFormat("Image creator\t{0}\t{1}", image1Info.Creator, image2Info.Creator).AppendLine();
sb.AppendFormat("Image name\t{0}\t{1}", image1Info.MediaTitle, image2Info.MediaTitle).AppendLine();
sb.AppendFormat("Image comments\t{0}\t{1}", image1Info.Comments, image2Info.Comments).AppendLine();
sb.AppendFormat("Image creator\t{0}\t{1}", image1Info.Creator, image2Info.Creator).AppendLine();
sb.AppendFormat("Image name\t{0}\t{1}", image1Info.MediaTitle, image2Info.MediaTitle).AppendLine();
sb.AppendFormat("Image comments\t{0}\t{1}", image1Info.Comments, image2Info.Comments).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();
@@ -432,8 +430,7 @@ namespace DiscImageChef.Commands
leastSectors = image2Info.Sectors;
if(!options.Verbose) sb.AppendLine("Image 1 has more sectors");
}
else
leastSectors = image1Info.Sectors;
else leastSectors = image1Info.Sectors;
DicConsole.WriteLine("Comparing sectors...");

View File

@@ -51,21 +51,23 @@ namespace DiscImageChef.Commands
"authors. In case of doubt, close DiscImageChef now and ask in our IRC support channel.");
DicConsole.WriteLine();
DicConsole.WriteLine("For any information sharing your IP address may be stored in our server, in a way that is not\n" +
"possible for any person, manual, or automated process, to link with your identity, unless\n" +
"possible for any person, manual, or automated process, to link with your identity, unless\n" +
"specified otherwise.");
}
ConsoleKeyInfo pressedKey = new ConsoleKeyInfo();
#region Device reports
DicConsole.WriteLine();
DicConsole.WriteLine("With the 'device-report' command, DiscImageChef creates a report of a device, that includes its\n" +
"manufacturer, model, firmware revision and/or version, attached bus, size, and supported commands.\n" +
"The serial number of the device is not stored in the report. If used with the debug parameter,\n" +
DicConsole.WriteLine(
"With the 'device-report' command, DiscImageChef creates a report of a device, that includes its\n" +
"manufacturer, model, firmware revision and/or version, attached bus, size, and supported commands.\n" +
"The serial number of the device is not stored in the report. If used with the debug parameter,\n" +
"extra information about the device will be stored in the report. This information is known to contain\n" +
"the device serial number in non-standard places that prevent the automatic removal of it on a handful\n" +
"of devices. A human-readable copy of the report in XML format is always created in the same directory\n" +
"where DiscImageChef is being run from.");
while(pressedKey.Key != ConsoleKey.Y && pressedKey.Key != ConsoleKey.N)
{
DicConsole.Write("Do you want to save device reports in shared folder of your computer? (Y/N): ");
@@ -77,9 +79,9 @@ namespace DiscImageChef.Commands
pressedKey = new ConsoleKeyInfo();
DicConsole.WriteLine();
DicConsole.WriteLine("Sharing a report with us will send it to our server, that's in the european union territory, where it\n" +
"will be manually analized by an european union citizen to remove any trace of personal identification\n" +
"from it. Once that is done, it will be shared in our stats website, http://discimagechef.claunia.com\n" +
DicConsole.WriteLine("Sharing a report with us will send it to our server, that's in the european union territory, where it\n" +
"will be manually analized by an european union citizen to remove any trace of personal identification\n" +
"from it. Once that is done, it will be shared in our stats website, http://discimagechef.claunia.com\n" +
"These report will be used to improve DiscImageChef support, and in some cases, to provide emulation of the\n" +
"devices to other open-source projects. In any case, no information linking the report to you will be stored.");
while(pressedKey.Key != ConsoleKey.Y && pressedKey.Key != ConsoleKey.N)
@@ -91,14 +93,14 @@ namespace DiscImageChef.Commands
Settings.Settings.Current.ShareReports = pressedKey.Key == ConsoleKey.Y;
#endregion Device reports
#region Statistics
DicConsole.WriteLine();
DicConsole.WriteLine("DiscImageChef can store some usage statistics. These statistics are limited to the number of times a\n" +
"command is executed, a filesystem, partition, or device is used, the operating system version, and other.\n" +
DicConsole.WriteLine("DiscImageChef can store some usage statistics. These statistics are limited to the number of times a\n" +
"command is executed, a filesystem, partition, or device is used, the operating system version, and other.\n" +
"In no case, any information besides pure statistical usage numbers is stored, and they're just joint to the\n" +
"pool with no way of using them to identify you.");
pressedKey = new ConsoleKeyInfo();
while(pressedKey.Key != ConsoleKey.Y && pressedKey.Key != ConsoleKey.N)
{

View File

@@ -94,7 +94,7 @@ namespace DiscImageChef.Commands
try
{
StreamReader sr = new StreamReader(options.CicmXml);
sidecar = (CICMMetadataType)xs.Deserialize(sr);
sidecar = (CICMMetadataType)xs.Deserialize(sr);
sr.Close();
}
catch
@@ -114,7 +114,7 @@ namespace DiscImageChef.Commands
try
{
StreamReader sr = new StreamReader(options.ResumeFile);
resume = (Resume)xs.Deserialize(sr);
resume = (Resume)xs.Deserialize(sr);
sr.Close();
}
catch
@@ -271,7 +271,7 @@ namespace DiscImageChef.Commands
DriveManufacturer = options.DriveManufacturer ?? inputFormat.Info.DriveManufacturer,
DriveModel = options.DriveModel ?? inputFormat.Info.DriveModel,
DriveSerialNumber = options.DriveSerialNumber ?? inputFormat.Info.DriveSerialNumber,
LastMediaSequence =
LastMediaSequence =
options.LastMediaSequence != 0 ? options.LastMediaSequence : inputFormat.Info.LastMediaSequence,
MediaBarcode = options.MediaBarcode ?? inputFormat.Info.MediaBarcode,
MediaManufacturer = options.MediaManufacturer ?? inputFormat.Info.MediaManufacturer,
@@ -296,7 +296,7 @@ namespace DiscImageChef.Commands
List<Track> tracks;
try { tracks = inputFormat.Tracks; }
try { tracks = inputFormat.Tracks; }
catch(Exception) { tracks = null; }
CICMMetadataType cicmMetadata = inputFormat.CicmMetadata;
@@ -312,9 +312,8 @@ namespace DiscImageChef.Commands
foreach(MediaTagType mediaTag in inputFormat.Info.ReadableMediaTags)
{
if(options.Force && !outputFormat.SupportedMediaTags.Contains(mediaTag))
continue;
if(options.Force && !outputFormat.SupportedMediaTags.Contains(mediaTag)) continue;
DicConsole.WriteLine("Converting media tag {0}", mediaTag);
byte[] tag = inputFormat.ReadDiskTag(mediaTag);
if(outputFormat.WriteMediaTag(tag, mediaTag)) continue;
@@ -416,8 +415,7 @@ namespace DiscImageChef.Commands
continue;
}
if(options.Force && !outputFormat.SupportedSectorTags.Contains(tag))
continue;
if(options.Force && !outputFormat.SupportedSectorTags.Contains(tag)) continue;
doneSectors = 0;
while(doneSectors < inputFormat.Info.Sectors)
@@ -468,7 +466,7 @@ namespace DiscImageChef.Commands
{
foreach(Track track in tracks)
{
doneSectors = 0;
doneSectors = 0;
ulong trackSectors = track.TrackEndSector - track.TrackStartSector + 1;
while(doneSectors < trackSectors)
@@ -482,8 +480,8 @@ namespace DiscImageChef.Commands
(uint)(trackSectors - doneSectors);
DicConsole.Write("\rConverting sectors {0} to {1} in track {3} ({2:P2} done)",
doneSectors + track.TrackStartSector,
doneSectors + sectorsToDo + track.TrackStartSector,
doneSectors + track.TrackStartSector,
doneSectors + sectorsToDo + track.TrackStartSector,
(doneSectors + track.TrackStartSector) / (double)inputFormat.Info.Sectors,
track.TrackSequence);
@@ -496,8 +494,7 @@ namespace DiscImageChef.Commands
}
else
{
sector = inputFormat.ReadSectorsLong(doneSectors + track.TrackStartSector,
sectorsToDo);
sector = inputFormat.ReadSectorsLong(doneSectors + track.TrackStartSector, sectorsToDo);
result = outputFormat.WriteSectorsLong(sector, doneSectors + track.TrackStartSector,
sectorsToDo);
}
@@ -510,8 +507,7 @@ namespace DiscImageChef.Commands
}
else
{
sector = inputFormat.ReadSectors(doneSectors + track.TrackStartSector,
sectorsToDo);
sector = inputFormat.ReadSectors(doneSectors + track.TrackStartSector, sectorsToDo);
result = outputFormat.WriteSectors(sector, doneSectors + track.TrackStartSector,
sectorsToDo);
}
@@ -553,13 +549,12 @@ namespace DiscImageChef.Commands
// This tags are inline in long sector
continue;
}
if(options.Force && !outputFormat.SupportedSectorTags.Contains(tag))
continue;
if(options.Force && !outputFormat.SupportedSectorTags.Contains(tag)) continue;
foreach(Track track in tracks)
{
doneSectors = 0;
doneSectors = 0;
ulong trackSectors = track.TrackEndSector - track.TrackStartSector + 1;
byte[] sector;
bool result;
@@ -595,8 +590,8 @@ namespace DiscImageChef.Commands
(uint)(trackSectors - doneSectors);
DicConsole.Write("\rConverting tag {4} for sectors {0} to {1} in track {3} ({2:P2} done)",
doneSectors + track.TrackStartSector,
doneSectors + sectorsToDo + track.TrackStartSector,
doneSectors + track.TrackStartSector,
doneSectors + sectorsToDo + track.TrackStartSector,
(doneSectors + track.TrackStartSector) / (double)inputFormat.Info.Sectors,
track.TrackSequence, tag);
@@ -650,8 +645,7 @@ namespace DiscImageChef.Commands
if(resume != null || dumpHardware != null)
{
if(resume != null) ret = outputFormat.SetDumpHardware(resume.Tries);
else if(dumpHardware != null)
ret = outputFormat.SetDumpHardware(dumpHardware);
else if(dumpHardware != null) ret = outputFormat.SetDumpHardware(dumpHardware);
if(ret) DicConsole.WriteLine("Written dump hardware list to output image.");
}
@@ -659,8 +653,7 @@ namespace DiscImageChef.Commands
if(sidecar != null || cicmMetadata != null)
{
if(sidecar != null) ret = outputFormat.SetCicmMetadata(sidecar);
else if(cicmMetadata != null)
ret = outputFormat.SetCicmMetadata(cicmMetadata);
else if(cicmMetadata != null) ret = outputFormat.SetCicmMetadata(cicmMetadata);
if(ret) DicConsole.WriteLine("Written CICM XML metadata to output image.");
}

View File

@@ -152,9 +152,9 @@ namespace DiscImageChef.Commands
return;
}
string[] contents = Directory.GetFiles(options.InputFile, "*", SearchOption.TopDirectoryOnly);
List<string> files = contents.Where(file => new FileInfo(file).Length % options.BlockSize == 0)
.ToList();
string[] contents = Directory.GetFiles(options.InputFile, "*", SearchOption.TopDirectoryOnly);
List<string> files = contents.Where(file => new FileInfo(file).Length % options.BlockSize == 0)
.ToList();
files.Sort(StringComparer.CurrentCultureIgnoreCase);
@@ -174,8 +174,7 @@ namespace DiscImageChef.Commands
Core.Statistics.AddCommand("create-sidecar");
}
else
DicConsole.ErrorWriteLine("The specified input file cannot be found.");
else DicConsole.ErrorWriteLine("The specified input file cannot be found.");
}
}
}

View File

@@ -45,16 +45,16 @@ namespace DiscImageChef.Commands
{
internal static void DoDecode(DecodeOptions options)
{
DicConsole.DebugWriteLine("Decode command", "--debug={0}", options.Debug);
DicConsole.DebugWriteLine("Decode command", "--verbose={0}", options.Verbose);
DicConsole.DebugWriteLine("Decode command", "--input={0}", options.InputFile);
DicConsole.DebugWriteLine("Decode command", "--start={0}", options.StartSector);
DicConsole.DebugWriteLine("Decode command", "--length={0}", options.Length);
DicConsole.DebugWriteLine("Decode command", "--disk-tags={0}", options.DiskTags);
DicConsole.DebugWriteLine("Decode command", "--debug={0}", options.Debug);
DicConsole.DebugWriteLine("Decode command", "--verbose={0}", options.Verbose);
DicConsole.DebugWriteLine("Decode command", "--input={0}", options.InputFile);
DicConsole.DebugWriteLine("Decode command", "--start={0}", options.StartSector);
DicConsole.DebugWriteLine("Decode command", "--length={0}", options.Length);
DicConsole.DebugWriteLine("Decode command", "--disk-tags={0}", options.DiskTags);
DicConsole.DebugWriteLine("Decode command", "--sector-tags={0}", options.SectorTags);
FiltersList filtersList = new FiltersList();
IFilter inputFilter = filtersList.GetFilter(options.InputFile);
IFilter inputFilter = filtersList.GetFilter(options.InputFile);
if(inputFilter == null)
{
@@ -91,11 +91,12 @@ namespace DiscImageChef.Commands
{
DicConsole.WriteLine("SCSI INQUIRY command response:");
DicConsole
.WriteLine("================================================================================");
.WriteLine("================================================================================");
DicConsole.WriteLine(Inquiry.Prettify(inquiry));
DicConsole
.WriteLine("================================================================================");
.WriteLine("================================================================================");
}
break;
}
case MediaTagType.ATA_IDENTIFY:
@@ -107,11 +108,12 @@ namespace DiscImageChef.Commands
{
DicConsole.WriteLine("ATA IDENTIFY DEVICE command response:");
DicConsole
.WriteLine("================================================================================");
.WriteLine("================================================================================");
DicConsole.WriteLine(Identify.Prettify(identify));
DicConsole
.WriteLine("================================================================================");
.WriteLine("================================================================================");
}
break;
}
case MediaTagType.ATAPI_IDENTIFY:
@@ -119,16 +121,17 @@ namespace DiscImageChef.Commands
byte[] identify = inputFormat.ReadDiskTag(MediaTagType.ATAPI_IDENTIFY);
if(identify == null)
DicConsole
.WriteLine("Error reading ATA IDENTIFY PACKET DEVICE response from disc image");
.WriteLine("Error reading ATA IDENTIFY PACKET DEVICE response from disc image");
else
{
DicConsole.WriteLine("ATA IDENTIFY PACKET DEVICE command response:");
DicConsole
.WriteLine("================================================================================");
.WriteLine("================================================================================");
DicConsole.WriteLine(Identify.Prettify(identify));
DicConsole
.WriteLine("================================================================================");
.WriteLine("================================================================================");
}
break;
}
case MediaTagType.CD_ATIP:
@@ -139,11 +142,12 @@ namespace DiscImageChef.Commands
{
DicConsole.WriteLine("CD ATIP:");
DicConsole
.WriteLine("================================================================================");
.WriteLine("================================================================================");
DicConsole.WriteLine(ATIP.Prettify(atip));
DicConsole
.WriteLine("================================================================================");
.WriteLine("================================================================================");
}
break;
}
case MediaTagType.CD_FullTOC:
@@ -154,11 +158,12 @@ namespace DiscImageChef.Commands
{
DicConsole.WriteLine("CD full TOC:");
DicConsole
.WriteLine("================================================================================");
.WriteLine("================================================================================");
DicConsole.WriteLine(FullTOC.Prettify(fulltoc));
DicConsole
.WriteLine("================================================================================");
.WriteLine("================================================================================");
}
break;
}
case MediaTagType.CD_PMA:
@@ -169,11 +174,12 @@ namespace DiscImageChef.Commands
{
DicConsole.WriteLine("CD PMA:");
DicConsole
.WriteLine("================================================================================");
.WriteLine("================================================================================");
DicConsole.WriteLine(PMA.Prettify(pma));
DicConsole
.WriteLine("================================================================================");
.WriteLine("================================================================================");
}
break;
}
case MediaTagType.CD_SessionInfo:
@@ -185,11 +191,12 @@ namespace DiscImageChef.Commands
{
DicConsole.WriteLine("CD session information:");
DicConsole
.WriteLine("================================================================================");
.WriteLine("================================================================================");
DicConsole.WriteLine(Session.Prettify(sessioninfo));
DicConsole
.WriteLine("================================================================================");
.WriteLine("================================================================================");
}
break;
}
case MediaTagType.CD_TEXT:
@@ -200,11 +207,12 @@ namespace DiscImageChef.Commands
{
DicConsole.WriteLine("CD-TEXT:");
DicConsole
.WriteLine("================================================================================");
.WriteLine("================================================================================");
DicConsole.WriteLine(CDTextOnLeadIn.Prettify(cdtext));
DicConsole
.WriteLine("================================================================================");
.WriteLine("================================================================================");
}
break;
}
case MediaTagType.CD_TOC:
@@ -215,11 +223,12 @@ namespace DiscImageChef.Commands
{
DicConsole.WriteLine("CD TOC:");
DicConsole
.WriteLine("================================================================================");
.WriteLine("================================================================================");
DicConsole.WriteLine(TOC.Prettify(toc));
DicConsole
.WriteLine("================================================================================");
.WriteLine("================================================================================");
}
break;
}
default:

View File

@@ -71,11 +71,11 @@ namespace DiscImageChef.Commands
DicConsole.WriteLine("USB device");
if(dev.UsbDescriptors != null)
DicConsole.WriteLine("USB descriptor is {0} bytes", dev.UsbDescriptors.Length);
DicConsole.WriteLine("USB Vendor ID: {0:X4}", dev.UsbVendorId);
DicConsole.WriteLine("USB Product ID: {0:X4}", dev.UsbProductId);
DicConsole.WriteLine("USB Manufacturer: {0}", dev.UsbManufacturerString);
DicConsole.WriteLine("USB Product: {0}", dev.UsbProductString);
DicConsole.WriteLine("USB Serial number: {0}", dev.UsbSerialString);
DicConsole.WriteLine("USB Vendor ID: {0:X4}", dev.UsbVendorId);
DicConsole.WriteLine("USB Product ID: {0:X4}", dev.UsbProductId);
DicConsole.WriteLine("USB Manufacturer: {0}", dev.UsbManufacturerString);
DicConsole.WriteLine("USB Product: {0}", dev.UsbProductString);
DicConsole.WriteLine("USB Serial number: {0}", dev.UsbSerialString);
DicConsole.WriteLine();
}
@@ -842,7 +842,7 @@ namespace DiscImageChef.Commands
case "DVDR PX-708A":
case "DVDR PX-708A2":
case "DVDR PX-712A":
plxtDvd = true;
plxtDvd = true;
plxtSense = dev.PlextorReadEeprom(out plxtBuf, out senseBuf, dev.Timeout,
out _);
break;

View File

@@ -45,9 +45,9 @@ namespace DiscImageChef.Commands
{
internal static void DoDeviceReport(DeviceReportOptions options)
{
DicConsole.DebugWriteLine("Device-Report command", "--debug={0}", options.Debug);
DicConsole.DebugWriteLine("Device-Report command", "--debug={0}", options.Debug);
DicConsole.DebugWriteLine("Device-Report command", "--verbose={0}", options.Verbose);
DicConsole.DebugWriteLine("Device-Report command", "--device={0}", options.DevicePath);
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]))
@@ -63,14 +63,19 @@ namespace DiscImageChef.Commands
Core.Statistics.AddDevice(dev);
Metadata.DeviceReport report = new Metadata.DeviceReport();
bool removable = false;
string xmlFile;
Metadata.DeviceReport report = new Metadata.DeviceReport();
bool removable = false;
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";
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";
xmlFile = xmlFile.Replace('\\', '_').Replace('/', '_').Replace('?', '_');

View File

@@ -60,9 +60,9 @@ namespace DiscImageChef.Commands
Sidecar.EndProgressEvent2 += Progress.EndProgress2;
Sidecar.UpdateStatusEvent += Progress.UpdateStatus;
DicConsole.DebugWriteLine("Dump-Media command", "--debug={0}", options.Debug);
DicConsole.DebugWriteLine("Dump-Media command", "--verbose={0}", options.Verbose);
DicConsole.DebugWriteLine("Dump-Media command", "--device={0}", options.DevicePath);
DicConsole.DebugWriteLine("Dump-Media command", "--debug={0}", options.Debug);
DicConsole.DebugWriteLine("Dump-Media command", "--verbose={0}", options.Verbose);
DicConsole.DebugWriteLine("Dump-Media command", "--device={0}", options.DevicePath);
// TODO: Disabled temporarily
//DicConsole.DebugWriteLine("Dump-Media command", "--raw={0}", options.Raw);
DicConsole.DebugWriteLine("Dump-Media command", "--stop-on-error={0}", options.StopOnError);
@@ -206,7 +206,8 @@ namespace DiscImageChef.Commands
switch(dev.Type)
{
case DeviceType.ATA:
Ata.Dump(dev, options.DevicePath, outputFormat, options.RetryPasses, options.Force, false, /*options.Raw,*/
Ata.Dump(dev, options.DevicePath, outputFormat, options.RetryPasses, options.Force,
false, /*options.Raw,*/
options.Persistent, options.StopOnError, ref resume, ref dumpLog, encoding, outputPrefix,
options.OutputFile, parsedOptions, sidecar, (uint)options.Skip, options.NoMetadata,
options.NoTrim);
@@ -214,19 +215,21 @@ namespace DiscImageChef.Commands
case DeviceType.MMC:
case DeviceType.SecureDigital:
SecureDigital.Dump(dev, options.DevicePath, outputFormat, options.RetryPasses, options.Force,
false, /*options.Raw,*/ options.Persistent, options.StopOnError, ref resume, ref dumpLog,
encoding, outputPrefix, options.OutputFile, parsedOptions, sidecar,
false, /*options.Raw,*/ options.Persistent, options.StopOnError, ref resume,
ref dumpLog, encoding, outputPrefix, options.OutputFile, parsedOptions, sidecar,
(uint)options.Skip, options.NoMetadata, options.NoTrim);
break;
case DeviceType.NVMe:
NvMe.Dump(dev, options.DevicePath, outputFormat, options.RetryPasses, options.Force, false, /*options.Raw,*/
NvMe.Dump(dev, options.DevicePath, outputFormat, options.RetryPasses, options.Force,
false, /*options.Raw,*/
options.Persistent, options.StopOnError, ref resume, ref dumpLog, encoding, outputPrefix,
options.OutputFile, parsedOptions, sidecar, (uint)options.Skip, options.NoMetadata,
options.NoTrim);
break;
case DeviceType.ATAPI:
case DeviceType.SCSI:
Scsi.Dump(dev, options.DevicePath, outputFormat, options.RetryPasses, options.Force, false, /*options.Raw,*/
Scsi.Dump(dev, options.DevicePath, outputFormat, options.RetryPasses, options.Force,
false, /*options.Raw,*/
options.Persistent, options.StopOnError, ref resume, ref dumpLog, options.LeadIn,
encoding, outputPrefix, options.OutputFile, parsedOptions, sidecar, (uint)options.Skip,
options.NoMetadata, options.NoTrim);

View File

@@ -84,7 +84,7 @@ namespace DiscImageChef.Commands
foreach(Track currentTrack in inputTracks)
{
entTable = new ulong[256];
entTable = new ulong[256];
ulong trackSize = 0;
List<string> uniqueSectorsPerTrack = new List<string>();
@@ -107,7 +107,7 @@ namespace DiscImageChef.Commands
trackSize += (ulong)sector.LongLength;
}
entropy += entTable.Select(l => (double)l / (double)trackSize)
entropy += entTable.Select(l => (double)l / (double)trackSize)
.Select(frequency => -(frequency * Math.Log(frequency, 2))).Sum();
DicConsole.WriteLine("Entropy for track {0} is {1:F4}.", currentTrack.TrackSequence, entropy);
@@ -128,7 +128,7 @@ namespace DiscImageChef.Commands
if(!options.WholeDisc) return;
entTable = new ulong[256];
entTable = new ulong[256];
ulong diskSize = 0;
List<string> uniqueSectors = new List<string>();
@@ -151,7 +151,7 @@ namespace DiscImageChef.Commands
diskSize += (ulong)sector.LongLength;
}
entropy += entTable.Select(l => (double)l / (double)diskSize)
entropy += entTable.Select(l => (double)l / (double)diskSize)
.Select(frequency => -(frequency * Math.Log(frequency, 2))).Sum();
DicConsole.WriteLine();

View File

@@ -54,15 +54,15 @@ namespace DiscImageChef.Commands
DicConsole.DebugWriteLine("Extract-Files command", "--xattrs={0}", options.Xattrs);
DicConsole.DebugWriteLine("Extract-Files command", "--output={0}", options.OutputDir);
FiltersList filtersList = new FiltersList();
IFilter inputFilter = filtersList.GetFilter(options.InputFile);
FiltersList filtersList = new FiltersList();
IFilter inputFilter = filtersList.GetFilter(options.InputFile);
Dictionary<string, string> parsedOptions = Options.Parse(options.Options);
DicConsole.DebugWriteLine("Extract-Files command", "Parsed options:");
foreach(KeyValuePair<string,string> parsedOption in parsedOptions)
foreach(KeyValuePair<string, string> parsedOption in parsedOptions)
DicConsole.DebugWriteLine("Extract-Files command", "{0} = {1}", parsedOption.Key, parsedOption.Value);
parsedOptions.Add("debug", options.Debug.ToString());
if(inputFilter == null)
{
DicConsole.ErrorWriteLine("Cannot open specified file.");
@@ -172,7 +172,7 @@ namespace DiscImageChef.Commands
error = fs.Mount(imageFormat, partitions[i], encoding, parsedOptions);
if(error == Errno.NoError)
{
error = fs.ReadDir("/", out List<string> rootDir);
error = fs.ReadDir("/", out List<string> rootDir);
if(error == Errno.NoError)
foreach(string entry in rootDir)
{
@@ -193,8 +193,7 @@ namespace DiscImageChef.Commands
foreach(string xattr in xattrs)
{
byte[] xattrBuf = new byte[0];
error =
fs.GetXattr(entry, xattr, ref xattrBuf);
error = fs.GetXattr(entry, xattr, ref xattrBuf);
if(error != Errno.NoError) continue;
Directory
@@ -323,7 +322,7 @@ namespace DiscImageChef.Commands
error = fs.Mount(imageFormat, partitions[i], encoding, parsedOptions);
if(error == Errno.NoError)
{
error = fs.ReadDir("/", out List<string> rootDir);
error = fs.ReadDir("/", out List<string> rootDir);
if(error == Errno.NoError)
foreach(string entry in rootDir)
{
@@ -344,7 +343,7 @@ namespace DiscImageChef.Commands
foreach(string xattr in xattrs)
{
byte[] xattrBuf = new byte[0];
error = fs.GetXattr(entry, xattr, ref xattrBuf);
error = fs.GetXattr(entry, xattr, ref xattrBuf);
if(error != Errno.NoError) continue;
Directory.CreateDirectory(Path.Combine(options.OutputDir,
@@ -479,7 +478,7 @@ namespace DiscImageChef.Commands
error = fs.Mount(imageFormat, wholePart, encoding, parsedOptions);
if(error == Errno.NoError)
{
error = fs.ReadDir("/", out List<string> rootDir);
error = fs.ReadDir("/", out List<string> rootDir);
if(error == Errno.NoError)
foreach(string entry in rootDir)
{
@@ -500,7 +499,7 @@ namespace DiscImageChef.Commands
foreach(string xattr in xattrs)
{
byte[] xattrBuf = new byte[0];
error = fs.GetXattr(entry, xattr, ref xattrBuf);
error = fs.GetXattr(entry, xattr, ref xattrBuf);
if(error != Errno.NoError) continue;
Directory.CreateDirectory(Path.Combine(options.OutputDir,
@@ -619,7 +618,7 @@ namespace DiscImageChef.Commands
error = fs.Mount(imageFormat, wholePart, encoding, parsedOptions);
if(error == Errno.NoError)
{
error = fs.ReadDir("/", out List<string> rootDir);
error = fs.ReadDir("/", out List<string> rootDir);
if(error == Errno.NoError)
foreach(string entry in rootDir)
{
@@ -639,7 +638,7 @@ namespace DiscImageChef.Commands
foreach(string xattr in xattrs)
{
byte[] xattrBuf = new byte[0];
error = fs.GetXattr(entry, xattr, ref xattrBuf);
error = fs.GetXattr(entry, xattr, ref xattrBuf);
if(error != Errno.NoError) continue;
Directory.CreateDirectory(Path.Combine(options.OutputDir,

View File

@@ -40,7 +40,7 @@ namespace DiscImageChef.Commands
{
internal static void DoListDevices(ListDevicesOptions options)
{
DicConsole.DebugWriteLine("Media-Info command", "--debug={0}", options.Debug);
DicConsole.DebugWriteLine("Media-Info command", "--debug={0}", options.Debug);
DicConsole.DebugWriteLine("Media-Info command", "--verbose={0}", options.Verbose);
Devices.DeviceInfo[] devices = Device.ListDevices();

View File

@@ -42,18 +42,17 @@ namespace DiscImageChef.Commands
internal static void DoList()
{
List<CommonEncodingInfo> encodings = Encoding
.GetEncodings()
.Select(info => new CommonEncodingInfo
{
Name = info.Name,
DisplayName = info.GetEncoding().EncodingName
}).ToList();
.GetEncodings().Select(info => new CommonEncodingInfo
{
Name = info.Name,
DisplayName = info.GetEncoding().EncodingName
}).ToList();
encodings.AddRange(Claunia.Encoding.Encoding.GetEncodings()
.Select(info => new CommonEncodingInfo
{
Name = info.Name,
DisplayName = info.DisplayName
}));
{
Name = info.Name,
DisplayName = info.DisplayName
}));
DicConsole.WriteLine("{0,-16} {1,-8}", "Name", "Description");

View File

@@ -59,9 +59,9 @@ namespace DiscImageChef.Commands
option.description);
DicConsole.WriteLine();
}
DicConsole.WriteLine();
DicConsole.WriteLine("Read/Write media images options:");
foreach(KeyValuePair<string, IWritableImage> kvp in plugins.WritableImages)
{

View File

@@ -50,12 +50,12 @@ namespace DiscImageChef.Commands
DicConsole.DebugWriteLine("Ls command", "--verbose={0}", options.Verbose);
DicConsole.DebugWriteLine("Ls command", "--input={0}", options.InputFile);
FiltersList filtersList = new FiltersList();
IFilter inputFilter = filtersList.GetFilter(options.InputFile);
FiltersList filtersList = new FiltersList();
IFilter inputFilter = filtersList.GetFilter(options.InputFile);
Dictionary<string, string> parsedOptions = Options.Parse(options.Options);
DicConsole.DebugWriteLine("Ls command", "Parsed options:");
foreach(KeyValuePair<string,string> parsedOption in parsedOptions)
foreach(KeyValuePair<string, string> parsedOption in parsedOptions)
DicConsole.DebugWriteLine("Ls command", "{0} = {1}", parsedOption.Key, parsedOption.Value);
parsedOptions.Add("debug", options.Debug.ToString());
@@ -161,7 +161,7 @@ namespace DiscImageChef.Commands
error = fs.Mount(imageFormat, partitions[i], encoding, parsedOptions);
if(error == Errno.NoError)
{
error = fs.ReadDir("/", out List<string> rootDir);
error = fs.ReadDir("/", out List<string> rootDir);
if(error == Errno.NoError)
foreach(string entry in rootDir)
DicConsole.WriteLine("{0}", entry);
@@ -190,7 +190,7 @@ namespace DiscImageChef.Commands
error = fs.Mount(imageFormat, partitions[i], encoding, parsedOptions);
if(error == Errno.NoError)
{
error = fs.ReadDir("/", out List<string> rootDir);
error = fs.ReadDir("/", out List<string> rootDir);
if(error == Errno.NoError)
foreach(string entry in rootDir)
DicConsole.WriteLine("{0}", entry);
@@ -229,7 +229,7 @@ namespace DiscImageChef.Commands
error = fs.Mount(imageFormat, wholePart, encoding, parsedOptions);
if(error == Errno.NoError)
{
error = fs.ReadDir("/", out List<string> rootDir);
error = fs.ReadDir("/", out List<string> rootDir);
if(error == Errno.NoError)
foreach(string entry in rootDir)
DicConsole.WriteLine("{0}", entry);
@@ -255,7 +255,7 @@ namespace DiscImageChef.Commands
error = fs.Mount(imageFormat, wholePart, encoding, parsedOptions);
if(error == Errno.NoError)
{
error = fs.ReadDir("/", out List<string> rootDir);
error = fs.ReadDir("/", out List<string> rootDir);
if(error == Errno.NoError)
foreach(string entry in rootDir)
if(options.Long)
@@ -272,7 +272,7 @@ namespace DiscImageChef.Commands
foreach(string xattr in xattrs)
{
byte[] xattrBuf = new byte[0];
error = fs.GetXattr(entry, xattr, ref xattrBuf);
error = fs.GetXattr(entry, xattr, ref xattrBuf);
if(error == Errno.NoError)
DicConsole.WriteLine("\t\t{0}\t{1} bytes", xattr,
xattrBuf.Length);

View File

@@ -229,11 +229,9 @@ namespace DiscImageChef.Commands
scsiDensityCode = (byte)decMode.Value.Header.BlockDescriptors[0].Density;
if(decMode.Value.Pages != null)
{
containsFloppyPage =
decMode.Value.Pages.Aggregate(containsFloppyPage,
(current, modePage) => current | (modePage.Page == 0x05));
}
}
switch(dev.ScsiType)
@@ -1316,7 +1314,8 @@ namespace DiscImageChef.Commands
return;
}
ulong totalSize = (ulong)((cmdBuf[0] << 24) + (cmdBuf[1] << 16) + (cmdBuf[2] << 8) + cmdBuf[3]);
ulong totalSize =
(ulong)((cmdBuf[0] << 24) + (cmdBuf[1] << 16) + (cmdBuf[2] << 8) + cmdBuf[3]);
sense = dev.ReadDiscStructure(out cmdBuf, out senseBuf, MmcDiscStructureMediaType.Dvd, 0, 0,
MmcDiscStructureFormat.PhysicalInformation, 0, 0, out _);
if(sense)
@@ -1347,8 +1346,8 @@ namespace DiscImageChef.Commands
return;
}
ulong gameSize = (ulong)((cmdBuf[0] << 24) + (cmdBuf[1] << 16) + (cmdBuf[2] << 8) + cmdBuf[3]) +
1;
ulong gameSize =
(ulong)((cmdBuf[0] << 24) + (cmdBuf[1] << 16) + (cmdBuf[2] << 8) + cmdBuf[3]) + 1;
DicConsole.DebugWriteLine("Dump-media command", "Game partition total size: {0} sectors",
gameSize);
@@ -1379,11 +1378,12 @@ namespace DiscImageChef.Commands
DicConsole.DebugWriteLine("Dump-media command", "Unlocked total size: {0} sectors",
totalSize);
ulong middleZone = totalSize -
(PFI.Decode(cmdBuf).Value.Layer0EndPSN -
PFI.Decode(cmdBuf).Value.DataAreaStartPSN + 1) - gameSize + 1;
ulong middleZone =
totalSize -
(PFI.Decode(cmdBuf).Value.Layer0EndPSN -
PFI.Decode(cmdBuf).Value.DataAreaStartPSN + 1) - gameSize + 1;
totalSize = l0Video + l1Video + middleZone * 2 + gameSize;
totalSize = l0Video + l1Video + middleZone * 2 + gameSize;
ulong layerBreak = l0Video + middleZone + gameSize / 2;
DicConsole.WriteLine("Video layer 0 size: {0} sectors", l0Video);

View File

@@ -41,11 +41,11 @@ namespace DiscImageChef.Commands
{
internal static void DoMediaScan(MediaScanOptions options)
{
DicConsole.DebugWriteLine("Media-Scan command", "--debug={0}", options.Debug);
DicConsole.DebugWriteLine("Media-Scan command", "--verbose={0}", options.Verbose);
DicConsole.DebugWriteLine("Media-Scan command", "--device={0}", options.DevicePath);
DicConsole.DebugWriteLine("Media-Scan command", "--debug={0}", options.Debug);
DicConsole.DebugWriteLine("Media-Scan command", "--verbose={0}", options.Verbose);
DicConsole.DebugWriteLine("Media-Scan command", "--device={0}", options.DevicePath);
DicConsole.DebugWriteLine("Media-Scan command", "--mhdd-log={0}", options.MhddLogPath);
DicConsole.DebugWriteLine("Media-Scan command", "--ibg-log={0}", options.IbgLogPath);
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]))
@@ -84,26 +84,27 @@ namespace DiscImageChef.Commands
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("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);
DicConsole.WriteLine("Summary:");
DicConsole.WriteLine("{0} sectors took less than 3 ms.", results.A);
DicConsole.WriteLine("{0} sectors took less than 10 ms but more than 3 ms.", results.B);
DicConsole.WriteLine("{0} sectors took less than 50 ms but more than 10 ms.", results.C);
DicConsole.WriteLine("{0} sectors took less than 150 ms but more than 50 ms.", results.D);
DicConsole.WriteLine("{0} sectors took less than 3 ms.", results.A);
DicConsole.WriteLine("{0} sectors took less than 10 ms but more than 3 ms.", results.B);
DicConsole.WriteLine("{0} sectors took less than 50 ms but more than 10 ms.", results.C);
DicConsole.WriteLine("{0} sectors took less than 150 ms but more than 50 ms.", results.D);
DicConsole.WriteLine("{0} sectors took less than 500 ms but more than 150 ms.", results.E);
DicConsole.WriteLine("{0} sectors took more than 500 ms.", results.F);
DicConsole.WriteLine("{0} sectors could not be read.", results.UnreadableSectors.Count);
DicConsole.WriteLine("{0} sectors took more than 500 ms.", results.F);
DicConsole.WriteLine("{0} sectors could not be read.",
results.UnreadableSectors.Count);
if(results.UnreadableSectors.Count > 0)
foreach(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
#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
#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);

View File

@@ -41,16 +41,16 @@ namespace DiscImageChef.Commands
{
internal static void DoPrintHex(PrintHexOptions options)
{
DicConsole.DebugWriteLine("PrintHex command", "--debug={0}", options.Debug);
DicConsole.DebugWriteLine("PrintHex command", "--verbose={0}", options.Verbose);
DicConsole.DebugWriteLine("PrintHex command", "--input={0}", options.InputFile);
DicConsole.DebugWriteLine("PrintHex command", "--start={0}", options.StartSector);
DicConsole.DebugWriteLine("PrintHex command", "--length={0}", options.Length);
DicConsole.DebugWriteLine("PrintHex command", "--debug={0}", options.Debug);
DicConsole.DebugWriteLine("PrintHex command", "--verbose={0}", options.Verbose);
DicConsole.DebugWriteLine("PrintHex command", "--input={0}", options.InputFile);
DicConsole.DebugWriteLine("PrintHex command", "--start={0}", options.StartSector);
DicConsole.DebugWriteLine("PrintHex command", "--length={0}", options.Length);
DicConsole.DebugWriteLine("PrintHex command", "--long-sectors={0}", options.LongSectors);
DicConsole.DebugWriteLine("PrintHex command", "--WidthBytes={0}", options.WidthBytes);
DicConsole.DebugWriteLine("PrintHex command", "--WidthBytes={0}", options.WidthBytes);
FiltersList filtersList = new FiltersList();
IFilter inputFilter = filtersList.GetFilter(options.InputFile);
IFilter inputFilter = filtersList.GetFilter(options.InputFile);
if(inputFilter == null)
{
@@ -75,7 +75,7 @@ namespace DiscImageChef.Commands
if(inputFormat.Info.ReadableSectorTags == null)
{
DicConsole
.WriteLine("Requested sectors with tags, unsupported by underlying image format, printing only user data.");
.WriteLine("Requested sectors with tags, unsupported by underlying image format, printing only user data.");
options.LongSectors = false;
}
else
@@ -83,14 +83,14 @@ namespace DiscImageChef.Commands
if(inputFormat.Info.ReadableSectorTags.Count == 0)
{
DicConsole
.WriteLine("Requested sectors with tags, unsupported by underlying image format, printing only user data.");
.WriteLine("Requested sectors with tags, unsupported by underlying image format, printing only user data.");
options.LongSectors = false;
}
}
byte[] sector = options.LongSectors
? inputFormat.ReadSectorLong(options.StartSector + i)
: inputFormat.ReadSector(options.StartSector + i);
: inputFormat.ReadSector(options.StartSector + i);
DiscImageChef.PrintHex.PrintHexArray(sector, options.WidthBytes);
}

View File

@@ -43,14 +43,14 @@ namespace DiscImageChef.Commands
{
internal static void DoVerify(VerifyOptions options)
{
DicConsole.DebugWriteLine("Verify command", "--debug={0}", options.Debug);
DicConsole.DebugWriteLine("Verify command", "--verbose={0}", options.Verbose);
DicConsole.DebugWriteLine("Verify command", "--input={0}", options.InputFile);
DicConsole.DebugWriteLine("Verify command", "--verify-disc={0}", options.VerifyDisc);
DicConsole.DebugWriteLine("Verify command", "--debug={0}", options.Debug);
DicConsole.DebugWriteLine("Verify command", "--verbose={0}", options.Verbose);
DicConsole.DebugWriteLine("Verify command", "--input={0}", options.InputFile);
DicConsole.DebugWriteLine("Verify command", "--verify-disc={0}", options.VerifyDisc);
DicConsole.DebugWriteLine("Verify command", "--verify-sectors={0}", options.VerifySectors);
FiltersList filtersList = new FiltersList();
IFilter inputFilter = filtersList.GetFilter(options.InputFile);
IFilter inputFilter = filtersList.GetFilter(options.InputFile);
if(inputFilter == null)
{
@@ -71,17 +71,17 @@ namespace DiscImageChef.Commands
Core.Statistics.AddMedia(inputFormat.Info.MediaType, false);
Core.Statistics.AddFilter(inputFilter.Name);
bool? correctDisc = null;
long totalSectors = 0;
long errorSectors = 0;
long correctSectors = 0;
long unknownSectors = 0;
bool? correctDisc = null;
long totalSectors = 0;
long errorSectors = 0;
long correctSectors = 0;
long unknownSectors = 0;
if(options.VerifyDisc)
{
DateTime startCheck = DateTime.UtcNow;
bool? discCheckStatus = inputFormat.VerifyMediaImage();
DateTime endCheck = DateTime.UtcNow;
DateTime startCheck = DateTime.UtcNow;
bool? discCheckStatus = inputFormat.VerifyMediaImage();
DateTime endCheck = DateTime.UtcNow;
TimeSpan checkTime = endCheck - startCheck;
@@ -112,21 +112,21 @@ namespace DiscImageChef.Commands
}
catch { formatHasTracks = false; }
DateTime startCheck;
DateTime endCheck;
DateTime startCheck;
DateTime endCheck;
List<ulong> failingLbas = new List<ulong>();
List<ulong> unknownLbas = new List<ulong>();
if(formatHasTracks)
{
List<Track> inputTracks = inputFormat.Tracks;
ulong currentSectorAll = 0;
List<Track> inputTracks = inputFormat.Tracks;
ulong currentSectorAll = 0;
startCheck = DateTime.UtcNow;
foreach(Track currentTrack in inputTracks)
{
ulong remainingSectors = currentTrack.TrackEndSector - currentTrack.TrackStartSector;
ulong currentSector = 0;
ulong currentSector = 0;
while(remainingSectors > 0)
{
@@ -138,11 +138,11 @@ namespace DiscImageChef.Commands
if(remainingSectors < 512)
inputFormat.VerifySectors(currentSector, (uint)remainingSectors,
currentTrack.TrackSequence, out tempfailingLbas,
out tempunknownLbas);
currentTrack.TrackSequence, out tempfailingLbas,
out tempunknownLbas);
else
inputFormat.VerifySectors(currentSector, 512, currentTrack.TrackSequence,
out tempfailingLbas, out tempunknownLbas);
out tempfailingLbas, out tempunknownLbas);
failingLbas.AddRange(tempfailingLbas);
@@ -150,13 +150,13 @@ namespace DiscImageChef.Commands
if(remainingSectors < 512)
{
currentSector += remainingSectors;
currentSector += remainingSectors;
currentSectorAll += remainingSectors;
remainingSectors = 0;
remainingSectors = 0;
}
else
{
currentSector += 512;
currentSector += 512;
currentSectorAll += 512;
remainingSectors -= 512;
}
@@ -168,7 +168,7 @@ namespace DiscImageChef.Commands
else
{
ulong remainingSectors = inputFormat.Info.Sectors;
ulong currentSector = 0;
ulong currentSector = 0;
startCheck = DateTime.UtcNow;
while(remainingSectors > 0)
@@ -179,10 +179,9 @@ namespace DiscImageChef.Commands
List<ulong> tempunknownLbas;
if(remainingSectors < 512)
inputFormat.VerifySectors(currentSector, (uint)remainingSectors,
out tempfailingLbas, out tempunknownLbas);
else
inputFormat.VerifySectors(currentSector, 512, out tempfailingLbas, out tempunknownLbas);
inputFormat.VerifySectors(currentSector, (uint)remainingSectors, out tempfailingLbas,
out tempunknownLbas);
else inputFormat.VerifySectors(currentSector, 512, out tempfailingLbas, out tempunknownLbas);
failingLbas.AddRange(tempfailingLbas);
@@ -190,12 +189,12 @@ namespace DiscImageChef.Commands
if(remainingSectors < 512)
{
currentSector += remainingSectors;
remainingSectors = 0;
currentSector += remainingSectors;
remainingSectors = 0;
}
else
{
currentSector += 512;
currentSector += 512;
remainingSectors -= 512;
}
}
@@ -205,15 +204,14 @@ namespace DiscImageChef.Commands
TimeSpan checkTime = endCheck - startCheck;
DicConsole.Write("\r" + new string(' ', System.Console.WindowWidth-1) + "\r");
DicConsole.Write("\r" + new string(' ', System.Console.WindowWidth - 1) + "\r");
if(unknownSectors > 0)
DicConsole.WriteLine("There is at least one sector that does not contain a checksum");
if(errorSectors > 0)
if(errorSectors > 0)
DicConsole.WriteLine("There is at least one sector with incorrect checksum or errors");
if(unknownSectors == 0 && errorSectors == 0)
DicConsole.WriteLine("All sector checksums are correct");
if(unknownSectors == 0 && errorSectors == 0) DicConsole.WriteLine("All sector checksums are correct");
DicConsole.VerboseWriteLine("Checking sector checksums took {0} seconds", checkTime.TotalSeconds);
if(options.Verbose)
@@ -221,12 +219,16 @@ namespace DiscImageChef.Commands
DicConsole.VerboseWriteLine("LBAs with error:");
if(failingLbas.Count == (int)inputFormat.Info.Sectors)
DicConsole.VerboseWriteLine("\tall sectors.");
else foreach(ulong t in failingLbas) DicConsole.VerboseWriteLine("\t{0}", t);
else
foreach(ulong t in failingLbas)
DicConsole.VerboseWriteLine("\t{0}", t);
DicConsole.WriteLine("LBAs without checksum:");
if(unknownLbas.Count == (int)inputFormat.Info.Sectors)
DicConsole.VerboseWriteLine("\tall sectors.");
else foreach(ulong t in unknownLbas) DicConsole.VerboseWriteLine("\t{0}", t);
else
foreach(ulong t in unknownLbas)
DicConsole.VerboseWriteLine("\t{0}", t);
}
DicConsole.WriteLine("Total sectors........... {0}", inputFormat.Info.Sectors);
@@ -234,8 +236,8 @@ namespace DiscImageChef.Commands
DicConsole.WriteLine("Total unknowns.......... {0}", unknownLbas.Count);
DicConsole.WriteLine("Total errors+unknowns... {0}", failingLbas.Count + unknownLbas.Count);
totalSectors = (long)inputFormat.Info.Sectors;
errorSectors = failingLbas.Count;
totalSectors = (long)inputFormat.Info.Sectors;
errorSectors = failingLbas.Count;
unknownSectors = unknownLbas.Count;
correctSectors = totalSectors - errorSectors - unknownSectors;
}