mirror of
https://github.com/aaru-dps/Aaru.Server.git
synced 2025-12-16 19:24:27 +00:00
REFACTOR: Convert 'if' statement to 'switch' statement.
This commit is contained in:
@@ -45,29 +45,29 @@ namespace DiscImageChef.Core.Devices.Report
|
||||
Tuple[] tuples = CIS.GetTuples(dev.Cis);
|
||||
if(tuples != null)
|
||||
foreach(Tuple tuple in tuples)
|
||||
if(tuple.Code == TupleCodes.CISTPL_MANFID)
|
||||
{
|
||||
ManufacturerIdentificationTuple manfid = CIS.DecodeManufacturerIdentificationTuple(tuple);
|
||||
switch(tuple.Code) {
|
||||
case TupleCodes.CISTPL_MANFID:
|
||||
ManufacturerIdentificationTuple manfid = CIS.DecodeManufacturerIdentificationTuple(tuple);
|
||||
|
||||
if(manfid != null)
|
||||
{
|
||||
report.PCMCIA.ManufacturerCode = manfid.ManufacturerID;
|
||||
report.PCMCIA.CardCode = manfid.CardID;
|
||||
report.PCMCIA.ManufacturerCodeSpecified = true;
|
||||
report.PCMCIA.CardCodeSpecified = true;
|
||||
}
|
||||
}
|
||||
else if(tuple.Code == TupleCodes.CISTPL_VERS_1)
|
||||
{
|
||||
Level1VersionTuple vers = CIS.DecodeLevel1VersionTuple(tuple);
|
||||
if(manfid != null)
|
||||
{
|
||||
report.PCMCIA.ManufacturerCode = manfid.ManufacturerID;
|
||||
report.PCMCIA.CardCode = manfid.CardID;
|
||||
report.PCMCIA.ManufacturerCodeSpecified = true;
|
||||
report.PCMCIA.CardCodeSpecified = true;
|
||||
}
|
||||
break;
|
||||
case TupleCodes.CISTPL_VERS_1:
|
||||
Level1VersionTuple vers = CIS.DecodeLevel1VersionTuple(tuple);
|
||||
|
||||
if(vers != null)
|
||||
{
|
||||
report.PCMCIA.Manufacturer = vers.Manufacturer;
|
||||
report.PCMCIA.ProductName = vers.Product;
|
||||
report.PCMCIA.Compliance = string.Format("{0}.{1}", vers.MajorVersion, vers.MinorVersion);
|
||||
report.PCMCIA.AdditionalInformation = vers.AdditionalInformation;
|
||||
}
|
||||
if(vers != null)
|
||||
{
|
||||
report.PCMCIA.Manufacturer = vers.Manufacturer;
|
||||
report.PCMCIA.ProductName = vers.Product;
|
||||
report.PCMCIA.Compliance = string.Format("{0}.{1}", vers.MajorVersion, vers.MinorVersion);
|
||||
report.PCMCIA.AdditionalInformation = vers.AdditionalInformation;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -959,68 +959,67 @@ namespace DiscImageChef.Core.Devices.Report.SCSI
|
||||
mediaType + ".bin", "read results", buffer);
|
||||
}
|
||||
|
||||
if(mediaType == "DVD-ROM" || mediaType == "HD DVD-ROM")
|
||||
{
|
||||
mediaTest.CanReadBCASpecified = true;
|
||||
DicConsole.WriteLine("Querying DVD BCA...");
|
||||
mediaTest.CanReadBCA =
|
||||
!dev.ReadDiscStructure(out buffer, out senseBuffer, MmcDiscStructureMediaType.Dvd, 0, 0,
|
||||
MmcDiscStructureFormat.BurstCuttingArea, 0, timeout,
|
||||
out duration);
|
||||
DicConsole.DebugWriteLine("SCSI Report", "Sense = {0}", !mediaTest.CanReadBCA);
|
||||
if(debug)
|
||||
DataFile.WriteTo("SCSI Report", "bca",
|
||||
"_debug_" + report.SCSI.Inquiry.ProductIdentification + "_" +
|
||||
mediaType + ".bin", "read results", buffer);
|
||||
mediaTest.CanReadAACSSpecified = true;
|
||||
DicConsole.WriteLine("Querying DVD AACS...");
|
||||
mediaTest.CanReadAACS =
|
||||
!dev.ReadDiscStructure(out buffer, out senseBuffer, MmcDiscStructureMediaType.Dvd, 0, 0,
|
||||
MmcDiscStructureFormat.DvdAacs, 0, timeout, out duration);
|
||||
DicConsole.DebugWriteLine("SCSI Report", "Sense = {0}", !mediaTest.CanReadAACS);
|
||||
if(debug)
|
||||
DataFile.WriteTo("SCSI Report", "aacs",
|
||||
"_debug_" + report.SCSI.Inquiry.ProductIdentification + "_" +
|
||||
mediaType + ".bin", "read results", buffer);
|
||||
}
|
||||
|
||||
if(mediaType == "BD-ROM")
|
||||
{
|
||||
mediaTest.CanReadBCASpecified = true;
|
||||
DicConsole.WriteLine("Querying BD BCA...");
|
||||
mediaTest.CanReadBCA =
|
||||
!dev.ReadDiscStructure(out buffer, out senseBuffer, MmcDiscStructureMediaType.Bd, 0, 0,
|
||||
MmcDiscStructureFormat.BdBurstCuttingArea, 0, timeout,
|
||||
out duration);
|
||||
DicConsole.DebugWriteLine("SCSI Report", "Sense = {0}", !mediaTest.CanReadBCA);
|
||||
if(debug)
|
||||
DataFile.WriteTo("SCSI Report", "bdbca",
|
||||
"_debug_" + report.SCSI.Inquiry.ProductIdentification + "_" +
|
||||
mediaType + ".bin", "read results", buffer);
|
||||
}
|
||||
|
||||
if(mediaType == "DVD-RAM" || mediaType == "HD DVD-RAM")
|
||||
{
|
||||
mediaTest.CanReadDDSSpecified = true;
|
||||
mediaTest.CanReadSpareAreaInformationSpecified = true;
|
||||
mediaTest.CanReadDDS =
|
||||
!dev.ReadDiscStructure(out buffer, out senseBuffer, MmcDiscStructureMediaType.Dvd, 0, 0,
|
||||
MmcDiscStructureFormat.DvdramDds, 0, timeout, out duration);
|
||||
DicConsole.DebugWriteLine("SCSI Report", "Sense = {0}", !mediaTest.CanReadDDS);
|
||||
if(debug)
|
||||
DataFile.WriteTo("SCSI Report", "dds",
|
||||
"_debug_" + report.SCSI.Inquiry.ProductIdentification + "_" +
|
||||
mediaType + ".bin", "read results", buffer);
|
||||
mediaTest.CanReadSpareAreaInformation =
|
||||
!dev.ReadDiscStructure(out buffer, out senseBuffer, MmcDiscStructureMediaType.Dvd, 0, 0,
|
||||
MmcDiscStructureFormat.DvdramSpareAreaInformation, 0, timeout,
|
||||
out duration);
|
||||
DicConsole.DebugWriteLine("SCSI Report", "Sense = {0}",
|
||||
!mediaTest.CanReadSpareAreaInformation);
|
||||
if(debug)
|
||||
DataFile.WriteTo("SCSI Report", "sai",
|
||||
"_debug_" + report.SCSI.Inquiry.ProductIdentification + "_" +
|
||||
mediaType + ".bin", "read results", buffer);
|
||||
switch(mediaType) {
|
||||
case "DVD-ROM":
|
||||
case "HD DVD-ROM":
|
||||
mediaTest.CanReadBCASpecified = true;
|
||||
DicConsole.WriteLine("Querying DVD BCA...");
|
||||
mediaTest.CanReadBCA =
|
||||
!dev.ReadDiscStructure(out buffer, out senseBuffer, MmcDiscStructureMediaType.Dvd, 0, 0,
|
||||
MmcDiscStructureFormat.BurstCuttingArea, 0, timeout,
|
||||
out duration);
|
||||
DicConsole.DebugWriteLine("SCSI Report", "Sense = {0}", !mediaTest.CanReadBCA);
|
||||
if(debug)
|
||||
DataFile.WriteTo("SCSI Report", "bca",
|
||||
"_debug_" + report.SCSI.Inquiry.ProductIdentification + "_" +
|
||||
mediaType + ".bin", "read results", buffer);
|
||||
mediaTest.CanReadAACSSpecified = true;
|
||||
DicConsole.WriteLine("Querying DVD AACS...");
|
||||
mediaTest.CanReadAACS =
|
||||
!dev.ReadDiscStructure(out buffer, out senseBuffer, MmcDiscStructureMediaType.Dvd, 0, 0,
|
||||
MmcDiscStructureFormat.DvdAacs, 0, timeout, out duration);
|
||||
DicConsole.DebugWriteLine("SCSI Report", "Sense = {0}", !mediaTest.CanReadAACS);
|
||||
if(debug)
|
||||
DataFile.WriteTo("SCSI Report", "aacs",
|
||||
"_debug_" + report.SCSI.Inquiry.ProductIdentification + "_" +
|
||||
mediaType + ".bin", "read results", buffer);
|
||||
break;
|
||||
case "BD-ROM":
|
||||
mediaTest.CanReadBCASpecified = true;
|
||||
DicConsole.WriteLine("Querying BD BCA...");
|
||||
mediaTest.CanReadBCA =
|
||||
!dev.ReadDiscStructure(out buffer, out senseBuffer, MmcDiscStructureMediaType.Bd, 0, 0,
|
||||
MmcDiscStructureFormat.BdBurstCuttingArea, 0, timeout,
|
||||
out duration);
|
||||
DicConsole.DebugWriteLine("SCSI Report", "Sense = {0}", !mediaTest.CanReadBCA);
|
||||
if(debug)
|
||||
DataFile.WriteTo("SCSI Report", "bdbca",
|
||||
"_debug_" + report.SCSI.Inquiry.ProductIdentification + "_" +
|
||||
mediaType + ".bin", "read results", buffer);
|
||||
break;
|
||||
case "DVD-RAM":
|
||||
case "HD DVD-RAM":
|
||||
mediaTest.CanReadDDSSpecified = true;
|
||||
mediaTest.CanReadSpareAreaInformationSpecified = true;
|
||||
mediaTest.CanReadDDS =
|
||||
!dev.ReadDiscStructure(out buffer, out senseBuffer, MmcDiscStructureMediaType.Dvd, 0, 0,
|
||||
MmcDiscStructureFormat.DvdramDds, 0, timeout, out duration);
|
||||
DicConsole.DebugWriteLine("SCSI Report", "Sense = {0}", !mediaTest.CanReadDDS);
|
||||
if(debug)
|
||||
DataFile.WriteTo("SCSI Report", "dds",
|
||||
"_debug_" + report.SCSI.Inquiry.ProductIdentification + "_" +
|
||||
mediaType + ".bin", "read results", buffer);
|
||||
mediaTest.CanReadSpareAreaInformation =
|
||||
!dev.ReadDiscStructure(out buffer, out senseBuffer, MmcDiscStructureMediaType.Dvd, 0, 0,
|
||||
MmcDiscStructureFormat.DvdramSpareAreaInformation, 0, timeout,
|
||||
out duration);
|
||||
DicConsole.DebugWriteLine("SCSI Report", "Sense = {0}",
|
||||
!mediaTest.CanReadSpareAreaInformation);
|
||||
if(debug)
|
||||
DataFile.WriteTo("SCSI Report", "sai",
|
||||
"_debug_" + report.SCSI.Inquiry.ProductIdentification + "_" +
|
||||
mediaType + ".bin", "read results", buffer);
|
||||
break;
|
||||
}
|
||||
|
||||
if(mediaType.StartsWith("BD-R", StringComparison.Ordinal) && mediaType != "BD-ROM")
|
||||
|
||||
@@ -42,8 +42,12 @@ namespace DiscImageChef.Core.Devices.Report
|
||||
{
|
||||
if(report == null) return;
|
||||
|
||||
if(dev.Type == DeviceType.MMC) report.MultiMediaCard = new mmcsdType();
|
||||
else if(dev.Type == DeviceType.SecureDigital) report.SecureDigital = new mmcsdType();
|
||||
switch(dev.Type) {
|
||||
case DeviceType.MMC: report.MultiMediaCard = new mmcsdType();
|
||||
break;
|
||||
case DeviceType.SecureDigital: report.SecureDigital = new mmcsdType();
|
||||
break;
|
||||
}
|
||||
|
||||
DicConsole.WriteLine("Trying to get CID...");
|
||||
bool sense = dev.ReadCid(out byte[] cid, out uint[] response, dev.Timeout, out double duration);
|
||||
@@ -52,26 +56,26 @@ namespace DiscImageChef.Core.Devices.Report
|
||||
{
|
||||
DicConsole.WriteLine("CID obtained correctly...");
|
||||
|
||||
if(dev.Type == DeviceType.SecureDigital)
|
||||
{
|
||||
// Clear serial number and manufacturing date
|
||||
cid[9] = 0;
|
||||
cid[10] = 0;
|
||||
cid[11] = 0;
|
||||
cid[12] = 0;
|
||||
cid[13] = 0;
|
||||
cid[14] = 0;
|
||||
report.SecureDigital.CID = cid;
|
||||
}
|
||||
else if(dev.Type == DeviceType.MMC)
|
||||
{
|
||||
// Clear serial number and manufacturing date
|
||||
cid[10] = 0;
|
||||
cid[11] = 0;
|
||||
cid[12] = 0;
|
||||
cid[13] = 0;
|
||||
cid[14] = 0;
|
||||
report.MultiMediaCard.CID = cid;
|
||||
switch(dev.Type) {
|
||||
case DeviceType.SecureDigital:
|
||||
// Clear serial number and manufacturing date
|
||||
cid[9] = 0;
|
||||
cid[10] = 0;
|
||||
cid[11] = 0;
|
||||
cid[12] = 0;
|
||||
cid[13] = 0;
|
||||
cid[14] = 0;
|
||||
report.SecureDigital.CID = cid;
|
||||
break;
|
||||
case DeviceType.MMC:
|
||||
// Clear serial number and manufacturing date
|
||||
cid[10] = 0;
|
||||
cid[11] = 0;
|
||||
cid[12] = 0;
|
||||
cid[13] = 0;
|
||||
cid[14] = 0;
|
||||
report.MultiMediaCard.CID = cid;
|
||||
break;
|
||||
}
|
||||
}
|
||||
else DicConsole.WriteLine("Could not read CID...");
|
||||
@@ -83,54 +87,62 @@ namespace DiscImageChef.Core.Devices.Report
|
||||
{
|
||||
DicConsole.WriteLine("CSD obtained correctly...");
|
||||
|
||||
if(dev.Type == DeviceType.MMC) report.MultiMediaCard.CSD = csd;
|
||||
else if(dev.Type == DeviceType.SecureDigital) report.SecureDigital.CSD = csd;
|
||||
switch(dev.Type) {
|
||||
case DeviceType.MMC: report.MultiMediaCard.CSD = csd;
|
||||
break;
|
||||
case DeviceType.SecureDigital: report.SecureDigital.CSD = csd;
|
||||
break;
|
||||
}
|
||||
}
|
||||
else DicConsole.WriteLine("Could not read CSD...");
|
||||
|
||||
if(dev.Type == DeviceType.MMC)
|
||||
{
|
||||
DicConsole.WriteLine("Trying to get OCR...");
|
||||
sense = dev.ReadOcr(out byte[] ocr, out response, dev.Timeout, out duration);
|
||||
|
||||
if(!sense)
|
||||
switch(dev.Type) {
|
||||
case DeviceType.MMC:
|
||||
{
|
||||
DicConsole.WriteLine("OCR obtained correctly...");
|
||||
report.MultiMediaCard.OCR = ocr;
|
||||
DicConsole.WriteLine("Trying to get OCR...");
|
||||
sense = dev.ReadOcr(out byte[] ocr, out response, dev.Timeout, out duration);
|
||||
|
||||
if(!sense)
|
||||
{
|
||||
DicConsole.WriteLine("OCR obtained correctly...");
|
||||
report.MultiMediaCard.OCR = ocr;
|
||||
}
|
||||
else DicConsole.WriteLine("Could not read OCR...");
|
||||
|
||||
DicConsole.WriteLine("Trying to get Extended CSD...");
|
||||
sense = dev.ReadExtendedCsd(out byte[] ecsd, out response, dev.Timeout, out duration);
|
||||
|
||||
if(!sense)
|
||||
{
|
||||
DicConsole.WriteLine("Extended CSD obtained correctly...");
|
||||
report.MultiMediaCard.ExtendedCSD = ecsd;
|
||||
}
|
||||
else DicConsole.WriteLine("Could not read Extended CSD...");
|
||||
break;
|
||||
}
|
||||
else DicConsole.WriteLine("Could not read OCR...");
|
||||
|
||||
DicConsole.WriteLine("Trying to get Extended CSD...");
|
||||
sense = dev.ReadExtendedCsd(out byte[] ecsd, out response, dev.Timeout, out duration);
|
||||
|
||||
if(!sense)
|
||||
case DeviceType.SecureDigital:
|
||||
{
|
||||
DicConsole.WriteLine("Extended CSD obtained correctly...");
|
||||
report.MultiMediaCard.ExtendedCSD = ecsd;
|
||||
}
|
||||
else DicConsole.WriteLine("Could not read Extended CSD...");
|
||||
}
|
||||
else if(dev.Type == DeviceType.SecureDigital)
|
||||
{
|
||||
DicConsole.WriteLine("Trying to get OCR...");
|
||||
sense = dev.ReadSdocr(out byte[] ocr, out response, dev.Timeout, out duration);
|
||||
DicConsole.WriteLine("Trying to get OCR...");
|
||||
sense = dev.ReadSdocr(out byte[] ocr, out response, dev.Timeout, out duration);
|
||||
|
||||
if(!sense)
|
||||
{
|
||||
DicConsole.WriteLine("OCR obtained correctly...");
|
||||
report.SecureDigital.OCR = ocr;
|
||||
}
|
||||
else DicConsole.WriteLine("Could not read OCR...");
|
||||
if(!sense)
|
||||
{
|
||||
DicConsole.WriteLine("OCR obtained correctly...");
|
||||
report.SecureDigital.OCR = ocr;
|
||||
}
|
||||
else DicConsole.WriteLine("Could not read OCR...");
|
||||
|
||||
DicConsole.WriteLine("Trying to get SCR...");
|
||||
sense = dev.ReadScr(out byte[] scr, out response, dev.Timeout, out duration);
|
||||
DicConsole.WriteLine("Trying to get SCR...");
|
||||
sense = dev.ReadScr(out byte[] scr, out response, dev.Timeout, out duration);
|
||||
|
||||
if(!sense)
|
||||
{
|
||||
DicConsole.WriteLine("SCR obtained correctly...");
|
||||
report.SecureDigital.SCR = scr;
|
||||
if(!sense)
|
||||
{
|
||||
DicConsole.WriteLine("SCR obtained correctly...");
|
||||
report.SecureDigital.SCR = scr;
|
||||
}
|
||||
else DicConsole.WriteLine("Could not read SCR...");
|
||||
break;
|
||||
}
|
||||
else DicConsole.WriteLine("Could not read SCR...");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user