mirror of
https://github.com/aaru-dps/Aaru.Server.git
synced 2025-12-16 19:24:27 +00:00
REFACTOR: Invert 'if' statement to reduce nesting.
This commit is contained in:
@@ -110,12 +110,11 @@ namespace DiscImageChef.Decoders.SCSI
|
||||
if(page.DVW) sb.AppendLine("\tVerifying after writing is disabled");
|
||||
if(page.DDE) sb.AppendLine("\tDrive will abort when a writing error is detected");
|
||||
|
||||
if(page.SLM)
|
||||
{
|
||||
sb.Append("\tDrive has two LUNs with rewritable being ");
|
||||
if(page.SLM) sb.AppendLine("LUN 1");
|
||||
else sb.AppendLine("LUN 0");
|
||||
}
|
||||
if(!page.SLM) return sb.ToString();
|
||||
|
||||
sb.Append("\tDrive has two LUNs with rewritable being ");
|
||||
if(page.SLM) sb.AppendLine("LUN 1");
|
||||
else sb.AppendLine("LUN 0");
|
||||
|
||||
return sb.ToString();
|
||||
}
|
||||
|
||||
@@ -228,26 +228,25 @@ namespace DiscImageChef.Decoders.SCSI
|
||||
}
|
||||
}
|
||||
|
||||
if(page.OutputPort3ChannelSelection > 0)
|
||||
{
|
||||
sb.Append("\tOutput port 3 has channels ");
|
||||
if((page.OutputPort3ChannelSelection & 0x01) == 0x01) sb.Append("0 ");
|
||||
if((page.OutputPort3ChannelSelection & 0x02) == 0x02) sb.Append("1 ");
|
||||
if((page.OutputPort3ChannelSelection & 0x04) == 0x04) sb.Append("2 ");
|
||||
if((page.OutputPort3ChannelSelection & 0x08) == 0x08) sb.Append("3 ");
|
||||
if(page.OutputPort3ChannelSelection <= 0) return sb.ToString();
|
||||
|
||||
switch(page.OutputPort3Volume)
|
||||
{
|
||||
case 0:
|
||||
sb.AppendLine("muted");
|
||||
break;
|
||||
case 0xFF:
|
||||
sb.AppendLine("at maximum volume");
|
||||
break;
|
||||
default:
|
||||
sb.AppendFormat("at volume {0}", page.OutputPort3Volume).AppendLine();
|
||||
break;
|
||||
}
|
||||
sb.Append("\tOutput port 3 has channels ");
|
||||
if((page.OutputPort3ChannelSelection & 0x01) == 0x01) sb.Append("0 ");
|
||||
if((page.OutputPort3ChannelSelection & 0x02) == 0x02) sb.Append("1 ");
|
||||
if((page.OutputPort3ChannelSelection & 0x04) == 0x04) sb.Append("2 ");
|
||||
if((page.OutputPort3ChannelSelection & 0x08) == 0x08) sb.Append("3 ");
|
||||
|
||||
switch(page.OutputPort3Volume)
|
||||
{
|
||||
case 0:
|
||||
sb.AppendLine("muted");
|
||||
break;
|
||||
case 0xFF:
|
||||
sb.AppendLine("at maximum volume");
|
||||
break;
|
||||
default:
|
||||
sb.AppendFormat("at volume {0}", page.OutputPort3Volume).AppendLine();
|
||||
break;
|
||||
}
|
||||
|
||||
return sb.ToString();
|
||||
|
||||
@@ -91,11 +91,10 @@ namespace DiscImageChef.Decoders.SCSI
|
||||
sb.AppendFormat("\tVendor-specific mode control: {0}", page.ModeControl);
|
||||
sb.AppendFormat("\tVendor-specific velocity setting: {0}", page.VelocitySetting);
|
||||
|
||||
if(page.EncryptionCapable)
|
||||
{
|
||||
sb.AppendLine("\tDrive supports encryption");
|
||||
if(page.EncryptionEnabled) sb.AppendLine("\tDrive has encryption enabled");
|
||||
}
|
||||
if(!page.EncryptionCapable) return sb.ToString();
|
||||
|
||||
sb.AppendLine("\tDrive supports encryption");
|
||||
if(page.EncryptionEnabled) sb.AppendLine("\tDrive has encryption enabled");
|
||||
|
||||
return sb.ToString();
|
||||
}
|
||||
|
||||
@@ -236,37 +236,38 @@ namespace DiscImageChef.Decoders.SCSI
|
||||
|
||||
if(longLBA) hdr[4] += 0x01;
|
||||
|
||||
if(header.BlockDescriptors != null)
|
||||
if(longLBA)
|
||||
for(int i = 0; i < header.BlockDescriptors.Length; i++)
|
||||
{
|
||||
byte[] temp = BitConverter.GetBytes(header.BlockDescriptors[i].Blocks);
|
||||
hdr[7 + i * 16 + 8] = temp[0];
|
||||
hdr[6 + i * 16 + 8] = temp[1];
|
||||
hdr[5 + i * 16 + 8] = temp[2];
|
||||
hdr[4 + i * 16 + 8] = temp[3];
|
||||
hdr[3 + i * 16 + 8] = temp[4];
|
||||
hdr[2 + i * 16 + 8] = temp[5];
|
||||
hdr[1 + i * 16 + 8] = temp[6];
|
||||
hdr[0 + i * 16 + 8] = temp[7];
|
||||
hdr[12 + i * 16 + 8] = (byte)((header.BlockDescriptors[i].BlockLength & 0xFF000000) >> 24);
|
||||
hdr[13 + i * 16 + 8] = (byte)((header.BlockDescriptors[i].BlockLength & 0xFF0000) >> 16);
|
||||
hdr[14 + i * 16 + 8] = (byte)((header.BlockDescriptors[i].BlockLength & 0xFF00) >> 8);
|
||||
hdr[15 + i * 16 + 8] = (byte)(header.BlockDescriptors[i].BlockLength & 0xFF);
|
||||
}
|
||||
else
|
||||
for(int i = 0; i < header.BlockDescriptors.Length; i++)
|
||||
{
|
||||
if(deviceType != PeripheralDeviceTypes.DirectAccess)
|
||||
hdr[0 + i * 8 + 8] = (byte)header.BlockDescriptors[i].Density;
|
||||
else hdr[0 + i * 8 + 8] = (byte)((header.BlockDescriptors[i].Blocks & 0xFF000000) >> 24);
|
||||
hdr[1 + i * 8 + 8] = (byte)((header.BlockDescriptors[i].Blocks & 0xFF0000) >> 16);
|
||||
hdr[2 + i * 8 + 8] = (byte)((header.BlockDescriptors[i].Blocks & 0xFF00) >> 8);
|
||||
hdr[3 + i * 8 + 8] = (byte)(header.BlockDescriptors[i].Blocks & 0xFF);
|
||||
hdr[5 + i * 8 + 8] = (byte)((header.BlockDescriptors[i].BlockLength & 0xFF0000) >> 16);
|
||||
hdr[6 + i * 8 + 8] = (byte)((header.BlockDescriptors[i].BlockLength & 0xFF00) >> 8);
|
||||
hdr[7 + i * 8 + 8] = (byte)(header.BlockDescriptors[i].BlockLength & 0xFF);
|
||||
}
|
||||
if(header.BlockDescriptors == null) return hdr;
|
||||
|
||||
if(longLBA)
|
||||
for(int i = 0; i < header.BlockDescriptors.Length; i++)
|
||||
{
|
||||
byte[] temp = BitConverter.GetBytes(header.BlockDescriptors[i].Blocks);
|
||||
hdr[7 + i * 16 + 8] = temp[0];
|
||||
hdr[6 + i * 16 + 8] = temp[1];
|
||||
hdr[5 + i * 16 + 8] = temp[2];
|
||||
hdr[4 + i * 16 + 8] = temp[3];
|
||||
hdr[3 + i * 16 + 8] = temp[4];
|
||||
hdr[2 + i * 16 + 8] = temp[5];
|
||||
hdr[1 + i * 16 + 8] = temp[6];
|
||||
hdr[0 + i * 16 + 8] = temp[7];
|
||||
hdr[12 + i * 16 + 8] = (byte)((header.BlockDescriptors[i].BlockLength & 0xFF000000) >> 24);
|
||||
hdr[13 + i * 16 + 8] = (byte)((header.BlockDescriptors[i].BlockLength & 0xFF0000) >> 16);
|
||||
hdr[14 + i * 16 + 8] = (byte)((header.BlockDescriptors[i].BlockLength & 0xFF00) >> 8);
|
||||
hdr[15 + i * 16 + 8] = (byte)(header.BlockDescriptors[i].BlockLength & 0xFF);
|
||||
}
|
||||
else
|
||||
for(int i = 0; i < header.BlockDescriptors.Length; i++)
|
||||
{
|
||||
if(deviceType != PeripheralDeviceTypes.DirectAccess)
|
||||
hdr[0 + i * 8 + 8] = (byte)header.BlockDescriptors[i].Density;
|
||||
else hdr[0 + i * 8 + 8] = (byte)((header.BlockDescriptors[i].Blocks & 0xFF000000) >> 24);
|
||||
hdr[1 + i * 8 + 8] = (byte)((header.BlockDescriptors[i].Blocks & 0xFF0000) >> 16);
|
||||
hdr[2 + i * 8 + 8] = (byte)((header.BlockDescriptors[i].Blocks & 0xFF00) >> 8);
|
||||
hdr[3 + i * 8 + 8] = (byte)(header.BlockDescriptors[i].Blocks & 0xFF);
|
||||
hdr[5 + i * 8 + 8] = (byte)((header.BlockDescriptors[i].BlockLength & 0xFF0000) >> 16);
|
||||
hdr[6 + i * 8 + 8] = (byte)((header.BlockDescriptors[i].BlockLength & 0xFF00) >> 8);
|
||||
hdr[7 + i * 8 + 8] = (byte)(header.BlockDescriptors[i].BlockLength & 0xFF);
|
||||
}
|
||||
|
||||
return hdr;
|
||||
}
|
||||
@@ -282,7 +283,8 @@ namespace DiscImageChef.Decoders.SCSI
|
||||
|
||||
Array.Copy(hdr, 0, md, 0, hdr.Length);
|
||||
|
||||
if(mode.Pages != null)
|
||||
if(mode.Pages == null) return md;
|
||||
|
||||
{
|
||||
int offset = hdr.Length;
|
||||
foreach(ModePage page in mode.Pages)
|
||||
|
||||
@@ -184,20 +184,19 @@ namespace DiscImageChef.Decoders.SCSI
|
||||
break;
|
||||
}
|
||||
|
||||
if(header.BlockDescriptors != null)
|
||||
{
|
||||
hdr[3] = (byte)(header.BlockDescriptors.Length * 8);
|
||||
if(header.BlockDescriptors == null) return hdr;
|
||||
|
||||
for(int i = 0; i < header.BlockDescriptors.Length; i++)
|
||||
{
|
||||
hdr[0 + i * 8 + 4] = (byte)header.BlockDescriptors[i].Density;
|
||||
hdr[1 + i * 8 + 4] = (byte)((header.BlockDescriptors[i].Blocks & 0xFF0000) >> 16);
|
||||
hdr[2 + i * 8 + 4] = (byte)((header.BlockDescriptors[i].Blocks & 0xFF00) >> 8);
|
||||
hdr[3 + i * 8 + 4] = (byte)(header.BlockDescriptors[i].Blocks & 0xFF);
|
||||
hdr[5 + i * 8 + 4] = (byte)((header.BlockDescriptors[i].BlockLength & 0xFF0000) >> 16);
|
||||
hdr[6 + i * 8 + 4] = (byte)((header.BlockDescriptors[i].BlockLength & 0xFF00) >> 8);
|
||||
hdr[7 + i * 8 + 4] = (byte)(header.BlockDescriptors[i].BlockLength & 0xFF);
|
||||
}
|
||||
hdr[3] = (byte)(header.BlockDescriptors.Length * 8);
|
||||
|
||||
for(int i = 0; i < header.BlockDescriptors.Length; i++)
|
||||
{
|
||||
hdr[0 + i * 8 + 4] = (byte)header.BlockDescriptors[i].Density;
|
||||
hdr[1 + i * 8 + 4] = (byte)((header.BlockDescriptors[i].Blocks & 0xFF0000) >> 16);
|
||||
hdr[2 + i * 8 + 4] = (byte)((header.BlockDescriptors[i].Blocks & 0xFF00) >> 8);
|
||||
hdr[3 + i * 8 + 4] = (byte)(header.BlockDescriptors[i].Blocks & 0xFF);
|
||||
hdr[5 + i * 8 + 4] = (byte)((header.BlockDescriptors[i].BlockLength & 0xFF0000) >> 16);
|
||||
hdr[6 + i * 8 + 4] = (byte)((header.BlockDescriptors[i].BlockLength & 0xFF00) >> 8);
|
||||
hdr[7 + i * 8 + 4] = (byte)(header.BlockDescriptors[i].BlockLength & 0xFF);
|
||||
}
|
||||
|
||||
return hdr;
|
||||
@@ -214,7 +213,8 @@ namespace DiscImageChef.Decoders.SCSI
|
||||
|
||||
Array.Copy(hdr, 0, md, 0, hdr.Length);
|
||||
|
||||
if(mode.Pages != null)
|
||||
if(mode.Pages == null) return md;
|
||||
|
||||
{
|
||||
int offset = hdr.Length;
|
||||
foreach(ModePage page in mode.Pages)
|
||||
|
||||
Reference in New Issue
Block a user