Code style fixes.

This commit is contained in:
2020-07-22 13:20:25 +01:00
parent 4cbfe9b0cd
commit b52d623764
3 changed files with 89 additions and 108 deletions

View File

@@ -177,9 +177,7 @@ namespace Aaru.Decoders.ATA
{ {
sb.Append("ATA-1 "); sb.Append("ATA-1 ");
maxatalevel = 1; maxatalevel = 1;
minatalevel = 1;
if(minatalevel > 1)
minatalevel = 1;
} }
if(ata2) if(ata2)
@@ -751,11 +749,11 @@ namespace Aaru.Decoders.ATA
else else
sb.AppendFormat("Device rotate at {0} rpm", ATAID.NominalRotationRate).AppendLine(); sb.AppendFormat("Device rotate at {0} rpm", ATAID.NominalRotationRate).AppendLine();
uint logicalsectorsize = 0; uint logicalSectorSize = 0;
if(!atapi) if(!atapi)
{ {
uint physicalsectorsize; uint physicalSectorSize;
if((ATAID.PhysLogSectorSize & 0x8000) == 0x0000 && if((ATAID.PhysLogSectorSize & 0x8000) == 0x0000 &&
(ATAID.PhysLogSectorSize & 0x4000) == 0x4000) (ATAID.PhysLogSectorSize & 0x4000) == 0x4000)
@@ -763,27 +761,27 @@ namespace Aaru.Decoders.ATA
if((ATAID.PhysLogSectorSize & 0x1000) == 0x1000) if((ATAID.PhysLogSectorSize & 0x1000) == 0x1000)
if(ATAID.LogicalSectorWords <= 255 || if(ATAID.LogicalSectorWords <= 255 ||
ATAID.LogicalAlignment == 0xFFFF) ATAID.LogicalAlignment == 0xFFFF)
logicalsectorsize = 512; logicalSectorSize = 512;
else else
logicalsectorsize = ATAID.LogicalSectorWords * 2; logicalSectorSize = ATAID.LogicalSectorWords * 2;
else else
logicalsectorsize = 512; logicalSectorSize = 512;
if((ATAID.PhysLogSectorSize & 0x2000) == 0x2000) if((ATAID.PhysLogSectorSize & 0x2000) == 0x2000)
physicalsectorsize = logicalsectorsize * (uint)Math.Pow(2, ATAID.PhysLogSectorSize & 0xF); physicalSectorSize = logicalSectorSize * (uint)Math.Pow(2, ATAID.PhysLogSectorSize & 0xF);
else else
physicalsectorsize = logicalsectorsize; physicalSectorSize = logicalSectorSize;
} }
else else
{ {
logicalsectorsize = 512; logicalSectorSize = 512;
physicalsectorsize = 512; physicalSectorSize = 512;
} }
sb.AppendFormat("Physical sector size: {0} bytes", physicalsectorsize).AppendLine(); sb.AppendFormat("Physical sector size: {0} bytes", physicalSectorSize).AppendLine();
sb.AppendFormat("Logical sector size: {0} bytes", logicalsectorsize).AppendLine(); sb.AppendFormat("Logical sector size: {0} bytes", logicalSectorSize).AppendLine();
if(logicalsectorsize != physicalsectorsize && if(logicalSectorSize != physicalSectorSize &&
(ATAID.LogicalAlignment & 0x8000) == 0x0000 && (ATAID.LogicalAlignment & 0x8000) == 0x0000 &&
(ATAID.LogicalAlignment & 0x4000) == 0x4000) (ATAID.LogicalAlignment & 0x4000) == 0x4000)
sb.AppendFormat("Logical sector starts at offset {0} from physical sector", sb.AppendFormat("Logical sector starts at offset {0} from physical sector",
@@ -825,73 +823,73 @@ namespace Aaru.Decoders.ATA
if(minatalevel <= 5) if(minatalevel <= 5)
if(ATAID.CurrentSectors > 0) if(ATAID.CurrentSectors > 0)
sb.AppendFormat("Device size in CHS mode: {0} bytes, {1} Mb, {2} MiB", sb.AppendFormat("Device size in CHS mode: {0} bytes, {1} Mb, {2} MiB",
(ulong)ATAID.CurrentSectors * logicalsectorsize, (ulong)ATAID.CurrentSectors * logicalSectorSize,
((ulong)ATAID.CurrentSectors * logicalsectorsize) / 1000 / 1000, ((ulong)ATAID.CurrentSectors * logicalSectorSize) / 1000 / 1000,
((ulong)ATAID.CurrentSectors * 512) / 1024 / 1024).AppendLine(); ((ulong)ATAID.CurrentSectors * 512) / 1024 / 1024).AppendLine();
else else
{ {
ulong currentSectors = (ulong)(ATAID.Cylinders * ATAID.Heads * ATAID.SectorsPerTrack); ulong currentSectors = (ulong)(ATAID.Cylinders * ATAID.Heads * ATAID.SectorsPerTrack);
sb.AppendFormat("Device size in CHS mode: {0} bytes, {1} Mb, {2} MiB", sb.AppendFormat("Device size in CHS mode: {0} bytes, {1} Mb, {2} MiB",
currentSectors * logicalsectorsize, currentSectors * logicalSectorSize,
(currentSectors * logicalsectorsize) / 1000 / 1000, (currentSectors * logicalSectorSize) / 1000 / 1000,
(currentSectors * 512) / 1024 / 1024).AppendLine(); (currentSectors * 512) / 1024 / 1024).AppendLine();
} }
if(ATAID.Capabilities.HasFlag(CommonTypes.Structs.Devices.ATA.Identify.CapabilitiesBit.LBASupport)) if(ATAID.Capabilities.HasFlag(CommonTypes.Structs.Devices.ATA.Identify.CapabilitiesBit.LBASupport))
if(((ulong)ATAID.LBASectors * logicalsectorsize) / 1024 / 1024 > 1000000) if(((ulong)ATAID.LBASectors * logicalSectorSize) / 1024 / 1024 > 1000000)
sb.AppendFormat("Device size in 28-bit LBA mode: {0} bytes, {1} Tb, {2} TiB", sb.AppendFormat("Device size in 28-bit LBA mode: {0} bytes, {1} Tb, {2} TiB",
(ulong)ATAID.LBASectors * logicalsectorsize, (ulong)ATAID.LBASectors * logicalSectorSize,
((ulong)ATAID.LBASectors * logicalsectorsize) / 1000 / 1000 / 1000 / 1000, ((ulong)ATAID.LBASectors * logicalSectorSize) / 1000 / 1000 / 1000 / 1000,
((ulong)ATAID.LBASectors * 512) / 1024 / 1024 / 1024 / 1024).AppendLine(); ((ulong)ATAID.LBASectors * 512) / 1024 / 1024 / 1024 / 1024).AppendLine();
else if(((ulong)ATAID.LBASectors * logicalsectorsize) / 1024 / 1024 > 1000) else if(((ulong)ATAID.LBASectors * logicalSectorSize) / 1024 / 1024 > 1000)
sb.AppendFormat("Device size in 28-bit LBA mode: {0} bytes, {1} Gb, {2} GiB", sb.AppendFormat("Device size in 28-bit LBA mode: {0} bytes, {1} Gb, {2} GiB",
(ulong)ATAID.LBASectors * logicalsectorsize, (ulong)ATAID.LBASectors * logicalSectorSize,
((ulong)ATAID.LBASectors * logicalsectorsize) / 1000 / 1000 / 1000, ((ulong)ATAID.LBASectors * logicalSectorSize) / 1000 / 1000 / 1000,
((ulong)ATAID.LBASectors * 512) / 1024 / 1024 / 1024).AppendLine(); ((ulong)ATAID.LBASectors * 512) / 1024 / 1024 / 1024).AppendLine();
else else
sb.AppendFormat("Device size in 28-bit LBA mode: {0} bytes, {1} Mb, {2} MiB", sb.AppendFormat("Device size in 28-bit LBA mode: {0} bytes, {1} Mb, {2} MiB",
(ulong)ATAID.LBASectors * logicalsectorsize, (ulong)ATAID.LBASectors * logicalSectorSize,
((ulong)ATAID.LBASectors * logicalsectorsize) / 1000 / 1000, ((ulong)ATAID.LBASectors * logicalSectorSize) / 1000 / 1000,
((ulong)ATAID.LBASectors * 512) / 1024 / 1024).AppendLine(); ((ulong)ATAID.LBASectors * 512) / 1024 / 1024).AppendLine();
if(ATAID.CommandSet2.HasFlag(CommonTypes.Structs.Devices.ATA.Identify.CommandSetBit2.LBA48)) if(ATAID.CommandSet2.HasFlag(CommonTypes.Structs.Devices.ATA.Identify.CommandSetBit2.LBA48))
if(ATAID.CommandSet5.HasFlag(CommonTypes.Structs.Devices.ATA.Identify.CommandSetBit5.ExtSectors)) if(ATAID.CommandSet5.HasFlag(CommonTypes.Structs.Devices.ATA.Identify.CommandSetBit5.ExtSectors))
if((ATAID.ExtendedUserSectors * logicalsectorsize) / 1024 / 1024 > 1000000) if((ATAID.ExtendedUserSectors * logicalSectorSize) / 1024 / 1024 > 1000000)
sb.AppendFormat("Device size in 48-bit LBA mode: {0} bytes, {1} Tb, {2} TiB", sb.AppendFormat("Device size in 48-bit LBA mode: {0} bytes, {1} Tb, {2} TiB",
ATAID.ExtendedUserSectors * logicalsectorsize, ATAID.ExtendedUserSectors * logicalSectorSize,
(ATAID.ExtendedUserSectors * logicalsectorsize) / 1000 / 1000 / 1000 / 1000, (ATAID.ExtendedUserSectors * logicalSectorSize) / 1000 / 1000 / 1000 / 1000,
(ATAID.ExtendedUserSectors * logicalsectorsize) / 1024 / 1024 / 1024 / (ATAID.ExtendedUserSectors * logicalSectorSize) / 1024 / 1024 / 1024 /
1024).AppendLine(); 1024).AppendLine();
else if((ATAID.ExtendedUserSectors * logicalsectorsize) / 1024 / 1024 > 1000) else if((ATAID.ExtendedUserSectors * logicalSectorSize) / 1024 / 1024 > 1000)
sb.AppendFormat("Device size in 48-bit LBA mode: {0} bytes, {1} Gb, {2} GiB", sb.AppendFormat("Device size in 48-bit LBA mode: {0} bytes, {1} Gb, {2} GiB",
ATAID.ExtendedUserSectors * logicalsectorsize, ATAID.ExtendedUserSectors * logicalSectorSize,
(ATAID.ExtendedUserSectors * logicalsectorsize) / 1000 / 1000 / 1000, (ATAID.ExtendedUserSectors * logicalSectorSize) / 1000 / 1000 / 1000,
(ATAID.ExtendedUserSectors * logicalsectorsize) / 1024 / 1024 / 1024). (ATAID.ExtendedUserSectors * logicalSectorSize) / 1024 / 1024 / 1024).
AppendLine(); AppendLine();
else else
sb.AppendFormat("Device size in 48-bit LBA mode: {0} bytes, {1} Mb, {2} MiB", sb.AppendFormat("Device size in 48-bit LBA mode: {0} bytes, {1} Mb, {2} MiB",
ATAID.ExtendedUserSectors * logicalsectorsize, ATAID.ExtendedUserSectors * logicalSectorSize,
(ATAID.ExtendedUserSectors * logicalsectorsize) / 1000 / 1000, (ATAID.ExtendedUserSectors * logicalSectorSize) / 1000 / 1000,
(ATAID.ExtendedUserSectors * logicalsectorsize) / 1024 / 1024).AppendLine(); (ATAID.ExtendedUserSectors * logicalSectorSize) / 1024 / 1024).AppendLine();
else else
{ {
if((ATAID.LBA48Sectors * logicalsectorsize) / 1024 / 1024 > 1000000) if((ATAID.LBA48Sectors * logicalSectorSize) / 1024 / 1024 > 1000000)
sb.AppendFormat("Device size in 48-bit LBA mode: {0} bytes, {1} Tb, {2} TiB", sb.AppendFormat("Device size in 48-bit LBA mode: {0} bytes, {1} Tb, {2} TiB",
ATAID.LBA48Sectors * logicalsectorsize, ATAID.LBA48Sectors * logicalSectorSize,
(ATAID.LBA48Sectors * logicalsectorsize) / 1000 / 1000 / 1000 / 1000, (ATAID.LBA48Sectors * logicalSectorSize) / 1000 / 1000 / 1000 / 1000,
(ATAID.LBA48Sectors * logicalsectorsize) / 1024 / 1024 / 1024 / 1024). (ATAID.LBA48Sectors * logicalSectorSize) / 1024 / 1024 / 1024 / 1024).
AppendLine(); AppendLine();
else if((ATAID.LBA48Sectors * logicalsectorsize) / 1024 / 1024 > 1000) else if((ATAID.LBA48Sectors * logicalSectorSize) / 1024 / 1024 > 1000)
sb.AppendFormat("Device size in 48-bit LBA mode: {0} bytes, {1} Gb, {2} GiB", sb.AppendFormat("Device size in 48-bit LBA mode: {0} bytes, {1} Gb, {2} GiB",
ATAID.LBA48Sectors * logicalsectorsize, ATAID.LBA48Sectors * logicalSectorSize,
(ATAID.LBA48Sectors * logicalsectorsize) / 1000 / 1000 / 1000, (ATAID.LBA48Sectors * logicalSectorSize) / 1000 / 1000 / 1000,
(ATAID.LBA48Sectors * logicalsectorsize) / 1024 / 1024 / 1024).AppendLine(); (ATAID.LBA48Sectors * logicalSectorSize) / 1024 / 1024 / 1024).AppendLine();
else else
sb.AppendFormat("Device size in 48-bit LBA mode: {0} bytes, {1} Mb, {2} MiB", sb.AppendFormat("Device size in 48-bit LBA mode: {0} bytes, {1} Mb, {2} MiB",
ATAID.LBA48Sectors * logicalsectorsize, ATAID.LBA48Sectors * logicalSectorSize,
(ATAID.LBA48Sectors * logicalsectorsize) / 1000 / 1000, (ATAID.LBA48Sectors * logicalSectorSize) / 1000 / 1000,
(ATAID.LBA48Sectors * logicalsectorsize) / 1024 / 1024).AppendLine(); (ATAID.LBA48Sectors * logicalSectorSize) / 1024 / 1024).AppendLine();
} }
if(ata1 || cfa) if(ata1 || cfa)
@@ -974,7 +972,8 @@ namespace Aaru.Decoders.ATA
sb.Append("Device capabilities:"); sb.Append("Device capabilities:");
if(ATAID.Capabilities.HasFlag(CommonTypes.Structs.Devices.ATA.Identify.CapabilitiesBit.StandardStanbyTimer)) if(ATAID.Capabilities.HasFlag(CommonTypes.Structs.Devices.ATA.Identify.CapabilitiesBit.StandardStandbyTimer)
)
sb.AppendLine().Append("Standby time values are standard"); sb.AppendLine().Append("Standby time values are standard");
if(ATAID.Capabilities.HasFlag(CommonTypes.Structs.Devices.ATA.Identify.CapabilitiesBit.IORDY)) if(ATAID.Capabilities.HasFlag(CommonTypes.Structs.Devices.ATA.Identify.CapabilitiesBit.IORDY))
@@ -1378,7 +1377,7 @@ namespace Aaru.Decoders.ATA
if(ATAID.InterseekDelay != 0x0000 && if(ATAID.InterseekDelay != 0x0000 &&
ATAID.InterseekDelay != 0xFFFF) ATAID.InterseekDelay != 0xFFFF)
sb.AppendLine().AppendFormat("{0} microseconds of interseek delay for ISO-7779 accoustic testing", sb.AppendLine().AppendFormat("{0} microseconds of interseek delay for ISO-7779 acoustic testing",
ATAID.InterseekDelay); ATAID.InterseekDelay);
if((ushort)ATAID.DeviceFormFactor != 0x0000 && if((ushort)ATAID.DeviceFormFactor != 0x0000 &&
@@ -2080,7 +2079,7 @@ namespace Aaru.Decoders.ATA
sb.AppendLine(ATAID.SecurityStatus.HasFlag(CommonTypes. sb.AppendLine(ATAID.SecurityStatus.HasFlag(CommonTypes.
Structs.Devices.ATA.Identify.SecurityStatusBit.Expired) Structs.Devices.ATA.Identify.SecurityStatusBit.Expired)
? "Security count has expired" : "Security count has notexpired"); ? "Security count has expired" : "Security count has not expired");
sb.AppendLine(ATAID.SecurityStatus.HasFlag(CommonTypes. sb.AppendLine(ATAID.SecurityStatus.HasFlag(CommonTypes.
Structs.Devices.ATA.Identify.SecurityStatusBit.Maximum) Structs.Devices.ATA.Identify.SecurityStatusBit.Maximum)
@@ -2156,7 +2155,7 @@ namespace Aaru.Decoders.ATA
sb.AppendLine().AppendFormat("Version {0}", (ATAID.NVCacheCaps & 0x0F00) >> 8).AppendLine(); sb.AppendLine().AppendFormat("Version {0}", (ATAID.NVCacheCaps & 0x0F00) >> 8).AppendLine();
} }
sb.AppendLine().AppendFormat("Non-Volatile Cache is {0} bytes", ATAID.NVCacheSize * logicalsectorsize). sb.AppendLine().AppendFormat("Non-Volatile Cache is {0} bytes", ATAID.NVCacheSize * logicalSectorSize).
AppendLine(); AppendLine();
} }

View File

@@ -215,10 +215,7 @@ namespace Aaru.Decoders.MMC
{ {
public static ExtendedCSD DecodeExtendedCSD(byte[] response) public static ExtendedCSD DecodeExtendedCSD(byte[] response)
{ {
if(response == null) if(response?.Length != 512)
return null;
if(response.Length != 512)
return null; return null;
var handle = GCHandle.Alloc(response, GCHandleType.Pinned); var handle = GCHandle.Alloc(response, GCHandleType.Pinned);

View File

@@ -122,17 +122,12 @@ namespace Aaru.Decoders.SCSI.MMC
public static string Prettify000b(StandardDiscInformation? information) public static string Prettify000b(StandardDiscInformation? information)
{ {
if(!information.HasValue) if(information?.DataType != 0)
return null;
StandardDiscInformation decoded = information.Value;
if(decoded.DataType != 0)
return null; return null;
var sb = new StringBuilder(); var sb = new StringBuilder();
switch(decoded.DiscType) switch(information.Value.DiscType)
{ {
case 0x00: case 0x00:
sb.AppendLine("Disc type declared as CD-DA or CD-ROM"); sb.AppendLine("Disc type declared as CD-DA or CD-ROM");
@@ -151,12 +146,12 @@ namespace Aaru.Decoders.SCSI.MMC
break; break;
default: default:
sb.AppendFormat("Unknown disc type {0:X2}h", decoded.DiscType).AppendLine(); sb.AppendFormat("Unknown disc type {0:X2}h", information.Value.DiscType).AppendLine();
break; break;
} }
switch(decoded.DiscStatus) switch(information.Value.DiscStatus)
{ {
case 0: case 0:
sb.AppendLine("Disc is empty"); sb.AppendLine("Disc is empty");
@@ -172,10 +167,10 @@ namespace Aaru.Decoders.SCSI.MMC
break; break;
} }
if(decoded.Erasable) if(information.Value.Erasable)
sb.AppendLine("Disc is erasable"); sb.AppendLine("Disc is erasable");
switch(decoded.LastSessionStatus) switch(information.Value.LastSessionStatus)
{ {
case 0: case 0:
sb.AppendLine("Last session is empty"); sb.AppendLine("Last session is empty");
@@ -195,7 +190,7 @@ namespace Aaru.Decoders.SCSI.MMC
break; break;
} }
switch(decoded.BGFormatStatus) switch(information.Value.BGFormatStatus)
{ {
case 1: case 1:
sb.AppendLine("Media was being formatted in the background but it is stopped and incomplete"); sb.AppendLine("Media was being formatted in the background but it is stopped and incomplete");
@@ -211,39 +206,39 @@ namespace Aaru.Decoders.SCSI.MMC
break; break;
} }
if(decoded.Dbit) if(information.Value.Dbit)
sb.AppendLine("MRW is dirty"); sb.AppendLine("MRW is dirty");
sb.AppendFormat("First track on disc is track {0}", decoded.FirstTrackNumber).AppendLine(); sb.AppendFormat("First track on disc is track {0}", information.Value.FirstTrackNumber).AppendLine();
sb.AppendFormat("Disc has {0} sessions", decoded.Sessions).AppendLine(); sb.AppendFormat("Disc has {0} sessions", information.Value.Sessions).AppendLine();
sb.AppendFormat("First track in last session is track {0}", decoded.FirstTrackLastSession).AppendLine(); sb.AppendFormat("First track in last session is track {0}", information.Value.FirstTrackLastSession).AppendLine();
sb.AppendFormat("Last track in last session is track {0}", decoded.LastTrackLastSession).AppendLine(); sb.AppendFormat("Last track in last session is track {0}", information.Value.LastTrackLastSession).AppendLine();
sb.AppendFormat("Last session Lead-In address is {0} (as LBA) or {1:X2}:{2:X2}:{3:X2}", sb.AppendFormat("Last session Lead-In address is {0} (as LBA) or {1:X2}:{2:X2}:{3:X2}",
decoded.LastSessionLeadInStartLBA, (decoded.LastSessionLeadInStartLBA & 0xFF0000) >> 16, information.Value.LastSessionLeadInStartLBA, (information.Value.LastSessionLeadInStartLBA & 0xFF0000) >> 16,
(decoded.LastSessionLeadInStartLBA & 0xFF00) >> 8, (information.Value.LastSessionLeadInStartLBA & 0xFF00) >> 8,
decoded.LastSessionLeadInStartLBA & 0xFF).AppendLine(); information.Value.LastSessionLeadInStartLBA & 0xFF).AppendLine();
sb.AppendFormat("Last possible Lead-Out address is {0} (as LBA) or {1:X2}:{2:X2}:{3:X2}", sb.AppendFormat("Last possible Lead-Out address is {0} (as LBA) or {1:X2}:{2:X2}:{3:X2}",
decoded.LastPossibleLeadOutStartLBA, (decoded.LastPossibleLeadOutStartLBA & 0xFF0000) >> 16, information.Value.LastPossibleLeadOutStartLBA, (information.Value.LastPossibleLeadOutStartLBA & 0xFF0000) >> 16,
(decoded.LastPossibleLeadOutStartLBA & 0xFF00) >> 8, (information.Value.LastPossibleLeadOutStartLBA & 0xFF00) >> 8,
decoded.LastPossibleLeadOutStartLBA & 0xFF).AppendLine(); information.Value.LastPossibleLeadOutStartLBA & 0xFF).AppendLine();
sb.AppendLine(decoded.URU ? "Disc is defined for unrestricted use" : "Disc is defined for restricted use"); sb.AppendLine(information.Value.URU ? "Disc is defined for unrestricted use" : "Disc is defined for restricted use");
if(decoded.DID_V) if(information.Value.DID_V)
sb.AppendFormat("Disc ID: {0:X6}", decoded.DiscIdentification & 0x00FFFFFF).AppendLine(); sb.AppendFormat("Disc ID: {0:X6}", information.Value.DiscIdentification & 0x00FFFFFF).AppendLine();
if(decoded.DBC_V) if(information.Value.DBC_V)
sb.AppendFormat("Disc barcode: {0:X16}", decoded.DiscBarcode).AppendLine(); sb.AppendFormat("Disc barcode: {0:X16}", information.Value.DiscBarcode).AppendLine();
if(decoded.DAC_V) if(information.Value.DAC_V)
sb.AppendFormat("Disc application code: {0}", decoded.DiscApplicationCode).AppendLine(); sb.AppendFormat("Disc application code: {0}", information.Value.DiscApplicationCode).AppendLine();
if(decoded.OPCTables == null) if(information.Value.OPCTables == null)
return sb.ToString(); return sb.ToString();
foreach(OPCTable table in decoded.OPCTables) foreach(OPCTable table in information.Value.OPCTables)
sb.AppendFormat("OPC values for {0}Kbit/sec.: {1}, {2}, {3}, {4}, {5}, {6}", table.Speed, sb.AppendFormat("OPC values for {0}Kbit/sec.: {1}, {2}, {3}, {4}, {5}, {6}", table.Speed,
table.OPCValues[0], table.OPCValues[1], table.OPCValues[2], table.OPCValues[3], table.OPCValues[0], table.OPCValues[1], table.OPCValues[2], table.OPCValues[3],
table.OPCValues[4], table.OPCValues[5]).AppendLine(); table.OPCValues[4], table.OPCValues[5]).AppendLine();
@@ -278,23 +273,18 @@ namespace Aaru.Decoders.SCSI.MMC
public static string Prettify001b(TrackResourcesInformation? information) public static string Prettify001b(TrackResourcesInformation? information)
{ {
if(!information.HasValue) if(information?.DataType != 1)
return null;
TrackResourcesInformation decoded = information.Value;
if(decoded.DataType != 1)
return null; return null;
var sb = new StringBuilder(); var sb = new StringBuilder();
sb.AppendFormat("{0} maximum possible tracks on the disc", decoded.MaxTracks).AppendLine(); sb.AppendFormat("{0} maximum possible tracks on the disc", information.Value.MaxTracks).AppendLine();
sb.AppendFormat("{0} assigned tracks on the disc", decoded.AssignedTracks).AppendLine(); sb.AppendFormat("{0} assigned tracks on the disc", information.Value.AssignedTracks).AppendLine();
sb.AppendFormat("{0} maximum possible appendable tracks on the disc", decoded.AppendableTracks). sb.AppendFormat("{0} maximum possible appendable tracks on the disc", information.Value.AppendableTracks).
AppendLine(); AppendLine();
sb.AppendFormat("{0} current appendable tracks on the disc", decoded.MaxAppendableTracks).AppendLine(); sb.AppendFormat("{0} current appendable tracks on the disc", information.Value.MaxAppendableTracks).AppendLine();
return sb.ToString(); return sb.ToString();
} }
@@ -331,22 +321,17 @@ namespace Aaru.Decoders.SCSI.MMC
public static string Prettify010b(POWResourcesInformation? information) public static string Prettify010b(POWResourcesInformation? information)
{ {
if(!information.HasValue) if(information?.DataType != 1)
return null;
POWResourcesInformation decoded = information.Value;
if(decoded.DataType != 1)
return null; return null;
var sb = new StringBuilder(); var sb = new StringBuilder();
sb.AppendFormat("{0} remaining POW replacements", decoded.RemainingPOWReplacements).AppendLine(); sb.AppendFormat("{0} remaining POW replacements", information.Value.RemainingPOWReplacements).AppendLine();
sb.AppendFormat("{0} remaining POW reallocation map entries", decoded.RemainingPOWReallocation). sb.AppendFormat("{0} remaining POW reallocation map entries", information.Value.RemainingPOWReallocation).
AppendLine(); AppendLine();
sb.AppendFormat("{0} remaining POW updates", decoded.RemainingPOWUpdates).AppendLine(); sb.AppendFormat("{0} remaining POW updates", information.Value.RemainingPOWUpdates).AppendLine();
return sb.ToString(); return sb.ToString();
} }