REFACTOR: Invert 'if' statement to reduce nesting.

This commit is contained in:
2017-12-21 06:06:19 +00:00
parent 9cd1869d1d
commit 4d886dae25
138 changed files with 9447 additions and 9806 deletions

View File

@@ -504,13 +504,12 @@ namespace DiscImageChef.Core.Devices.Dumping
foreach(Filesystem plugin in plugins.PluginsList.Values)
try
{
if(plugin.Identify(imageFormat, partitions[i]))
{
plugin.GetInformation(imageFormat, partitions[i], out string foo);
lstFs.Add(plugin.XmlFSType);
Statistics.AddFilesystem(plugin.XmlFSType.Type);
dumpLog.WriteLine("Filesystem {0} found.", plugin.XmlFSType.Type);
}
if(!plugin.Identify(imageFormat, partitions[i])) continue;
plugin.GetInformation(imageFormat, partitions[i], out string foo);
lstFs.Add(plugin.XmlFSType);
Statistics.AddFilesystem(plugin.XmlFSType.Type);
dumpLog.WriteLine("Filesystem {0} found.", plugin.XmlFSType.Type);
}
#pragma warning disable RECS0022 // A catch clause that catches System.Exception and has an empty body
catch
@@ -540,13 +539,12 @@ namespace DiscImageChef.Core.Devices.Dumping
foreach(Filesystem plugin in plugins.PluginsList.Values)
try
{
if(plugin.Identify(imageFormat, wholePart))
{
plugin.GetInformation(imageFormat, wholePart, out string foo);
lstFs.Add(plugin.XmlFSType);
Statistics.AddFilesystem(plugin.XmlFSType.Type);
dumpLog.WriteLine("Filesystem {0} found.", plugin.XmlFSType.Type);
}
if(!plugin.Identify(imageFormat, wholePart)) continue;
plugin.GetInformation(imageFormat, wholePart, out string foo);
lstFs.Add(plugin.XmlFSType);
Statistics.AddFilesystem(plugin.XmlFSType.Type);
dumpLog.WriteLine("Filesystem {0} found.", plugin.XmlFSType.Type);
}
#pragma warning disable RECS0022 // A catch clause that catches System.Exception and has an empty body
catch

View File

@@ -715,22 +715,21 @@ namespace DiscImageChef.Core.Devices.Dumping
totalDuration += cmdDuration;
}
if(!sense && !dev.Error || runningPersistent)
{
if(!sense && !dev.Error)
{
resume.BadBlocks.Remove(badSector);
extents.Add(badSector);
dumpLog.WriteLine("Correctly retried sector {0} in pass {1}.", badSector, pass);
}
if((sense || dev.Error) && !runningPersistent) continue;
if(separateSubchannel)
{
dumpFile.WriteAt(readBuffer, badSector, (uint)sectorSize, 0, sectorSize);
subFile.WriteAt(readBuffer, badSector, subSize, sectorSize, (int)subSize);
}
else dumpFile.WriteAt(readBuffer, badSector, blockSize);
if(!sense && !dev.Error)
{
resume.BadBlocks.Remove(badSector);
extents.Add(badSector);
dumpLog.WriteLine("Correctly retried sector {0} in pass {1}.", badSector, pass);
}
if(separateSubchannel)
{
dumpFile.WriteAt(readBuffer, badSector, (uint)sectorSize, 0, sectorSize);
subFile.WriteAt(readBuffer, badSector, subSize, sectorSize, (int)subSize);
}
else dumpFile.WriteAt(readBuffer, badSector, blockSize);
}
if(pass < retryPasses && !aborted && resume.BadBlocks.Count > 0)

View File

@@ -78,31 +78,29 @@ namespace DiscImageChef.Core.Devices.Dumping
if(oldtry.Software == null) throw new Exception("Found corrupt resume file, cannot continue...");
if(oldtry.Software.Name == "DiscImageChef" &&
oldtry.Software.OperatingSystem == platform.ToString() &&
oldtry.Software.Version == Version.GetVersion())
{
if(removable && (oldtry.Manufacturer != manufacturer || oldtry.Model != model ||
oldtry.Serial != serial)) continue;
if(oldtry.Software.Name != "DiscImageChef" ||
oldtry.Software.OperatingSystem != platform.ToString() ||
oldtry.Software.Version != Version.GetVersion()) continue;
currentTry = oldtry;
extents = ExtentsConverter.FromMetadata(currentTry.Extents);
break;
}
if(removable && (oldtry.Manufacturer != manufacturer || oldtry.Model != model ||
oldtry.Serial != serial)) continue;
currentTry = oldtry;
extents = ExtentsConverter.FromMetadata(currentTry.Extents);
break;
}
if(currentTry == null)
if(currentTry != null) return;
currentTry = new DumpHardwareType
{
currentTry = new DumpHardwareType
{
Software = Version.GetSoftwareType(platform),
Manufacturer = manufacturer,
Model = model,
Serial = serial
};
resume.Tries.Add(currentTry);
extents = new ExtentsULong();
}
Software = Version.GetSoftwareType(platform),
Manufacturer = manufacturer,
Model = model,
Serial = serial
};
resume.Tries.Add(currentTry);
extents = new ExtentsULong();
}
else
{

View File

@@ -211,18 +211,17 @@ namespace DiscImageChef.Core.Devices.Dumping
{
dumpLog.WriteLine("Requesting page {0:X2}h.", page);
sense = dev.ScsiInquiry(out cmdBuf, out senseBuf, page);
if(!sense)
if(sense) continue;
EVPDType evpd = new EVPDType
{
EVPDType evpd = new EVPDType
{
Image = string.Format("{0}.evpd_{1:X2}h.bin", outputPrefix, page),
Checksums = Checksum.GetChecksums(cmdBuf).ToArray(),
Size = cmdBuf.Length
};
evpd.Checksums = Checksum.GetChecksums(cmdBuf).ToArray();
DataFile.WriteTo("SCSI Dump", evpd.Image, cmdBuf);
evpds.Add(evpd);
}
Image = string.Format("{0}.evpd_{1:X2}h.bin", outputPrefix, page),
Checksums = Checksum.GetChecksums(cmdBuf).ToArray(),
Size = cmdBuf.Length
};
evpd.Checksums = Checksum.GetChecksums(cmdBuf).ToArray();
DataFile.WriteTo("SCSI Dump", evpd.Image, cmdBuf);
evpds.Add(evpd);
}
if(evpds.Count > 0) sidecar.BlockMedia[0].SCSI.EVPD = evpds.ToArray();
@@ -651,23 +650,22 @@ namespace DiscImageChef.Core.Devices.Dumping
foreach(Filesystem plugin in plugins.PluginsList.Values)
try
{
if(plugin.Identify(imageFormat, partitions[i]))
{
plugin.GetInformation(imageFormat, partitions[i], out string foo);
lstFs.Add(plugin.XmlFSType);
Statistics.AddFilesystem(plugin.XmlFSType.Type);
dumpLog.WriteLine("Filesystem {0} found.", plugin.XmlFSType.Type);
if(!plugin.Identify(imageFormat, partitions[i])) continue;
switch(plugin.XmlFSType.Type) {
case "Opera": dskType = MediaType.ThreeDO;
break;
case "PC Engine filesystem": dskType = MediaType.SuperCDROM2;
break;
case "Nintendo Wii filesystem": dskType = MediaType.WOD;
break;
case "Nintendo Gamecube filesystem": dskType = MediaType.GOD;
break;
}
plugin.GetInformation(imageFormat, partitions[i], out string foo);
lstFs.Add(plugin.XmlFSType);
Statistics.AddFilesystem(plugin.XmlFSType.Type);
dumpLog.WriteLine("Filesystem {0} found.", plugin.XmlFSType.Type);
switch(plugin.XmlFSType.Type) {
case "Opera": dskType = MediaType.ThreeDO;
break;
case "PC Engine filesystem": dskType = MediaType.SuperCDROM2;
break;
case "Nintendo Wii filesystem": dskType = MediaType.WOD;
break;
case "Nintendo Gamecube filesystem": dskType = MediaType.GOD;
break;
}
}
#pragma warning disable RECS0022 // A catch clause that catches System.Exception and has an empty body
@@ -693,23 +691,22 @@ namespace DiscImageChef.Core.Devices.Dumping
foreach(Filesystem plugin in plugins.PluginsList.Values)
try
{
if(plugin.Identify(imageFormat, wholePart))
{
plugin.GetInformation(imageFormat, wholePart, out string foo);
lstFs.Add(plugin.XmlFSType);
Statistics.AddFilesystem(plugin.XmlFSType.Type);
dumpLog.WriteLine("Filesystem {0} found.", plugin.XmlFSType.Type);
if(!plugin.Identify(imageFormat, wholePart)) continue;
switch(plugin.XmlFSType.Type) {
case "Opera": dskType = MediaType.ThreeDO;
break;
case "PC Engine filesystem": dskType = MediaType.SuperCDROM2;
break;
case "Nintendo Wii filesystem": dskType = MediaType.WOD;
break;
case "Nintendo Gamecube filesystem": dskType = MediaType.GOD;
break;
}
plugin.GetInformation(imageFormat, wholePart, out string foo);
lstFs.Add(plugin.XmlFSType);
Statistics.AddFilesystem(plugin.XmlFSType.Type);
dumpLog.WriteLine("Filesystem {0} found.", plugin.XmlFSType.Type);
switch(plugin.XmlFSType.Type) {
case "Opera": dskType = MediaType.ThreeDO;
break;
case "PC Engine filesystem": dskType = MediaType.SuperCDROM2;
break;
case "Nintendo Wii filesystem": dskType = MediaType.WOD;
break;
case "Nintendo Gamecube filesystem": dskType = MediaType.GOD;
break;
}
}
#pragma warning disable RECS0022 // A catch clause that catches System.Exception and has an empty body

View File

@@ -495,13 +495,12 @@ namespace DiscImageChef.Core.Devices.Dumping
foreach(Filesystem plugin in plugins.PluginsList.Values)
try
{
if(plugin.Identify(imageFormat, partitions[i]))
{
plugin.GetInformation(imageFormat, partitions[i], out string foo);
lstFs.Add(plugin.XmlFSType);
Statistics.AddFilesystem(plugin.XmlFSType.Type);
dumpLog.WriteLine("Filesystem {0} found.", plugin.XmlFSType.Type);
}
if(!plugin.Identify(imageFormat, partitions[i])) continue;
plugin.GetInformation(imageFormat, partitions[i], out string foo);
lstFs.Add(plugin.XmlFSType);
Statistics.AddFilesystem(plugin.XmlFSType.Type);
dumpLog.WriteLine("Filesystem {0} found.", plugin.XmlFSType.Type);
}
#pragma warning disable RECS0022 // A catch clause that catches System.Exception and has an empty body
catch
@@ -527,13 +526,12 @@ namespace DiscImageChef.Core.Devices.Dumping
foreach(Filesystem plugin in plugins.PluginsList.Values)
try
{
if(plugin.Identify(imageFormat, wholePart))
{
plugin.GetInformation(imageFormat, wholePart, out string foo);
lstFs.Add(plugin.XmlFSType);
Statistics.AddFilesystem(plugin.XmlFSType.Type);
dumpLog.WriteLine("Filesystem {0} found.", plugin.XmlFSType.Type);
}
if(!plugin.Identify(imageFormat, wholePart)) continue;
plugin.GetInformation(imageFormat, wholePart, out string foo);
lstFs.Add(plugin.XmlFSType);
Statistics.AddFilesystem(plugin.XmlFSType.Type);
dumpLog.WriteLine("Filesystem {0} found.", plugin.XmlFSType.Type);
}
#pragma warning disable RECS0022 // A catch clause that catches System.Exception and has an empty body
catch

View File

@@ -850,23 +850,22 @@ namespace DiscImageChef.Core.Devices.Dumping
foreach(Filesystem plugin in plugins.PluginsList.Values)
try
{
if(plugin.Identify(imageFormat, partitions[i]))
{
plugin.GetInformation(imageFormat, partitions[i], out string foo);
lstFs.Add(plugin.XmlFSType);
Statistics.AddFilesystem(plugin.XmlFSType.Type);
dumpLog.WriteLine("Filesystem {0} found.", plugin.XmlFSType.Type);
if(!plugin.Identify(imageFormat, partitions[i])) continue;
switch(plugin.XmlFSType.Type) {
case "Opera": dskType = MediaType.ThreeDO;
break;
case "PC Engine filesystem": dskType = MediaType.SuperCDROM2;
break;
case "Nintendo Wii filesystem": dskType = MediaType.WOD;
break;
case "Nintendo Gamecube filesystem": dskType = MediaType.GOD;
break;
}
plugin.GetInformation(imageFormat, partitions[i], out string foo);
lstFs.Add(plugin.XmlFSType);
Statistics.AddFilesystem(plugin.XmlFSType.Type);
dumpLog.WriteLine("Filesystem {0} found.", plugin.XmlFSType.Type);
switch(plugin.XmlFSType.Type) {
case "Opera": dskType = MediaType.ThreeDO;
break;
case "PC Engine filesystem": dskType = MediaType.SuperCDROM2;
break;
case "Nintendo Wii filesystem": dskType = MediaType.WOD;
break;
case "Nintendo Gamecube filesystem": dskType = MediaType.GOD;
break;
}
}
#pragma warning disable RECS0022 // A catch clause that catches System.Exception and has an empty body
@@ -892,23 +891,22 @@ namespace DiscImageChef.Core.Devices.Dumping
foreach(Filesystem plugin in plugins.PluginsList.Values)
try
{
if(plugin.Identify(imageFormat, wholePart))
{
plugin.GetInformation(imageFormat, wholePart, out string foo);
lstFs.Add(plugin.XmlFSType);
Statistics.AddFilesystem(plugin.XmlFSType.Type);
dumpLog.WriteLine("Filesystem {0} found.", plugin.XmlFSType.Type);
if(!plugin.Identify(imageFormat, wholePart)) continue;
switch(plugin.XmlFSType.Type) {
case "Opera": dskType = MediaType.ThreeDO;
break;
case "PC Engine filesystem": dskType = MediaType.SuperCDROM2;
break;
case "Nintendo Wii filesystem": dskType = MediaType.WOD;
break;
case "Nintendo Gamecube filesystem": dskType = MediaType.GOD;
break;
}
plugin.GetInformation(imageFormat, wholePart, out string foo);
lstFs.Add(plugin.XmlFSType);
Statistics.AddFilesystem(plugin.XmlFSType.Type);
dumpLog.WriteLine("Filesystem {0} found.", plugin.XmlFSType.Type);
switch(plugin.XmlFSType.Type) {
case "Opera": dskType = MediaType.ThreeDO;
break;
case "PC Engine filesystem": dskType = MediaType.SuperCDROM2;
break;
case "Nintendo Wii filesystem": dskType = MediaType.WOD;
break;
case "Nintendo Gamecube filesystem": dskType = MediaType.GOD;
break;
}
}
#pragma warning disable RECS0022 // A catch clause that catches System.Exception and has an empty body