From e9443388ee99c501f8e7c3ef7fa3326c81012c33 Mon Sep 17 00:00:00 2001 From: Natalia Portillo Date: Wed, 20 Dec 2017 23:07:46 +0000 Subject: [PATCH] REFACTOR: Use preferred braces style. --- DiscImageChef.Checksums/Adler32Context.cs | 9 +- DiscImageChef.Checksums/CDChecksums.cs | 27 +- DiscImageChef.Checksums/CRC16Context.cs | 9 +- DiscImageChef.Checksums/CRC32Context.cs | 9 +- DiscImageChef.Checksums/CRC64Context.cs | 9 +- DiscImageChef.Checksums/MD5Context.cs | 6 +- DiscImageChef.Checksums/RIPEMD160Context.cs | 9 +- DiscImageChef.Checksums/ReedSolomon.cs | 52 +-- DiscImageChef.Checksums/SHA1Context.cs | 9 +- DiscImageChef.Checksums/SHA256Context.cs | 6 +- DiscImageChef.Checksums/SHA384Context.cs | 9 +- DiscImageChef.Checksums/SHA512Context.cs | 9 +- DiscImageChef.Checksums/SpamSumContext.cs | 9 +- .../MediaTypeFromSCSI.cs | 8 +- .../Devices/Dumping/Alcohol120.cs | 6 +- .../Devices/Dumping/CompactDisc.cs | 36 +- DiscImageChef.Core/Devices/Dumping/SBC.cs | 25 +- DiscImageChef.Core/Devices/Dumping/XGD.cs | 10 +- DiscImageChef.Core/Devices/ReaderSCSI.cs | 24 ++ DiscImageChef.Core/Devices/Report/ATA.cs | 58 +++ .../Devices/Report/SCSI/General.cs | 30 +- DiscImageChef.Core/Devices/Report/SCSI/MMC.cs | 183 ++++++++- DiscImageChef.Core/Devices/Report/SCSI/SSC.cs | 4 + DiscImageChef.Core/Devices/Scanning/ATA.cs | 28 +- DiscImageChef.Core/Devices/Scanning/SCSI.cs | 14 +- .../Devices/Scanning/SecureDigital.cs | 12 +- DiscImageChef.Core/Filesystems.cs | 5 +- DiscImageChef.Core/ImageFormat.cs | 2 +- DiscImageChef.Core/Partitions.cs | 7 +- DiscImageChef.Core/PluginBase.cs | 14 +- DiscImageChef.Core/Sidecar/BlockMedia.cs | 17 +- DiscImageChef.Core/Sidecar/OpticalDisc.cs | 24 +- DiscImageChef.Decoders/ATA/Identify.cs | 297 +++------------ DiscImageChef.Decoders/CD/Sector.cs | 2 +- DiscImageChef.Decoders/DVD/PFI.cs | 14 +- DiscImageChef.Decoders/MMC/CSD.cs | 7 +- DiscImageChef.Decoders/PCMCIA/CIS.cs | 5 +- DiscImageChef.Decoders/SCSI/Inquiry.cs | 13 +- DiscImageChef.Decoders/SCSI/MMC/Features.cs | 13 +- DiscImageChef.Decoders/SCSI/MMC/Hybrid.cs | 7 +- DiscImageChef.Decoders/SCSI/ModesEncoders.cs | 12 +- DiscImageChef.Decoders/SecureDigital/CSD.cs | 7 +- DiscImageChef.Decoders/Xbox/DMI.cs | 4 +- DiscImageChef.Devices/Device/Constructor.cs | 15 +- .../Device/ScsiCommands/SyQuest.cs | 4 +- DiscImageChef.Devices/Windows/Command.cs | 2 +- DiscImageChef.Devices/Windows/ListDevices.cs | 12 +- DiscImageChef.Devices/Windows/Usb.cs | 29 +- DiscImageChef.Devices/Windows/UsbFunctions.cs | 39 +- DiscImageChef.DiscImages/Alcohol120.cs | 43 +-- DiscImageChef.DiscImages/AppleNIB.cs | 9 +- DiscImageChef.DiscImages/Apridisk.cs | 5 +- DiscImageChef.DiscImages/BLU.cs | 4 +- DiscImageChef.DiscImages/BlindWrite4.cs | 51 +-- DiscImageChef.DiscImages/BlindWrite5.cs | 79 +--- DiscImageChef.DiscImages/CDRDAO.cs | 46 +-- DiscImageChef.DiscImages/CDRWin.cs | 80 +--- DiscImageChef.DiscImages/CHD.cs | 31 +- DiscImageChef.DiscImages/CloneCD.cs | 80 +--- DiscImageChef.DiscImages/DiscJuggler.cs | 40 +- DiscImageChef.DiscImages/DiskCopy42.cs | 4 +- DiscImageChef.DiscImages/GDI.cs | 50 +-- DiscImageChef.DiscImages/HDCopy.cs | 29 +- DiscImageChef.DiscImages/IMD.cs | 2 +- DiscImageChef.DiscImages/NDIF.cs | 2 - DiscImageChef.DiscImages/Nero.cs | 40 +- DiscImageChef.DiscImages/PartClone.cs | 5 - DiscImageChef.DiscImages/Partimage.cs | 5 - DiscImageChef.DiscImages/QED.cs | 2 +- DiscImageChef.DiscImages/T98.cs | 4 +- DiscImageChef.DiscImages/TeleDisk.cs | 38 +- DiscImageChef.DiscImages/VHD.cs | 2 - DiscImageChef.DiscImages/VHDX.cs | 9 +- DiscImageChef.DiscImages/ZZZRawImage.cs | 8 +- DiscImageChef.Filesystems/Acorn.cs | 15 +- DiscImageChef.Filesystems/AppleDOS/File.cs | 5 +- DiscImageChef.Filesystems/AppleDOS/Xattr.cs | 5 +- DiscImageChef.Filesystems/AppleHFS.cs | 2 +- DiscImageChef.Filesystems/AppleHFSPlus.cs | 4 +- DiscImageChef.Filesystems/AppleMFS/Info.cs | 2 +- DiscImageChef.Filesystems/BFS.cs | 6 - DiscImageChef.Filesystems/CPM/Dir.cs | 24 +- DiscImageChef.Filesystems/CPM/Super.cs | 33 +- DiscImageChef.Filesystems/CPM/Xattr.cs | 10 +- DiscImageChef.Filesystems/FFS.cs | 17 +- DiscImageChef.Filesystems/HAMMER.cs | 2 +- DiscImageChef.Filesystems/ISO9660/Info.cs | 14 +- .../ISO9660/Structs/CDi.cs | 9 +- .../ISO9660/Structs/HighSierra.cs | 9 +- .../ISO9660/Structs/ISO.cs | 9 +- .../ISO9660/Structs/Joliet.cs | 15 +- DiscImageChef.Filesystems/LisaFS/File.cs | 28 +- DiscImageChef.Filesystems/LisaFS/Super.cs | 2 +- DiscImageChef.Filters/Filters.cs | 9 +- DiscImageChef.Helpers/ArrayFill.cs | 12 +- DiscImageChef.Helpers/DateHandlers.cs | 2 +- .../EndianAwareBinaryReader.cs | 6 +- DiscImageChef.Interop/DetectOS.cs | 5 +- DiscImageChef.Server/App_Start/Ata.cs | 352 ++---------------- .../Controllers/UploadReportController.cs | 5 +- .../Controllers/UploadStatsController.cs | 65 +--- DiscImageChef.Server/Statistics.aspx.cs | 6 +- DiscImageChef.Server/ViewReport.aspx.cs | 20 + DiscImageChef.Settings/Settings.cs | 65 +--- DiscImageChef.Tests.Devices/Main.cs | 2 + DiscImageChef/Commands/Analyze.cs | 2 + DiscImageChef/Commands/Checksum.cs | 2 + DiscImageChef/Commands/Compare.cs | 4 + DiscImageChef/Commands/CreateSidecar.cs | 7 +- DiscImageChef/Commands/Decode.cs | 2 + DiscImageChef/Commands/DeviceInfo.cs | 109 +++++- DiscImageChef/Commands/DeviceReport.cs | 7 +- DiscImageChef/Commands/DumpMedia.cs | 5 +- DiscImageChef/Commands/Entropy.cs | 4 + DiscImageChef/Commands/ExtractFiles.cs | 26 ++ DiscImageChef/Commands/Ls.cs | 26 +- DiscImageChef/Commands/MediaInfo.cs | 152 +++++++- DiscImageChef/Commands/MediaScan.cs | 7 +- DiscImageChef/Commands/Statistics.cs | 41 +- DiscImageChef/Commands/Verify.cs | 8 + 120 files changed, 1016 insertions(+), 1975 deletions(-) diff --git a/DiscImageChef.Checksums/Adler32Context.cs b/DiscImageChef.Checksums/Adler32Context.cs index 8a352aabc..9c7832587 100644 --- a/DiscImageChef.Checksums/Adler32Context.cs +++ b/DiscImageChef.Checksums/Adler32Context.cs @@ -92,10 +92,7 @@ namespace DiscImageChef.Checksums StringBuilder adlerOutput = new StringBuilder(); BigEndianBitConverter.IsLittleEndian = BitConverter.IsLittleEndian; - for(int i = 0; i < BigEndianBitConverter.GetBytes(finalSum).Length; i++) - { - adlerOutput.Append(BigEndianBitConverter.GetBytes(finalSum)[i].ToString("x2")); - } + for(int i = 0; i < BigEndianBitConverter.GetBytes(finalSum).Length; i++) adlerOutput.Append(BigEndianBitConverter.GetBytes(finalSum)[i].ToString("x2")); return adlerOutput.ToString(); } @@ -138,7 +135,7 @@ namespace DiscImageChef.Checksums StringBuilder adlerOutput = new StringBuilder(); - for(int i = 0; i < hash.Length; i++) { adlerOutput.Append(hash[i].ToString("x2")); } + for(int i = 0; i < hash.Length; i++) adlerOutput.Append(hash[i].ToString("x2")); fileStream.Close(); @@ -172,7 +169,7 @@ namespace DiscImageChef.Checksums StringBuilder adlerOutput = new StringBuilder(); - for(int i = 0; i < hash.Length; i++) { adlerOutput.Append(hash[i].ToString("x2")); } + for(int i = 0; i < hash.Length; i++) adlerOutput.Append(hash[i].ToString("x2")); return adlerOutput.ToString(); } diff --git a/DiscImageChef.Checksums/CDChecksums.cs b/DiscImageChef.Checksums/CDChecksums.cs index f01bc710e..842a9398e 100644 --- a/DiscImageChef.Checksums/CDChecksums.cs +++ b/DiscImageChef.Checksums/CDChecksums.cs @@ -99,17 +99,17 @@ namespace DiscImageChef.Checksums for(minor = 0; minor < minorCount; minor++) { byte temp; - if(index < 4) { temp = address[index]; } - else { temp = data[index - 4]; } + if(index < 4) temp = address[index]; + else temp = data[index - 4]; index += minorInc; - if(index >= size) { index -= size; } + if(index >= size) index -= size; eccA ^= temp; eccB ^= temp; eccA = eccFTable[eccA]; } eccA = eccBTable[eccFTable[eccA] ^ eccB]; - if(ecc[major] != eccA || ecc[major + majorCount] != (eccA ^ eccB)) { return false; } + if(ecc[major] != eccA || ecc[major + majorCount] != (eccA ^ eccB)) return false; } return true; @@ -132,7 +132,6 @@ namespace DiscImageChef.Checksums DicConsole.DebugWriteLine("CD checksums", "Mode 0 sector at address {0:X2}:{1:X2}:{2:X2}", channel[0x00C], channel[0x00D], channel[0x00E]); for(int i = 0x010; i < 0x930; i++) - { if(channel[i] != 0x00) { DicConsole.DebugWriteLine("CD checksums", @@ -140,7 +139,6 @@ namespace DiscImageChef.Checksums channel[0x00C], channel[0x00D], channel[0x00E]); return false; } - } return true; } @@ -211,11 +209,9 @@ namespace DiscImageChef.Checksums { if(channel[0x010] != channel[0x014] || channel[0x011] != channel[0x015] || channel[0x012] != channel[0x016] || channel[0x013] != channel[0x017]) - { DicConsole.DebugWriteLine("CD checksums", "Subheader copies differ in mode 2 form 2 sector at address: {0:X2}:{1:X2}:{2:X2}", channel[0x00C], channel[0x00D], channel[0x00E]); - } /* TODO: This is not working byte[] SectorForCheck = new byte[0x91C]; @@ -235,11 +231,9 @@ namespace DiscImageChef.Checksums { if(channel[0x010] != channel[0x014] || channel[0x011] != channel[0x015] || channel[0x012] != channel[0x016] || channel[0x013] != channel[0x017]) - { DicConsole.DebugWriteLine("CD checksums", "Subheader copies differ in mode 2 form 1 sector at address: {0:X2}:{1:X2}:{2:X2}", channel[0x00C], channel[0x00D], channel[0x00E]); - } byte[] address = new byte[4]; byte[] data = new byte[2060]; @@ -380,10 +374,10 @@ namespace DiscImageChef.Checksums } i = 0; - for(int j = 0; j < 24; j++) { cdSubRwPack1[j] = (byte)(subchannel[i++] & 0x3F); } - for(int j = 0; j < 24; j++) { cdSubRwPack2[j] = (byte)(subchannel[i++] & 0x3F); } - for(int j = 0; j < 24; j++) { cdSubRwPack3[j] = (byte)(subchannel[i++] & 0x3F); } - for(int j = 0; j < 24; j++) { cdSubRwPack4[j] = (byte)(subchannel[i++] & 0x3F); } + for(int j = 0; j < 24; j++) cdSubRwPack1[j] = (byte)(subchannel[i++] & 0x3F); + for(int j = 0; j < 24; j++) cdSubRwPack2[j] = (byte)(subchannel[i++] & 0x3F); + for(int j = 0; j < 24; j++) cdSubRwPack3[j] = (byte)(subchannel[i++] & 0x3F); + for(int j = 0; j < 24; j++) cdSubRwPack4[j] = (byte)(subchannel[i++] & 0x3F); switch(cdSubRwPack1[0]) { @@ -526,10 +520,7 @@ namespace DiscImageChef.Checksums static ushort CalculateCCITT_CRC16(byte[] buffer) { ushort crc16 = 0; - for(int i = 0; i < buffer.Length; i++) - { - crc16 = (ushort)(CcittCrc16Table[(crc16 >> 8) ^ buffer[i]] ^ (crc16 << 8)); - } + for(int i = 0; i < buffer.Length; i++) crc16 = (ushort)(CcittCrc16Table[(crc16 >> 8) ^ buffer[i]] ^ (crc16 << 8)); crc16 = (ushort)~crc16; diff --git a/DiscImageChef.Checksums/CRC16Context.cs b/DiscImageChef.Checksums/CRC16Context.cs index e5b007d69..ffe0d59cf 100644 --- a/DiscImageChef.Checksums/CRC16Context.cs +++ b/DiscImageChef.Checksums/CRC16Context.cs @@ -104,10 +104,7 @@ namespace DiscImageChef.Checksums StringBuilder crc16Output = new StringBuilder(); BigEndianBitConverter.IsLittleEndian = BitConverter.IsLittleEndian; - for(int i = 0; i < BigEndianBitConverter.GetBytes(hashInt).Length; i++) - { - crc16Output.Append(BigEndianBitConverter.GetBytes(hashInt)[i].ToString("x2")); - } + for(int i = 0; i < BigEndianBitConverter.GetBytes(hashInt).Length; i++) crc16Output.Append(BigEndianBitConverter.GetBytes(hashInt)[i].ToString("x2")); return crc16Output.ToString(); } @@ -155,7 +152,7 @@ namespace DiscImageChef.Checksums StringBuilder crc16Output = new StringBuilder(); - for(int i = 0; i < hash.Length; i++) { crc16Output.Append(hash[i].ToString("x2")); } + for(int i = 0; i < hash.Length; i++) crc16Output.Append(hash[i].ToString("x2")); fileStream.Close(); @@ -207,7 +204,7 @@ namespace DiscImageChef.Checksums StringBuilder crc16Output = new StringBuilder(); - for(int i = 0; i < hash.Length; i++) { crc16Output.Append(hash[i].ToString("x2")); } + for(int i = 0; i < hash.Length; i++) crc16Output.Append(hash[i].ToString("x2")); return crc16Output.ToString(); } diff --git a/DiscImageChef.Checksums/CRC32Context.cs b/DiscImageChef.Checksums/CRC32Context.cs index f6c88de29..7129f933d 100644 --- a/DiscImageChef.Checksums/CRC32Context.cs +++ b/DiscImageChef.Checksums/CRC32Context.cs @@ -104,10 +104,7 @@ namespace DiscImageChef.Checksums StringBuilder crc32Output = new StringBuilder(); BigEndianBitConverter.IsLittleEndian = BitConverter.IsLittleEndian; - for(int i = 0; i < BigEndianBitConverter.GetBytes(hashInt).Length; i++) - { - crc32Output.Append(BigEndianBitConverter.GetBytes(hashInt)[i].ToString("x2")); - } + for(int i = 0; i < BigEndianBitConverter.GetBytes(hashInt).Length; i++) crc32Output.Append(BigEndianBitConverter.GetBytes(hashInt)[i].ToString("x2")); return crc32Output.ToString(); } @@ -156,7 +153,7 @@ namespace DiscImageChef.Checksums StringBuilder crc32Output = new StringBuilder(); - for(int i = 0; i < hash.Length; i++) { crc32Output.Append(hash[i].ToString("x2")); } + for(int i = 0; i < hash.Length; i++) crc32Output.Append(hash[i].ToString("x2")); fileStream.Close(); @@ -208,7 +205,7 @@ namespace DiscImageChef.Checksums StringBuilder crc32Output = new StringBuilder(); - for(int i = 0; i < hash.Length; i++) { crc32Output.Append(hash[i].ToString("x2")); } + for(int i = 0; i < hash.Length; i++) crc32Output.Append(hash[i].ToString("x2")); return crc32Output.ToString(); } diff --git a/DiscImageChef.Checksums/CRC64Context.cs b/DiscImageChef.Checksums/CRC64Context.cs index c47a98251..8e6a1b888 100644 --- a/DiscImageChef.Checksums/CRC64Context.cs +++ b/DiscImageChef.Checksums/CRC64Context.cs @@ -103,10 +103,7 @@ namespace DiscImageChef.Checksums StringBuilder crc64Output = new StringBuilder(); BigEndianBitConverter.IsLittleEndian = BigEndianBitConverter.IsLittleEndian; - for(int i = 0; i < BigEndianBitConverter.GetBytes(hashInt).Length; i++) - { - crc64Output.Append(BigEndianBitConverter.GetBytes(hashInt)[i].ToString("x2")); - } + for(int i = 0; i < BigEndianBitConverter.GetBytes(hashInt).Length; i++) crc64Output.Append(BigEndianBitConverter.GetBytes(hashInt)[i].ToString("x2")); return crc64Output.ToString(); } @@ -155,7 +152,7 @@ namespace DiscImageChef.Checksums StringBuilder crc64Output = new StringBuilder(); - for(int i = 0; i < hash.Length; i++) { crc64Output.Append(hash[i].ToString("x2")); } + for(int i = 0; i < hash.Length; i++) crc64Output.Append(hash[i].ToString("x2")); fileStream.Close(); @@ -207,7 +204,7 @@ namespace DiscImageChef.Checksums StringBuilder crc64Output = new StringBuilder(); - for(int i = 0; i < hash.Length; i++) { crc64Output.Append(hash[i].ToString("x2")); } + for(int i = 0; i < hash.Length; i++) crc64Output.Append(hash[i].ToString("x2")); return crc64Output.ToString(); } diff --git a/DiscImageChef.Checksums/MD5Context.cs b/DiscImageChef.Checksums/MD5Context.cs index 0e49ea3f8..2cdf9e83f 100644 --- a/DiscImageChef.Checksums/MD5Context.cs +++ b/DiscImageChef.Checksums/MD5Context.cs @@ -87,7 +87,7 @@ namespace DiscImageChef.Checksums md5Provider.TransformFinalBlock(new byte[0], 0, 0); StringBuilder md5Output = new StringBuilder(); - for(int i = 0; i < md5Provider.Hash.Length; i++) { md5Output.Append(md5Provider.Hash[i].ToString("x2")); } + for(int i = 0; i < md5Provider.Hash.Length; i++) md5Output.Append(md5Provider.Hash[i].ToString("x2")); return md5Output.ToString(); } @@ -115,7 +115,7 @@ namespace DiscImageChef.Checksums hash = md5Provider.ComputeHash(fileStream); StringBuilder md5Output = new StringBuilder(); - for(int i = 0; i < hash.Length; i++) { md5Output.Append(hash[i].ToString("x2")); } + for(int i = 0; i < hash.Length; i++) md5Output.Append(hash[i].ToString("x2")); fileStream.Close(); @@ -133,7 +133,7 @@ namespace DiscImageChef.Checksums hash = md5Provider.ComputeHash(data, 0, (int)len); StringBuilder md5Output = new StringBuilder(); - for(int i = 0; i < hash.Length; i++) { md5Output.Append(hash[i].ToString("x2")); } + for(int i = 0; i < hash.Length; i++) md5Output.Append(hash[i].ToString("x2")); return md5Output.ToString(); } diff --git a/DiscImageChef.Checksums/RIPEMD160Context.cs b/DiscImageChef.Checksums/RIPEMD160Context.cs index b261ecd7f..dafb84074 100644 --- a/DiscImageChef.Checksums/RIPEMD160Context.cs +++ b/DiscImageChef.Checksums/RIPEMD160Context.cs @@ -87,10 +87,7 @@ namespace DiscImageChef.Checksums ripemd160Provider.TransformFinalBlock(new byte[0], 0, 0); StringBuilder ripemd160Output = new StringBuilder(); - for(int i = 0; i < ripemd160Provider.Hash.Length; i++) - { - ripemd160Output.Append(ripemd160Provider.Hash[i].ToString("x2")); - } + for(int i = 0; i < ripemd160Provider.Hash.Length; i++) ripemd160Output.Append(ripemd160Provider.Hash[i].ToString("x2")); return ripemd160Output.ToString(); } @@ -118,7 +115,7 @@ namespace DiscImageChef.Checksums hash = ripemd160Provider.ComputeHash(fileStream); StringBuilder ripemd160Output = new StringBuilder(); - for(int i = 0; i < hash.Length; i++) { ripemd160Output.Append(hash[i].ToString("x2")); } + for(int i = 0; i < hash.Length; i++) ripemd160Output.Append(hash[i].ToString("x2")); fileStream.Close(); @@ -136,7 +133,7 @@ namespace DiscImageChef.Checksums hash = ripemd160Provider.ComputeHash(data, 0, (int)len); StringBuilder ripemd160Output = new StringBuilder(); - for(int i = 0; i < hash.Length; i++) { ripemd160Output.Append(hash[i].ToString("x2")); } + for(int i = 0; i < hash.Length; i++) ripemd160Output.Append(hash[i].ToString("x2")); return ripemd160Output.ToString(); } diff --git a/DiscImageChef.Checksums/ReedSolomon.cs b/DiscImageChef.Checksums/ReedSolomon.cs index c40e6c390..8eeda85c5 100644 --- a/DiscImageChef.Checksums/ReedSolomon.cs +++ b/DiscImageChef.Checksums/ReedSolomon.cs @@ -314,7 +314,7 @@ namespace DiscImageChef.Checksums Clear(ref bb, nn - kk); for(i = kk - 1; i >= 0; i--) { - if(mm != 8) { if(data[i] > nn) return -1; /* Illegal symbol */ } + if(mm != 8) if(data[i] > nn) return -1; /* Illegal symbol */ feedback = index_of[data[i] ^ bb[nn - kk - 1]]; if(feedback != a0) @@ -384,7 +384,7 @@ namespace DiscImageChef.Checksums /* data[] is in polynomial form, copy and convert to index form */ for(i = nn - 1; i >= 0; i--) { - if(mm != 8) { if(data[i] > nn) return -1; /* Illegal symbol */ } + if(mm != 8) if(data[i] > nn) return -1; /* Illegal symbol */ recd[i] = index_of[data[i]]; } @@ -405,14 +405,7 @@ namespace DiscImageChef.Checksums s[i] = index_of[tmp]; } - if(synError == 0) - { - /* - * if syndrome is zero, data[] is a codeword and there are no - * errors to correct. So return data[] unmodified - */ - return 0; - } + if(synError == 0) return 0; Clear(ref lambda, nn - kk); lambda[0] = 1; @@ -483,13 +476,7 @@ namespace DiscImageChef.Checksums /* r is the step number */ /* Compute discrepancy at the r-th step in poly-form */ discrR = 0; - for(i = 0; i < r; i++) - { - if(lambda[i] != 0 && s[r - i] != a0) - { - discrR ^= alpha_to[Modnn(index_of[lambda[i]] + s[r - i])]; - } - } + for(i = 0; i < r; i++) if(lambda[i] != 0 && s[r - i] != a0) discrR ^= alpha_to[Modnn(index_of[lambda[i]] + s[r - i])]; discrR = index_of[discrR]; /* Index form */ if(discrR == a0) @@ -503,10 +490,8 @@ namespace DiscImageChef.Checksums /* 7 lines below: T(x) <-- lambda(x) - discr_r*x*b(x) */ t[0] = lambda[0]; for(i = 0; i < nn - kk; i++) - { if(b[i] != a0) t[i + 1] = lambda[i + 1] ^ alpha_to[Modnn(discrR + b[i])]; else t[i + 1] = lambda[i + 1]; - } if(2 * el <= r + noEras - 1) { @@ -570,14 +555,7 @@ namespace DiscImageChef.Checksums DicConsole.DebugWriteLine("Reed Solomon", "\n"); #endif - if(degLambda != count) - { - /* - * deg(lambda) unequal to number of roots => uncorrectable - * error detected - */ - return -1; - } + if(degLambda != count) return -1; /* * Compute err+eras evaluator poly omega(x) = s(x)*lambda(x) (modulo * x**(NN-KK)). in index form. Also find deg(omega). @@ -587,10 +565,7 @@ namespace DiscImageChef.Checksums { tmp = 0; j = degLambda < i ? degLambda : i; - for(; j >= 0; j--) - { - if(s[i + 1 - j] != a0 && lambda[j] != a0) tmp ^= alpha_to[Modnn(s[i + 1 - j] + lambda[j])]; - } + for(; j >= 0; j--) if(s[i + 1 - j] != a0 && lambda[j] != a0) tmp ^= alpha_to[Modnn(s[i + 1 - j] + lambda[j])]; if(tmp != 0) degOmega = i; omega[i] = index_of[tmp]; @@ -605,19 +580,13 @@ namespace DiscImageChef.Checksums for(j = count - 1; j >= 0; j--) { num1 = 0; - for(i = degOmega; i >= 0; i--) - { - if(omega[i] != a0) num1 ^= alpha_to[Modnn(omega[i] + i * root[j])]; - } + for(i = degOmega; i >= 0; i--) if(omega[i] != a0) num1 ^= alpha_to[Modnn(omega[i] + i * root[j])]; num2 = alpha_to[Modnn(root[j] * (B0 - 1) + nn)]; den = 0; /* lambda[i+1] for i even is the formal derivative lambda_pr of lambda[i] */ - for(i = Min(degLambda, nn - kk - 1) & ~1; i >= 0; i -= 2) - { - if(lambda[i + 1] != a0) den ^= alpha_to[Modnn(lambda[i + 1] + i * root[j])]; - } + for(i = Min(degLambda, nn - kk - 1) & ~1; i >= 0; i -= 2) if(lambda[i + 1] != a0) den ^= alpha_to[Modnn(lambda[i + 1] + i * root[j])]; if(den == 0) { @@ -625,10 +594,7 @@ namespace DiscImageChef.Checksums return -1; } /* Apply error to data */ - if(num1 != 0) - { - data[loc[j]] ^= alpha_to[Modnn(index_of[num1] + index_of[num2] + nn - index_of[den])]; - } + if(num1 != 0) data[loc[j]] ^= alpha_to[Modnn(index_of[num1] + index_of[num2] + nn - index_of[den])]; } return count; diff --git a/DiscImageChef.Checksums/SHA1Context.cs b/DiscImageChef.Checksums/SHA1Context.cs index 340913463..0ed7bd16e 100644 --- a/DiscImageChef.Checksums/SHA1Context.cs +++ b/DiscImageChef.Checksums/SHA1Context.cs @@ -87,10 +87,7 @@ namespace DiscImageChef.Checksums sha1Provider.TransformFinalBlock(new byte[0], 0, 0); StringBuilder sha1Output = new StringBuilder(); - for(int i = 0; i < sha1Provider.Hash.Length; i++) - { - sha1Output.Append(sha1Provider.Hash[i].ToString("x2")); - } + for(int i = 0; i < sha1Provider.Hash.Length; i++) sha1Output.Append(sha1Provider.Hash[i].ToString("x2")); return sha1Output.ToString(); } @@ -118,7 +115,7 @@ namespace DiscImageChef.Checksums hash = sha1Provider.ComputeHash(fileStream); StringBuilder sha1Output = new StringBuilder(); - for(int i = 0; i < hash.Length; i++) { sha1Output.Append(hash[i].ToString("x2")); } + for(int i = 0; i < hash.Length; i++) sha1Output.Append(hash[i].ToString("x2")); fileStream.Close(); @@ -136,7 +133,7 @@ namespace DiscImageChef.Checksums hash = sha1Provider.ComputeHash(data, 0, (int)len); StringBuilder sha1Output = new StringBuilder(); - for(int i = 0; i < hash.Length; i++) { sha1Output.Append(hash[i].ToString("x2")); } + for(int i = 0; i < hash.Length; i++) sha1Output.Append(hash[i].ToString("x2")); return sha1Output.ToString(); } diff --git a/DiscImageChef.Checksums/SHA256Context.cs b/DiscImageChef.Checksums/SHA256Context.cs index 026183e1a..78398704f 100644 --- a/DiscImageChef.Checksums/SHA256Context.cs +++ b/DiscImageChef.Checksums/SHA256Context.cs @@ -88,9 +88,7 @@ namespace DiscImageChef.Checksums StringBuilder sha256Output = new StringBuilder(); for(int i = 0; i < sha256Provider.Hash.Length; i++) - { sha256Output.Append(sha256Provider.Hash[i].ToString("x2")); - } return sha256Output.ToString(); } @@ -118,7 +116,7 @@ namespace DiscImageChef.Checksums hash = sha256Provider.ComputeHash(fileStream); StringBuilder sha256Output = new StringBuilder(); - for(int i = 0; i < hash.Length; i++) { sha256Output.Append(hash[i].ToString("x2")); } + for(int i = 0; i < hash.Length; i++) sha256Output.Append(hash[i].ToString("x2")); fileStream.Close(); @@ -136,7 +134,7 @@ namespace DiscImageChef.Checksums hash = sha256Provider.ComputeHash(data, 0, (int)len); StringBuilder sha256Output = new StringBuilder(); - for(int i = 0; i < hash.Length; i++) { sha256Output.Append(hash[i].ToString("x2")); } + for(int i = 0; i < hash.Length; i++) sha256Output.Append(hash[i].ToString("x2")); return sha256Output.ToString(); } diff --git a/DiscImageChef.Checksums/SHA384Context.cs b/DiscImageChef.Checksums/SHA384Context.cs index c7c2a434c..5831e5472 100644 --- a/DiscImageChef.Checksums/SHA384Context.cs +++ b/DiscImageChef.Checksums/SHA384Context.cs @@ -87,10 +87,7 @@ namespace DiscImageChef.Checksums sha384Provider.TransformFinalBlock(new byte[0], 0, 0); StringBuilder sha384Output = new StringBuilder(); - for(int i = 0; i < sha384Provider.Hash.Length; i++) - { - sha384Output.Append(sha384Provider.Hash[i].ToString("x2")); - } + for(int i = 0; i < sha384Provider.Hash.Length; i++) sha384Output.Append(sha384Provider.Hash[i].ToString("x2")); return sha384Output.ToString(); } @@ -118,7 +115,7 @@ namespace DiscImageChef.Checksums hash = sha384Provider.ComputeHash(fileStream); StringBuilder sha384Output = new StringBuilder(); - for(int i = 0; i < hash.Length; i++) { sha384Output.Append(hash[i].ToString("x2")); } + for(int i = 0; i < hash.Length; i++) sha384Output.Append(hash[i].ToString("x2")); fileStream.Close(); @@ -136,7 +133,7 @@ namespace DiscImageChef.Checksums hash = sha384Provider.ComputeHash(data, 0, (int)len); StringBuilder sha384Output = new StringBuilder(); - for(int i = 0; i < hash.Length; i++) { sha384Output.Append(hash[i].ToString("x2")); } + for(int i = 0; i < hash.Length; i++) sha384Output.Append(hash[i].ToString("x2")); return sha384Output.ToString(); } diff --git a/DiscImageChef.Checksums/SHA512Context.cs b/DiscImageChef.Checksums/SHA512Context.cs index 8567c705f..180538863 100644 --- a/DiscImageChef.Checksums/SHA512Context.cs +++ b/DiscImageChef.Checksums/SHA512Context.cs @@ -87,10 +87,7 @@ namespace DiscImageChef.Checksums sha512Provider.TransformFinalBlock(new byte[0], 0, 0); StringBuilder sha512Output = new StringBuilder(); - for(int i = 0; i < sha512Provider.Hash.Length; i++) - { - sha512Output.Append(sha512Provider.Hash[i].ToString("x2")); - } + for(int i = 0; i < sha512Provider.Hash.Length; i++) sha512Output.Append(sha512Provider.Hash[i].ToString("x2")); return sha512Output.ToString(); } @@ -118,7 +115,7 @@ namespace DiscImageChef.Checksums hash = sha512Provider.ComputeHash(fileStream); StringBuilder sha512Output = new StringBuilder(); - for(int i = 0; i < hash.Length; i++) { sha512Output.Append(hash[i].ToString("x2")); } + for(int i = 0; i < hash.Length; i++) sha512Output.Append(hash[i].ToString("x2")); fileStream.Close(); @@ -136,7 +133,7 @@ namespace DiscImageChef.Checksums hash = sha512Provider.ComputeHash(data, 0, (int)len); StringBuilder sha512Output = new StringBuilder(); - for(int i = 0; i < hash.Length; i++) { sha512Output.Append(hash[i].ToString("x2")); } + for(int i = 0; i < hash.Length; i++) sha512Output.Append(hash[i].ToString("x2")); return sha512Output.ToString(); } diff --git a/DiscImageChef.Checksums/SpamSumContext.cs b/DiscImageChef.Checksums/SpamSumContext.cs index 905364e0f..8b18a6fa9 100644 --- a/DiscImageChef.Checksums/SpamSumContext.cs +++ b/DiscImageChef.Checksums/SpamSumContext.cs @@ -233,12 +233,7 @@ namespace DiscImageChef.Checksums /* We have hit a reset point. We now emit hashes which are * based on all characters in the piece of the message between * the last reset point and this one */ - if(0 == self.Bh[i].Dlen) - { - /* Can only happen 30 times. */ - /* First step for this blocksize. Clone next. */ - fuzzy_try_fork_blockhash(); - } + if(0 == self.Bh[i].Dlen) fuzzy_try_fork_blockhash(); self.Bh[i].Digest[self.Bh[i].Dlen] = b64[self.Bh[i].H % 64]; self.Bh[i].Halfdigest = b64[self.Bh[i].Halfh % 64]; if(self.Bh[i].Dlen < SPAMSUM_LENGTH - 1) @@ -300,7 +295,7 @@ namespace DiscImageChef.Checksums while((ulong)SSDEEP_BS(bi) * SPAMSUM_LENGTH < self.TotalSize) { ++bi; - if(bi >= NUM_BLOCKHASHES) { throw new OverflowException("The input exceeds data types."); } + if(bi >= NUM_BLOCKHASHES) throw new OverflowException("The input exceeds data types."); } /* Adapt blocksize guess to actual digest length. */ while(bi >= self.Bhend) --bi; diff --git a/DiscImageChef.CommonTypes/MediaTypeFromSCSI.cs b/DiscImageChef.CommonTypes/MediaTypeFromSCSI.cs index 776ae6651..27d3c3540 100644 --- a/DiscImageChef.CommonTypes/MediaTypeFromSCSI.cs +++ b/DiscImageChef.CommonTypes/MediaTypeFromSCSI.cs @@ -45,7 +45,7 @@ namespace DiscImageChef.CommonTypes // Simpilified access device case 0x0E: { - if(mediumType == 0x03 || mediumType == 0x05 || mediumType == 0x07) { goto case 0x07; } + if(mediumType == 0x03 || mediumType == 0x05 || mediumType == 0x07) goto case 0x07; if(vendor.ToLowerInvariant() == "syquest") { @@ -104,7 +104,7 @@ namespace DiscImageChef.CommonTypes if(blocks == 2880) return MediaType.DOS_35_HD; if(blocks == 1440) return MediaType.DOS_35_DS_DD_9; } - else if(blockSize == 1024) { if(blocks == 1232) return MediaType.NEC_35_HD_8; } + else if(blockSize == 1024) if(blocks == 1232) return MediaType.NEC_35_HD_8; return MediaType.Unknown; } @@ -1320,7 +1320,6 @@ namespace DiscImageChef.CommonTypes { if(mediumType == 0x01 || mediumType == 0x02 || mediumType == 0x03 || mediumType == 0x05 || mediumType == 0x07) - { switch(blockSize) { case 512: @@ -1392,7 +1391,6 @@ namespace DiscImageChef.CommonTypes } default: return MediaType.UnknownMO; } - } return MediaType.UnknownMO; } @@ -1429,7 +1427,6 @@ namespace DiscImageChef.CommonTypes case 0x28: return MediaType.CDRW; case 0x80: if(model.ToLowerInvariant().StartsWith("ult")) - { switch(densityCode) { case 0x42: return MediaType.LTO2; @@ -1437,7 +1434,6 @@ namespace DiscImageChef.CommonTypes case 0x46: return MediaType.LTO4; case 0x58: return MediaType.LTO5; } - } break; } diff --git a/DiscImageChef.Core/Devices/Dumping/Alcohol120.cs b/DiscImageChef.Core/Devices/Dumping/Alcohol120.cs index d0373edd6..9610a6d21 100644 --- a/DiscImageChef.Core/Devices/Dumping/Alcohol120.cs +++ b/DiscImageChef.Core/Devices/Dumping/Alcohol120.cs @@ -205,7 +205,7 @@ namespace DiscImageChef.Core.Devices.Dumping if(tracksArray[i].point >= 0xA0) continue; if(!trackLengths.TryGetValue(tracksArray[i].point, out uint trkLen)) continue; - if(tracksArray[i].mode == AlcoholTrackMode.Dvd) { tracksArray[i].extraOffset = trkLen; } + if(tracksArray[i].mode == AlcoholTrackMode.Dvd) tracksArray[i].extraOffset = trkLen; else { AlcoholTrackExtra extra = new AlcoholTrackExtra(); @@ -274,7 +274,6 @@ namespace DiscImageChef.Core.Devices.Dumping if(header.type == AlcoholMediumType.Cd || header.type == AlcoholMediumType.Cdr || header.type == AlcoholMediumType.Cdrw) - { foreach(AlcoholTrackExtra extra in extrasArray) { tmp = new byte[8]; @@ -284,7 +283,6 @@ namespace DiscImageChef.Core.Devices.Dumping descriptorFile.Write(tmp, 0, tmp.Length); Marshal.FreeHGlobal(trkxPtr); } - } if(bca != null && bca.Length > 0) { @@ -502,7 +500,7 @@ namespace DiscImageChef.Core.Devices.Dumping AlcoholSession[] sess = sessions.ToArray(); - for(int i = 0; i < sess.Length; i++) { if(sess[i].sessionSequence == session) sess[i].nonTrackBlocks++; } + for(int i = 0; i < sess.Length; i++) if(sess[i].sessionSequence == session) sess[i].nonTrackBlocks++; sessions = new List(sess); } diff --git a/DiscImageChef.Core/Devices/Dumping/CompactDisc.cs b/DiscImageChef.Core/Devices/Dumping/CompactDisc.cs index 99ef867f7..4f6a44b52 100644 --- a/DiscImageChef.Core/Devices/Dumping/CompactDisc.cs +++ b/DiscImageChef.Core/Devices/Dumping/CompactDisc.cs @@ -132,10 +132,7 @@ namespace DiscImageChef.Core.Devices.Dumping Decoders.SCSI.MMC.DiscInformation.StandardDiscInformation? discInfo = Decoders.SCSI.MMC.DiscInformation.Decode000b(cmdBuf); if(discInfo.HasValue) - { - // If it is a read-only CD, check CD type if available if(dskType == MediaType.CD) - { switch(discInfo.Value.DiscType) { case 0x10: @@ -145,8 +142,6 @@ namespace DiscImageChef.Core.Devices.Dumping dskType = MediaType.CDROMXA; break; } - } - } } int sessions = 1; @@ -172,15 +167,11 @@ namespace DiscImageChef.Core.Devices.Dumping bool hasVideoTrack = false; if(toc.HasValue) - { foreach(FullTOC.TrackDataDescriptor track in toc.Value.TrackDescriptors) { if(track.TNO == 1 && ((TOC_CONTROL)(track.CONTROL & 0x0D) == TOC_CONTROL.DataTrack || (TOC_CONTROL)(track.CONTROL & 0x0D) == - TOC_CONTROL.DataTrackIncremental)) - { - allFirstSessionTracksAreAudio &= firstTrackLastSession != 1; - } + TOC_CONTROL.DataTrackIncremental)) allFirstSessionTracksAreAudio &= firstTrackLastSession != 1; if((TOC_CONTROL)(track.CONTROL & 0x0D) == TOC_CONTROL.DataTrack || (TOC_CONTROL)(track.CONTROL & 0x0D) == TOC_CONTROL.DataTrackIncremental) @@ -192,7 +183,6 @@ namespace DiscImageChef.Core.Devices.Dumping hasVideoTrack |= track.ADR == 4; } - } if(hasDataTrack && hasAudioTrack && allFirstSessionTracksAreAudio && sessions == 2) dskType = MediaType.CDPLUS; @@ -204,7 +194,6 @@ namespace DiscImageChef.Core.Devices.Dumping dumpLog.WriteLine("Reading PMA"); sense = dev.ReadPma(out cmdBuf, out senseBuf, dev.Timeout, out duration); if(!sense) - { if(PMA.Decode(cmdBuf).HasValue) { tmpBuf = new byte[cmdBuf.Length - 4]; @@ -217,12 +206,10 @@ namespace DiscImageChef.Core.Devices.Dumping }; DataFile.WriteTo("SCSI Dump", sidecar.OpticalDisc[0].PMA.Image, tmpBuf); } - } dumpLog.WriteLine("Reading CD-Text from Lead-In"); sense = dev.ReadCdText(out cmdBuf, out senseBuf, dev.Timeout, out duration); if(!sense) - { if(CDTextOnLeadIn.Decode(cmdBuf).HasValue) { tmpBuf = new byte[cmdBuf.Length - 4]; @@ -235,7 +222,6 @@ namespace DiscImageChef.Core.Devices.Dumping }; DataFile.WriteTo("SCSI Dump", sidecar.OpticalDisc[0].LeadInCdText.Image, tmpBuf); } - } } } @@ -259,7 +245,6 @@ namespace DiscImageChef.Core.Devices.Dumping sessionsForAlcohol[i].StartTrack = ushort.MaxValue; } foreach(FullTOC.TrackDataDescriptor trk in toc.Value.TrackDescriptors) - { if(trk.POINT > 0 && trk.POINT < 0xA0 && trk.SessionNumber <= sessionsForAlcohol.Length) { if(trk.POINT < sessionsForAlcohol[trk.SessionNumber - 1].StartTrack) @@ -267,15 +252,12 @@ namespace DiscImageChef.Core.Devices.Dumping if(trk.POINT > sessionsForAlcohol[trk.SessionNumber - 1].EndTrack) sessionsForAlcohol[trk.SessionNumber - 1].EndTrack = trk.POINT; } - } alcohol.AddSessions(sessionsForAlcohol); foreach(FullTOC.TrackDataDescriptor trk in toc.Value.TrackDescriptors) - { alcohol.AddTrack((byte)((trk.ADR << 4) & trk.CONTROL), trk.TNO, trk.POINT, trk.Min, trk.Sec, trk.Frame, trk.Zero, trk.PMIN, trk.PSEC, trk.PFRAME, trk.SessionNumber); - } FullTOC.TrackDataDescriptor[] sortedTracks = toc.Value.TrackDescriptors.OrderBy(track => track.POINT).ToArray(); @@ -283,9 +265,7 @@ namespace DiscImageChef.Core.Devices.Dumping long lastSector = 0; string lastMsf = null; foreach(FullTOC.TrackDataDescriptor trk in sortedTracks) - { if(trk.ADR == 1 || trk.ADR == 4) - { if(trk.POINT >= 0x01 && trk.POINT <= 0x63) { TrackType track = new TrackType @@ -345,8 +325,6 @@ namespace DiscImageChef.Core.Devices.Dumping else lastMsf = string.Format("{0:D2}:{1:D2}:{2:D2}", pmin, psec, pframe); lastSector = phour * 3600 * 75 + pmin * 60 * 75 + psec * 75 + pframe - 150; } - } - } TrackType[] tracks = trackList.ToArray(); for(int t = 1; t < tracks.Length; t++) @@ -386,7 +364,7 @@ namespace DiscImageChef.Core.Devices.Dumping return; } - if(dumpRaw) { throw new NotImplementedException("Raw CD dumping not yet implemented"); } + if(dumpRaw) throw new NotImplementedException("Raw CD dumping not yet implemented"); else { // TODO: Check subchannel capabilities @@ -472,7 +450,6 @@ namespace DiscImageChef.Core.Devices.Dumping dumpFile.Close(); if(leadInSectorsGood > 0) - { sidecar.OpticalDisc[0].LeadIn = new BorderType[] { new BorderType @@ -482,7 +459,6 @@ namespace DiscImageChef.Core.Devices.Dumping Size = leadInSectorsTotal * blockSize } }; - } else File.Delete(outputPrefix + ".leadin.bin"); DicConsole.WriteLine(); @@ -602,13 +578,11 @@ namespace DiscImageChef.Core.Devices.Dumping ibgLog.Write(i, currentSpeed * 1024); extents.Add(i, blocksToRead, true); if(separateSubchannel) - { for(int b = 0; b < blocksToRead; b++) { dumpFile.Write(readBuffer, (int)(0 + b * blockSize), sectorSize); subFile.Write(readBuffer, (int)(sectorSize + b * blockSize), (int)subSize); } - } else dumpFile.Write(readBuffer); } else @@ -644,7 +618,6 @@ namespace DiscImageChef.Core.Devices.Dumping { 0x00, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x00 })) - { switch(readBuffer[15]) { case 0: @@ -660,7 +633,6 @@ namespace DiscImageChef.Core.Devices.Dumping checkedDataFormat = true; break; } - } } #pragma warning disable IDE0004 // Remove Unnecessary Cast @@ -812,7 +784,7 @@ namespace DiscImageChef.Core.Devices.Dumping dumpLog.WriteLine("Sending MODE SELECT to drive."); sense = dev.ModeSelect(md6, out senseBuf, true, false, dev.Timeout, out duration); - if(sense) { sense = dev.ModeSelect10(md10, out senseBuf, true, false, dev.Timeout, out duration); } + if(sense) sense = dev.ModeSelect10(md10, out senseBuf, true, false, dev.Timeout, out duration); runningPersistent = true; if(!sense && !dev.Error) @@ -833,7 +805,7 @@ namespace DiscImageChef.Core.Devices.Dumping dumpLog.WriteLine("Sending MODE SELECT to drive."); sense = dev.ModeSelect(md6, out senseBuf, true, false, dev.Timeout, out duration); - if(sense) { sense = dev.ModeSelect10(md10, out senseBuf, true, false, dev.Timeout, out duration); } + if(sense) sense = dev.ModeSelect10(md10, out senseBuf, true, false, dev.Timeout, out duration); } DicConsole.WriteLine(); diff --git a/DiscImageChef.Core/Devices/Dumping/SBC.cs b/DiscImageChef.Core/Devices/Dumping/SBC.cs index fd60f7396..06e4a0d5a 100644 --- a/DiscImageChef.Core/Devices/Dumping/SBC.cs +++ b/DiscImageChef.Core/Devices/Dumping/SBC.cs @@ -233,15 +233,12 @@ namespace DiscImageChef.Core.Devices.Dumping sense = dev.ModeSense10(out cmdBuf, out senseBuf, false, true, ScsiModeSensePageControl.Current, 0x3F, 0xFF, 5, out duration); if(!sense || dev.Error) - { sense = dev.ModeSense10(out cmdBuf, out senseBuf, false, true, ScsiModeSensePageControl.Current, 0x3F, 0x00, 5, out duration); - } Decoders.SCSI.Modes.DecodedMode? decMode = null; if(!sense && !dev.Error) - { if(Decoders.SCSI.Modes.DecodeMode10(cmdBuf, dev.ScsiType).HasValue) { decMode = Decoders.SCSI.Modes.DecodeMode10(cmdBuf, dev.ScsiType); @@ -253,7 +250,6 @@ namespace DiscImageChef.Core.Devices.Dumping }; DataFile.WriteTo("SCSI Dump", sidecar.BlockMedia[0].SCSI.ModeSense10.Image, cmdBuf); } - } dumpLog.WriteLine("Requesting MODE SENSE (6)."); sense = dev.ModeSense6(out cmdBuf, out senseBuf, false, ScsiModeSensePageControl.Current, 0x3F, @@ -264,7 +260,6 @@ namespace DiscImageChef.Core.Devices.Dumping if(sense || dev.Error) sense = dev.ModeSense(out cmdBuf, out senseBuf, 5, out duration); if(!sense && !dev.Error) - { if(Decoders.SCSI.Modes.DecodeMode6(cmdBuf, dev.ScsiType).HasValue) { decMode = Decoders.SCSI.Modes.DecodeMode6(cmdBuf, dev.ScsiType); @@ -276,7 +271,6 @@ namespace DiscImageChef.Core.Devices.Dumping }; DataFile.WriteTo("SCSI Dump", sidecar.BlockMedia[0].SCSI.ModeSense.Image, cmdBuf); } - } if(decMode.HasValue) { @@ -295,18 +289,12 @@ namespace DiscImageChef.Core.Devices.Dumping uint longBlockSize = scsiReader.LongBlockSize; if(dumpRaw) - { if(blockSize == longBlockSize) { - if(!scsiReader.CanReadRaw) - { - DicConsole.ErrorWriteLine("Device doesn't seem capable of reading raw data from media."); - } + if(!scsiReader.CanReadRaw) DicConsole.ErrorWriteLine("Device doesn't seem capable of reading raw data from media."); else - { DicConsole .ErrorWriteLine("Device is capable of reading raw data but I've been unable to guess correct sector size."); - } if(!force) { @@ -330,7 +318,6 @@ namespace DiscImageChef.Core.Devices.Dumping physicalBlockSize = longBlockSize; blockSize = longBlockSize; } - } DicConsole.WriteLine("Reading {0} sectors at a time.", blocksToRead); @@ -548,7 +535,7 @@ namespace DiscImageChef.Core.Devices.Dumping dumpLog.WriteLine("Sending MODE SELECT to drive."); sense = dev.ModeSelect(md6, out senseBuf, true, false, dev.Timeout, out duration); - if(sense) { sense = dev.ModeSelect10(md10, out senseBuf, true, false, dev.Timeout, out duration); } + if(sense) sense = dev.ModeSelect10(md10, out senseBuf, true, false, dev.Timeout, out duration); runningPersistent = true; if(!sense && !dev.Error) @@ -569,7 +556,7 @@ namespace DiscImageChef.Core.Devices.Dumping dumpLog.WriteLine("Sending MODE SELECT to drive."); sense = dev.ModeSelect(md6, out senseBuf, true, false, dev.Timeout, out duration); - if(sense) { sense = dev.ModeSelect10(md10, out senseBuf, true, false, dev.Timeout, out duration); } + if(sense) sense = dev.ModeSelect10(md10, out senseBuf, true, false, dev.Timeout, out duration); } DicConsole.WriteLine(); @@ -662,7 +649,6 @@ namespace DiscImageChef.Core.Devices.Dumping partitions[i].Scheme); foreach(Filesystem plugin in plugins.PluginsList.Values) - { try { if(plugin.Identify(imageFormat, partitions[i])) @@ -686,7 +672,6 @@ namespace DiscImageChef.Core.Devices.Dumping { //DicConsole.DebugWriteLine("Dump-media command", "Plugin {0} crashed", _plugin.Name); } - } if(lstFs.Count > 0) xmlFileSysInfo[i].FileSystems = lstFs.ToArray(); } @@ -702,7 +687,6 @@ namespace DiscImageChef.Core.Devices.Dumping new Partition {Name = "Whole device", Length = blocks, Size = blocks * blockSize}; foreach(Filesystem plugin in plugins.PluginsList.Values) - { try { if(plugin.Identify(imageFormat, wholePart)) @@ -724,7 +708,6 @@ namespace DiscImageChef.Core.Devices.Dumping { //DicConsole.DebugWriteLine("Create-sidecar command", "Plugin {0} crashed", _plugin.Name); } - } if(lstFs.Count > 0) xmlFileSysInfo[0].FileSystems = lstFs.ToArray(); } @@ -820,12 +803,10 @@ namespace DiscImageChef.Core.Devices.Dumping Value = outputPrefix + ".bin" }; if(!dev.IsRemovable || dev.IsUsb) - { if(dev.Type == DeviceType.ATAPI) sidecar.BlockMedia[0].Interface = "ATAPI"; else if(dev.IsUsb) sidecar.BlockMedia[0].Interface = "USB"; else if(dev.IsFireWire) sidecar.BlockMedia[0].Interface = "FireWire"; else sidecar.BlockMedia[0].Interface = "SCSI"; - } sidecar.BlockMedia[0].LogicalBlocks = (long)blocks; sidecar.BlockMedia[0].PhysicalBlockSize = (int)physicalBlockSize; sidecar.BlockMedia[0].LogicalBlockSize = (int)logicalBlockSize; diff --git a/DiscImageChef.Core/Devices/Dumping/XGD.cs b/DiscImageChef.Core/Devices/Dumping/XGD.cs index 7a38ec07e..fb6c918f4 100644 --- a/DiscImageChef.Core/Devices/Dumping/XGD.cs +++ b/DiscImageChef.Core/Devices/Dumping/XGD.cs @@ -604,7 +604,7 @@ namespace DiscImageChef.Core.Devices.Dumping { List tmpList = new List(); - foreach(ulong ur in resume.BadBlocks) { for(ulong i = ur; i < ur + blocksToRead; i++) tmpList.Add(i); } + foreach(ulong ur in resume.BadBlocks) for(ulong i = ur; i < ur + blocksToRead; i++) tmpList.Add(i); tmpList.Sort(); @@ -732,7 +732,7 @@ namespace DiscImageChef.Core.Devices.Dumping dumpLog.WriteLine("Sending MODE SELECT to drive."); sense = dev.ModeSelect(md6, out senseBuf, true, false, dev.Timeout, out duration); - if(sense) { sense = dev.ModeSelect10(md10, out senseBuf, true, false, dev.Timeout, out duration); } + if(sense) sense = dev.ModeSelect10(md10, out senseBuf, true, false, dev.Timeout, out duration); runningPersistent = true; if(!sense && !dev.Error) @@ -753,7 +753,7 @@ namespace DiscImageChef.Core.Devices.Dumping dumpLog.WriteLine("Sending MODE SELECT to drive."); sense = dev.ModeSelect(md6, out senseBuf, true, false, dev.Timeout, out duration); - if(sense) { sense = dev.ModeSelect10(md10, out senseBuf, true, false, dev.Timeout, out duration); } + if(sense) sense = dev.ModeSelect10(md10, out senseBuf, true, false, dev.Timeout, out duration); } DicConsole.WriteLine(); @@ -848,7 +848,6 @@ namespace DiscImageChef.Core.Devices.Dumping partitions[i].Scheme); foreach(Filesystem plugin in plugins.PluginsList.Values) - { try { if(plugin.Identify(imageFormat, partitions[i])) @@ -872,7 +871,6 @@ namespace DiscImageChef.Core.Devices.Dumping { //DicConsole.DebugWriteLine("Dump-media command", "Plugin {0} crashed", _plugin.Name); } - } if(lstFs.Count > 0) xmlFileSysInfo[i].FileSystems = lstFs.ToArray(); } @@ -888,7 +886,6 @@ namespace DiscImageChef.Core.Devices.Dumping new Partition {Name = "Whole device", Length = blocks, Size = blocks * blockSize}; foreach(Filesystem plugin in plugins.PluginsList.Values) - { try { if(plugin.Identify(imageFormat, wholePart)) @@ -910,7 +907,6 @@ namespace DiscImageChef.Core.Devices.Dumping { //DicConsole.DebugWriteLine("Create-sidecar command", "Plugin {0} crashed", _plugin.Name); } - } if(lstFs.Count > 0) xmlFileSysInfo[0].FileSystems = lstFs.ToArray(); } diff --git a/DiscImageChef.Core/Devices/ReaderSCSI.cs b/DiscImageChef.Core/Devices/ReaderSCSI.cs index 37721e0a7..f63bf97e6 100644 --- a/DiscImageChef.Core/Devices/ReaderSCSI.cs +++ b/DiscImageChef.Core/Devices/ReaderSCSI.cs @@ -350,12 +350,16 @@ namespace DiscImageChef.Core.Devices else { if(dev.Manufacturer == "HL-DT-ST") + { hldtstReadRaw = !dev.HlDtStReadRawDvd(out readBuffer, out senseBuf, 0, 1, timeout, out duration); + } if(dev.Manufacturer == "PLEXTOR") + { plextorReadRaw = !dev.PlextorReadRawDvd(out readBuffer, out senseBuf, 0, 1, timeout, out duration); + } if(hldtstReadRaw || plextorReadRaw) { @@ -500,39 +504,59 @@ namespace DiscImageChef.Core.Devices if(readRaw) { if(readLong16) + { sense = dev.ReadLong16(out buffer, out senseBuf, false, block, longBlockSize, timeout, out duration); + } else if(readLong10) + { sense = dev.ReadLong10(out buffer, out senseBuf, false, false, (uint)block, (ushort)longBlockSize, timeout, out duration); + } else if(syqReadLong10) + { sense = dev.SyQuestReadLong10(out buffer, out senseBuf, (uint)block, longBlockSize, timeout, out duration); + } else if(syqReadLong6) + { sense = dev.SyQuestReadLong6(out buffer, out senseBuf, (uint)block, longBlockSize, timeout, out duration); + } else if(hldtstReadRaw) + { sense = dev.HlDtStReadRawDvd(out buffer, out senseBuf, (uint)block, longBlockSize, timeout, out duration); + } else if(plextorReadRaw) + { sense = dev.PlextorReadRawDvd(out buffer, out senseBuf, (uint)block, longBlockSize, timeout, out duration); + } else return true; } else { if(read16) + { sense = dev.Read16(out buffer, out senseBuf, 0, false, true, false, block, blockSize, 0, count, false, timeout, out duration); + } else if(read12) + { sense = dev.Read12(out buffer, out senseBuf, 0, false, false, false, false, (uint)block, blockSize, 0, count, false, timeout, out duration); + } else if(read10) + { sense = dev.Read10(out buffer, out senseBuf, 0, false, true, false, false, (uint)block, blockSize, 0, (ushort)count, timeout, out duration); + } else if(read6) + { sense = dev.Read6(out buffer, out senseBuf, (uint)block, blockSize, (byte)count, timeout, out duration); + } else return true; } diff --git a/DiscImageChef.Core/Devices/Report/ATA.cs b/DiscImageChef.Core/Devices/Report/ATA.cs index a1c114142..a359217cd 100644 --- a/DiscImageChef.Core/Devices/Report/ATA.cs +++ b/DiscImageChef.Core/Devices/Report/ATA.cs @@ -553,9 +553,11 @@ namespace DiscImageChef.Core.Devices.Report mediaTest.CurrentCHS.Heads = ataId.CurrentHeads; mediaTest.CurrentCHS.Sectors = ataId.CurrentSectorsPerTrack; if(mediaTest.Blocks == 0) + { mediaTest.Blocks = (ulong)(ataId.CurrentCylinders * ataId.CurrentHeads * ataId.CurrentSectorsPerTrack); + } mediaTest.BlocksSpecified = true; } @@ -696,9 +698,11 @@ namespace DiscImageChef.Core.Devices.Report "Sense = {0}, Status = 0x{1:X2}, Error = 0x{2:X2}, Length = {3}", sense, errorChs.status, errorChs.error, readBuf.Length); if(debug) + { DataFile.WriteTo("ATA Report", "readsectorschs", "_debug_" + mediaTest.MediumTypeName + ".bin", "read results", readBuf); + } DicConsole.WriteLine("Trying READ SECTOR(S) RETRY in CHS mode..."); sense = dev.Read(out readBuf, out errorChs, true, 0, 0, 1, 1, timeout, out duration); @@ -709,9 +713,11 @@ namespace DiscImageChef.Core.Devices.Report "Sense = {0}, Status = 0x{1:X2}, Error = 0x{2:X2}, Length = {3}", sense, errorChs.status, errorChs.error, readBuf.Length); if(debug) + { DataFile.WriteTo("ATA Report", "readsectorsretrychs", "_debug_" + mediaTest.MediumTypeName + ".bin", "read results", readBuf); + } DicConsole.WriteLine("Trying READ DMA in CHS mode..."); sense = dev.ReadDma(out readBuf, out errorChs, false, 0, 0, 1, 1, timeout, @@ -723,9 +729,11 @@ namespace DiscImageChef.Core.Devices.Report "Sense = {0}, Status = 0x{1:X2}, Error = 0x{2:X2}, Length = {3}", sense, errorChs.status, errorChs.error, readBuf.Length); if(debug) + { DataFile.WriteTo("ATA Report", "readdmachs", "_debug_" + mediaTest.MediumTypeName + ".bin", "read results", readBuf); + } DicConsole.WriteLine("Trying READ DMA RETRY in CHS mode..."); sense = dev.ReadDma(out readBuf, out errorChs, true, 0, 0, 1, 1, timeout, out duration); @@ -736,9 +744,11 @@ namespace DiscImageChef.Core.Devices.Report "Sense = {0}, Status = 0x{1:X2}, Error = 0x{2:X2}, Length = {3}", sense, errorChs.status, errorChs.error, readBuf.Length); if(debug) + { DataFile.WriteTo("ATA Report", "readdmaretrychs", "_debug_" + mediaTest.MediumTypeName + ".bin", "read results", readBuf); + } DicConsole.WriteLine("Trying SEEK in CHS mode..."); sense = dev.Seek(out errorChs, 0, 0, 1, timeout, out duration); @@ -757,9 +767,11 @@ namespace DiscImageChef.Core.Devices.Report "Sense = {0}, Status = 0x{1:X2}, Error = 0x{2:X2}, Length = {3}", sense, errorChs.status, errorChs.error, readBuf.Length); if(debug) + { DataFile.WriteTo("ATA Report", "readsectors", "_debug_" + mediaTest.MediumTypeName + ".bin", "read results", readBuf); + } DicConsole.WriteLine("Trying READ SECTOR(S) RETRY in LBA mode..."); sense = dev.Read(out readBuf, out errorLba, true, 0, 1, timeout, out duration); @@ -770,9 +782,11 @@ namespace DiscImageChef.Core.Devices.Report "Sense = {0}, Status = 0x{1:X2}, Error = 0x{2:X2}, Length = {3}", sense, errorChs.status, errorChs.error, readBuf.Length); if(debug) + { DataFile.WriteTo("ATA Report", "readsectorsretry", "_debug_" + mediaTest.MediumTypeName + ".bin", "read results", readBuf); + } DicConsole.WriteLine("Trying READ DMA in LBA mode..."); sense = dev.ReadDma(out readBuf, out errorLba, false, 0, 1, timeout, out duration); @@ -783,9 +797,11 @@ namespace DiscImageChef.Core.Devices.Report "Sense = {0}, Status = 0x{1:X2}, Error = 0x{2:X2}, Length = {3}", sense, errorChs.status, errorChs.error, readBuf.Length); if(debug) + { DataFile.WriteTo("ATA Report", "readdma", "_debug_" + mediaTest.MediumTypeName + ".bin", "read results", readBuf); + } DicConsole.WriteLine("Trying READ DMA RETRY in LBA mode..."); sense = dev.ReadDma(out readBuf, out errorLba, true, 0, 1, timeout, out duration); @@ -796,9 +812,11 @@ namespace DiscImageChef.Core.Devices.Report "Sense = {0}, Status = 0x{1:X2}, Error = 0x{2:X2}, Length = {3}", sense, errorChs.status, errorChs.error, readBuf.Length); if(debug) + { DataFile.WriteTo("ATA Report", "readdmaretry", "_debug_" + mediaTest.MediumTypeName + ".bin", "read results", readBuf); + } DicConsole.WriteLine("Trying SEEK in LBA mode..."); sense = dev.Seek(out errorLba, 0, timeout, out duration); @@ -817,9 +835,11 @@ namespace DiscImageChef.Core.Devices.Report "Sense = {0}, Status = 0x{1:X2}, Error = 0x{2:X2}, Length = {3}", sense, errorChs.status, errorChs.error, readBuf.Length); if(debug) + { DataFile.WriteTo("ATA Report", "readsectors48", "_debug_" + mediaTest.MediumTypeName + ".bin", "read results", readBuf); + } DicConsole.WriteLine("Trying READ DMA in LBA48 mode..."); sense = dev.ReadDma(out readBuf, out errorLba48, 0, 1, timeout, out duration); @@ -830,9 +850,11 @@ namespace DiscImageChef.Core.Devices.Report "Sense = {0}, Status = 0x{1:X2}, Error = 0x{2:X2}, Length = {3}", sense, errorChs.status, errorChs.error, readBuf.Length); if(debug) + { DataFile.WriteTo("ATA Report", "readdma48", "_debug_" + mediaTest.MediumTypeName + ".bin", "read results", readBuf); + } DicConsole.WriteLine("Trying READ LONG in CHS mode..."); sense = dev.ReadLong(out readBuf, out errorChs, false, 0, 0, 1, mediaTest.LongBlockSize, @@ -844,9 +866,11 @@ namespace DiscImageChef.Core.Devices.Report "Sense = {0}, Status = 0x{1:X2}, Error = 0x{2:X2}, Length = {3}", sense, errorChs.status, errorChs.error, readBuf.Length); if(debug) + { DataFile.WriteTo("ATA Report", "readlongchs", "_debug_" + mediaTest.MediumTypeName + ".bin", "read results", readBuf); + } DicConsole.WriteLine("Trying READ LONG RETRY in CHS mode..."); sense = dev.ReadLong(out readBuf, out errorChs, true, 0, 0, 1, mediaTest.LongBlockSize, @@ -858,9 +882,11 @@ namespace DiscImageChef.Core.Devices.Report "Sense = {0}, Status = 0x{1:X2}, Error = 0x{2:X2}, Length = {3}", sense, errorChs.status, errorChs.error, readBuf.Length); if(debug) + { DataFile.WriteTo("ATA Report", "readlongretrychs", "_debug_" + mediaTest.MediumTypeName + ".bin", "read results", readBuf); + } DicConsole.WriteLine("Trying READ LONG in LBA mode..."); sense = dev.ReadLong(out readBuf, out errorLba, false, 0, mediaTest.LongBlockSize, @@ -872,9 +898,11 @@ namespace DiscImageChef.Core.Devices.Report "Sense = {0}, Status = 0x{1:X2}, Error = 0x{2:X2}, Length = {3}", sense, errorChs.status, errorChs.error, readBuf.Length); if(debug) + { DataFile.WriteTo("ATA Report", "readlong", "_debug_" + mediaTest.MediumTypeName + ".bin", "read results", readBuf); + } DicConsole.WriteLine("Trying READ LONG RETRY in LBA mode..."); sense = dev.ReadLong(out readBuf, out errorLba, true, 0, mediaTest.LongBlockSize, @@ -886,9 +914,11 @@ namespace DiscImageChef.Core.Devices.Report "Sense = {0}, Status = 0x{1:X2}, Error = 0x{2:X2}, Length = {3}", sense, errorChs.status, errorChs.error, readBuf.Length); if(debug) + { DataFile.WriteTo("ATA Report", "readlongretry", "_debug_" + mediaTest.MediumTypeName + ".bin", "read results", readBuf); + } } else mediaTest.MediaIsRecognized = false; @@ -1070,8 +1100,10 @@ namespace DiscImageChef.Core.Devices.Report "Sense = {0}, Status = 0x{1:X2}, Error = 0x{2:X2}, Length = {3}", sense, errorChs.status, errorChs.error, readBuf.Length); if(debug) + { DataFile.WriteTo("ATA Report", "readsectorschs", "_debug_" + report.ATA.Model + ".bin", "read results", readBuf); + } DicConsole.WriteLine("Trying READ SECTOR(S) RETRY in CHS mode..."); sense = dev.Read(out readBuf, out errorChs, true, 0, 0, 1, 1, timeout, out duration); @@ -1081,8 +1113,10 @@ namespace DiscImageChef.Core.Devices.Report "Sense = {0}, Status = 0x{1:X2}, Error = 0x{2:X2}, Length = {3}", sense, errorChs.status, errorChs.error, readBuf.Length); if(debug) + { DataFile.WriteTo("ATA Report", "readsectorsretrychs", "_debug_" + report.ATA.Model + ".bin", "read results", readBuf); + } DicConsole.WriteLine("Trying READ DMA in CHS mode..."); sense = dev.ReadDma(out readBuf, out errorChs, false, 0, 0, 1, 1, timeout, out duration); @@ -1092,8 +1126,10 @@ namespace DiscImageChef.Core.Devices.Report "Sense = {0}, Status = 0x{1:X2}, Error = 0x{2:X2}, Length = {3}", sense, errorChs.status, errorChs.error, readBuf.Length); if(debug) + { DataFile.WriteTo("ATA Report", "readdmachs", "_debug_" + report.ATA.Model + ".bin", "read results", readBuf); + } DicConsole.WriteLine("Trying READ DMA RETRY in CHS mode..."); sense = dev.ReadDma(out readBuf, out errorChs, true, 0, 0, 1, 1, timeout, out duration); @@ -1103,8 +1139,10 @@ namespace DiscImageChef.Core.Devices.Report "Sense = {0}, Status = 0x{1:X2}, Error = 0x{2:X2}, Length = {3}", sense, errorChs.status, errorChs.error, readBuf.Length); if(debug) + { DataFile.WriteTo("ATA Report", "readdmaretrychs", "_debug_" + report.ATA.Model + ".bin", "read results", readBuf); + } DicConsole.WriteLine("Trying SEEK in CHS mode..."); sense = dev.Seek(out errorChs, 0, 0, 1, timeout, out duration); @@ -1121,8 +1159,10 @@ namespace DiscImageChef.Core.Devices.Report "Sense = {0}, Status = 0x{1:X2}, Error = 0x{2:X2}, Length = {3}", sense, errorLba.status, errorLba.error, readBuf.Length); if(debug) + { DataFile.WriteTo("ATA Report", "readsectors", "_debug_" + report.ATA.Model + ".bin", "read results", readBuf); + } DicConsole.WriteLine("Trying READ SECTOR(S) RETRY in LBA mode..."); sense = dev.Read(out readBuf, out errorLba, true, 0, 1, timeout, out duration); @@ -1132,8 +1172,10 @@ namespace DiscImageChef.Core.Devices.Report "Sense = {0}, Status = 0x{1:X2}, Error = 0x{2:X2}, Length = {3}", sense, errorLba.status, errorLba.error, readBuf.Length); if(debug) + { DataFile.WriteTo("ATA Report", "readsectorsretry", "_debug_" + report.ATA.Model + ".bin", "read results", readBuf); + } DicConsole.WriteLine("Trying READ DMA in LBA mode..."); sense = dev.ReadDma(out readBuf, out errorLba, false, 0, 1, timeout, out duration); @@ -1143,8 +1185,10 @@ namespace DiscImageChef.Core.Devices.Report "Sense = {0}, Status = 0x{1:X2}, Error = 0x{2:X2}, Length = {3}", sense, errorLba.status, errorLba.error, readBuf.Length); if(debug) + { DataFile.WriteTo("ATA Report", "readdma", "_debug_" + report.ATA.Model + ".bin", "read results", readBuf); + } DicConsole.WriteLine("Trying READ DMA RETRY in LBA mode..."); sense = dev.ReadDma(out readBuf, out errorLba, true, 0, 1, timeout, out duration); @@ -1154,8 +1198,10 @@ namespace DiscImageChef.Core.Devices.Report "Sense = {0}, Status = 0x{1:X2}, Error = 0x{2:X2}, Length = {3}", sense, errorLba.status, errorLba.error, readBuf.Length); if(debug) + { DataFile.WriteTo("ATA Report", "readdmaretry", "_debug_" + report.ATA.Model + ".bin", "read results", readBuf); + } DicConsole.WriteLine("Trying SEEK in LBA mode..."); sense = dev.Seek(out errorLba, 0, timeout, out duration); @@ -1172,8 +1218,10 @@ namespace DiscImageChef.Core.Devices.Report "Sense = {0}, Status = 0x{1:X2}, Error = 0x{2:X2}, Length = {3}", sense, errorLba48.status, errorLba48.error, readBuf.Length); if(debug) + { DataFile.WriteTo("ATA Report", "readsectors48", "_debug_" + report.ATA.Model + ".bin", "read results", readBuf); + } DicConsole.WriteLine("Trying READ DMA in LBA48 mode..."); sense = dev.ReadDma(out readBuf, out errorLba48, 0, 1, timeout, out duration); @@ -1183,8 +1231,10 @@ namespace DiscImageChef.Core.Devices.Report "Sense = {0}, Status = 0x{1:X2}, Error = 0x{2:X2}, Length = {3}", sense, errorLba48.status, errorLba48.error, readBuf.Length); if(debug) + { DataFile.WriteTo("ATA Report", "readdma48", "_debug_" + report.ATA.Model + ".bin", "read results", readBuf); + } DicConsole.WriteLine("Trying READ LONG in CHS mode..."); sense = dev.ReadLong(out readBuf, out errorChs, false, 0, 0, 1, @@ -1196,8 +1246,10 @@ namespace DiscImageChef.Core.Devices.Report "Sense = {0}, Status = 0x{1:X2}, Error = 0x{2:X2}, Length = {3}", sense, errorChs.status, errorChs.error, readBuf.Length); if(debug) + { DataFile.WriteTo("ATA Report", "readlongchs", "_debug_" + report.ATA.Model + ".bin", "read results", readBuf); + } DicConsole.WriteLine("Trying READ LONG RETRY in CHS mode..."); sense = dev.ReadLong(out readBuf, out errorChs, true, 0, 0, 1, @@ -1209,8 +1261,10 @@ namespace DiscImageChef.Core.Devices.Report "Sense = {0}, Status = 0x{1:X2}, Error = 0x{2:X2}, Length = {3}", sense, errorChs.status, errorChs.error, readBuf.Length); if(debug) + { DataFile.WriteTo("ATA Report", "readlongretrychs", "_debug_" + report.ATA.Model + ".bin", "read results", readBuf); + } DicConsole.WriteLine("Trying READ LONG in LBA mode..."); sense = dev.ReadLong(out readBuf, out errorLba, false, 0, report.ATA.ReadCapabilities.LongBlockSize, @@ -1222,8 +1276,10 @@ namespace DiscImageChef.Core.Devices.Report "Sense = {0}, Status = 0x{1:X2}, Error = 0x{2:X2}, Length = {3}", sense, errorLba.status, errorLba.error, readBuf.Length); if(debug) + { DataFile.WriteTo("ATA Report", "readlong", "_debug_" + report.ATA.Model + ".bin", "read results", readBuf); + } DicConsole.WriteLine("Trying READ LONG RETRY in LBA mode..."); sense = dev.ReadLong(out readBuf, out errorLba, true, 0, report.ATA.ReadCapabilities.LongBlockSize, @@ -1235,8 +1291,10 @@ namespace DiscImageChef.Core.Devices.Report "Sense = {0}, Status = 0x{1:X2}, Error = 0x{2:X2}, Length = {3}", sense, errorLba.status, errorLba.error, readBuf.Length); if(debug) + { DataFile.WriteTo("ATA Report", "readlongretry", "_debug_" + report.ATA.Model + ".bin", "read results", readBuf); + } } } } diff --git a/DiscImageChef.Core/Devices/Report/SCSI/General.cs b/DiscImageChef.Core/Devices/Report/SCSI/General.cs index ab0fe7098..f7104e5ae 100644 --- a/DiscImageChef.Core/Devices/Report/SCSI/General.cs +++ b/DiscImageChef.Core/Devices/Report/SCSI/General.cs @@ -133,10 +133,7 @@ namespace DiscImageChef.Core.Devices.Report.SCSI } if(inq.VersionDescriptors != null) { - foreach(ushort descriptor in inq.VersionDescriptors) - { - if(descriptor != 0) versionDescriptors.Add(descriptor); - } + foreach(ushort descriptor in inq.VersionDescriptors) if(descriptor != 0) versionDescriptors.Add(descriptor); if(versionDescriptors.Count > 0) report.SCSI.Inquiry.VersionDescriptors = versionDescriptors.ToArray(); @@ -305,10 +302,7 @@ namespace DiscImageChef.Core.Devices.Report.SCSI modePage.value = page.PageResponse; modePages.Add(modePage); - if(modePage.page == 0x2A && modePage.subpage == 0x00) - { - cdromMode = Decoders.SCSI.Modes.DecodeModePage_2A(page.PageResponse); - } + if(modePage.page == 0x2A && modePage.subpage == 0x00) cdromMode = Decoders.SCSI.Modes.DecodeModePage_2A(page.PageResponse); } if(modePages.Count > 0) report.SCSI.ModeSense.ModePages = modePages.ToArray(); @@ -477,9 +471,11 @@ namespace DiscImageChef.Core.Devices.Report.SCSI timeout, out duration); DicConsole.DebugWriteLine("SCSI Report", "Sense = {0}", !mediaTest.SupportsRead); if(debug) + { DataFile.WriteTo("SCSI Report", "read6", "_debug_" + mediaTest.MediumTypeName + ".bin", "read results", buffer); + } DicConsole.WriteLine("Trying SCSI READ (10)..."); mediaTest.SupportsRead10 = @@ -487,9 +483,11 @@ namespace DiscImageChef.Core.Devices.Report.SCSI mediaTest.BlockSize, 0, 1, timeout, out duration); DicConsole.DebugWriteLine("SCSI Report", "Sense = {0}", !mediaTest.SupportsRead10); if(debug) + { DataFile.WriteTo("SCSI Report", "read10", "_debug_" + mediaTest.MediumTypeName + ".bin", "read results", buffer); + } DicConsole.WriteLine("Trying SCSI READ (12)..."); mediaTest.SupportsRead12 = @@ -497,9 +495,11 @@ namespace DiscImageChef.Core.Devices.Report.SCSI mediaTest.BlockSize, 0, 1, false, timeout, out duration); DicConsole.DebugWriteLine("SCSI Report", "Sense = {0}", !mediaTest.SupportsRead12); if(debug) + { DataFile.WriteTo("SCSI Report", "read12", "_debug_" + mediaTest.MediumTypeName + ".bin", "read results", buffer); + } DicConsole.WriteLine("Trying SCSI READ (16)..."); mediaTest.SupportsRead16 = @@ -507,9 +507,11 @@ namespace DiscImageChef.Core.Devices.Report.SCSI mediaTest.BlockSize, 0, 1, false, timeout, out duration); DicConsole.DebugWriteLine("SCSI Report", "Sense = {0}", !mediaTest.SupportsRead16); if(debug) + { DataFile.WriteTo("SCSI Report", "read16", "_debug_" + mediaTest.MediumTypeName + ".bin", "read results", buffer); + } mediaTest.LongBlockSize = mediaTest.BlockSize; DicConsole.WriteLine("Trying SCSI READ LONG (10)..."); @@ -653,9 +655,11 @@ namespace DiscImageChef.Core.Devices.Report.SCSI sense = dev.ReadLong10(out buffer, out senseBuffer, false, false, 0, (ushort)mediaTest.LongBlockSize, timeout, out duration); if(!sense) + { DataFile.WriteTo("SCSI Report", "readlong10", "_debug_" + mediaTest.MediumTypeName + ".bin", "read results", buffer); + } } mediaTest.CanReadMediaSerialSpecified = true; @@ -753,9 +757,11 @@ namespace DiscImageChef.Core.Devices.Report.SCSI timeout, out duration); DicConsole.DebugWriteLine("SCSI Report", "Sense = {0}", !report.SCSI.ReadCapabilities.SupportsRead); if(debug) + { DataFile.WriteTo("SCSI Report", "read6", "_debug_" + report.SCSI.Inquiry.ProductIdentification + ".bin", "read results", buffer); + } DicConsole.WriteLine("Trying SCSI READ (10)..."); report.SCSI.ReadCapabilities.SupportsRead10 = @@ -764,9 +770,11 @@ namespace DiscImageChef.Core.Devices.Report.SCSI DicConsole.DebugWriteLine("SCSI Report", "Sense = {0}", !report.SCSI.ReadCapabilities.SupportsRead10); if(debug) + { DataFile.WriteTo("SCSI Report", "read10", "_debug_" + report.SCSI.Inquiry.ProductIdentification + ".bin", "read results", buffer); + } DicConsole.WriteLine("Trying SCSI READ (12)..."); report.SCSI.ReadCapabilities.SupportsRead12 = @@ -775,9 +783,11 @@ namespace DiscImageChef.Core.Devices.Report.SCSI DicConsole.DebugWriteLine("SCSI Report", "Sense = {0}", !report.SCSI.ReadCapabilities.SupportsRead12); if(debug) + { DataFile.WriteTo("SCSI Report", "read12", "_debug_" + report.SCSI.Inquiry.ProductIdentification + ".bin", "read results", buffer); + } DicConsole.WriteLine("Trying SCSI READ (16)..."); report.SCSI.ReadCapabilities.SupportsRead16 = @@ -786,9 +796,11 @@ namespace DiscImageChef.Core.Devices.Report.SCSI DicConsole.DebugWriteLine("SCSI Report", "Sense = {0}", !report.SCSI.ReadCapabilities.SupportsRead16); if(debug) + { DataFile.WriteTo("SCSI Report", "read16", "_debug_" + report.SCSI.Inquiry.ProductIdentification + ".bin", "read results", buffer); + } report.SCSI.ReadCapabilities.LongBlockSize = report.SCSI.ReadCapabilities.BlockSize; DicConsole.WriteLine("Trying SCSI READ LONG (10)..."); @@ -943,9 +955,11 @@ namespace DiscImageChef.Core.Devices.Report.SCSI (ushort)report.SCSI.ReadCapabilities.LongBlockSize, timeout, out duration); if(!sense) + { DataFile.WriteTo("SCSI Report", "readlong10", "_debug_" + report.SCSI.Inquiry.ProductIdentification + ".bin", "read results", buffer); + } } } } diff --git a/DiscImageChef.Core/Devices/Report/SCSI/MMC.cs b/DiscImageChef.Core/Devices/Report/SCSI/MMC.cs index 85df27ee8..49d9054cc 100644 --- a/DiscImageChef.Core/Devices/Report/SCSI/MMC.cs +++ b/DiscImageChef.Core/Devices/Report/SCSI/MMC.cs @@ -318,10 +318,7 @@ namespace DiscImageChef.Core.Devices.Report.SCSI report.SCSI.MultiMediaDevice.Features.CanReadDVDPlusRW = true; Decoders.SCSI.MMC.Feature_002A? ftr002A = Decoders.SCSI.MMC.Features.Decode_002A(desc.Data); - if(ftr002A.HasValue) - { - report.SCSI.MultiMediaDevice.Features.CanWriteDVDPlusRW = ftr002A.Value.Write; - } + if(ftr002A.HasValue) report.SCSI.MultiMediaDevice.Features.CanWriteDVDPlusRW = ftr002A.Value.Write; } break; case 0x002B: @@ -329,10 +326,7 @@ namespace DiscImageChef.Core.Devices.Report.SCSI report.SCSI.MultiMediaDevice.Features.CanReadDVDPlusR = true; Decoders.SCSI.MMC.Feature_002B? ftr002B = Decoders.SCSI.MMC.Features.Decode_002B(desc.Data); - if(ftr002B.HasValue) - { - report.SCSI.MultiMediaDevice.Features.CanWriteDVDPlusR = ftr002B.Value.Write; - } + if(ftr002B.HasValue) report.SCSI.MultiMediaDevice.Features.CanWriteDVDPlusR = ftr002B.Value.Write; } break; case 0x002D: @@ -686,10 +680,7 @@ namespace DiscImageChef.Core.Devices.Report.SCSI if(!mediaTypes.Contains("CD-RW")) mediaTypes.Add("CD-RW"); } - if(report.SCSI.MultiMediaDevice.Features.CanReadCDMRW) - { - if(!mediaTypes.Contains("CD-MRW")) mediaTypes.Add("CD-MRW"); - } + if(report.SCSI.MultiMediaDevice.Features.CanReadCDMRW) if(!mediaTypes.Contains("CD-MRW")) mediaTypes.Add("CD-MRW"); if(report.SCSI.MultiMediaDevice.Features.CanReadDDCD) { @@ -714,10 +705,7 @@ namespace DiscImageChef.Core.Devices.Report.SCSI if(!mediaTypes.Contains("DVD+R DL")) mediaTypes.Add("DVD+R DL"); } - if(report.SCSI.MultiMediaDevice.Features.CanReadDVDPlusMRW) - { - if(!mediaTypes.Contains("DVD+MRW")) mediaTypes.Add("DVD+MRW"); - } + if(report.SCSI.MultiMediaDevice.Features.CanReadDVDPlusMRW) if(!mediaTypes.Contains("DVD+MRW")) mediaTypes.Add("DVD+MRW"); if(report.SCSI.MultiMediaDevice.Features.CanReadHDDVD || report.SCSI.MultiMediaDevice.Features.CanReadHDDVDR) @@ -727,10 +715,7 @@ namespace DiscImageChef.Core.Devices.Report.SCSI if(!mediaTypes.Contains("HD DVD-RW")) mediaTypes.Add("HD DVD-RW"); } - if(report.SCSI.MultiMediaDevice.Features.CanReadHDDVDRAM) - { - if(!mediaTypes.Contains("HD DVD-RAM")) mediaTypes.Add("HD DVD-RAM"); - } + if(report.SCSI.MultiMediaDevice.Features.CanReadHDDVDRAM) if(!mediaTypes.Contains("HD DVD-RAM")) mediaTypes.Add("HD DVD-RAM"); } bool tryPlextor = false, tryHldtst = false, tryPioneer = false, tryNec = false; @@ -905,18 +890,22 @@ namespace DiscImageChef.Core.Devices.Report.SCSI !dev.ReadTocPmaAtip(out buffer, out senseBuffer, false, 0, 0, timeout, out duration); DicConsole.DebugWriteLine("SCSI Report", "Sense = {0}", !mediaTest.CanReadTOC); if(debug) + { DataFile.WriteTo("SCSI Report", "readtoc", "_debug_" + report.SCSI.Inquiry.ProductIdentification + "_" + mediaType + ".bin", "read results", buffer); + } DicConsole.WriteLine("Querying CD Full TOC..."); mediaTest.CanReadFullTOC = !dev.ReadRawToc(out buffer, out senseBuffer, 1, timeout, out duration); DicConsole.DebugWriteLine("SCSI Report", "Sense = {0}", !mediaTest.CanReadFullTOC); if(debug) + { DataFile.WriteTo("SCSI Report", "readfulltoc", "_debug_" + report.SCSI.Inquiry.ProductIdentification + "_" + mediaType + ".bin", "read results", buffer); + } } if(mediaType.StartsWith("CD-R", StringComparison.Ordinal) || @@ -928,16 +917,20 @@ namespace DiscImageChef.Core.Devices.Report.SCSI mediaTest.CanReadATIP = !dev.ReadAtip(out buffer, out senseBuffer, timeout, out duration); DicConsole.DebugWriteLine("SCSI Report", "Sense = {0}", !mediaTest.CanReadATIP); if(debug) + { DataFile.WriteTo("SCSI Report", "atip", "_debug_" + report.SCSI.Inquiry.ProductIdentification + "_" + mediaType + ".bin", "read results", buffer); + } DicConsole.WriteLine("Querying CD PMA..."); mediaTest.CanReadPMA = !dev.ReadPma(out buffer, out senseBuffer, timeout, out duration); DicConsole.DebugWriteLine("SCSI Report", "Sense = {0}", !mediaTest.CanReadPMA); if(debug) + { DataFile.WriteTo("SCSI Report", "pma", "_debug_" + report.SCSI.Inquiry.ProductIdentification + "_" + mediaType + ".bin", "read results", buffer); + } } if(mediaType.StartsWith("DVD-", StringComparison.Ordinal) || @@ -952,9 +945,11 @@ namespace DiscImageChef.Core.Devices.Report.SCSI out duration); DicConsole.DebugWriteLine("SCSI Report", "Sense = {0}", !mediaTest.CanReadPFI); if(debug) + { DataFile.WriteTo("SCSI Report", "pfi", "_debug_" + report.SCSI.Inquiry.ProductIdentification + "_" + mediaType + ".bin", "read results", buffer); + } DicConsole.WriteLine("Querying DVD DMI..."); mediaTest.CanReadDMI = !dev.ReadDiscStructure(out buffer, out senseBuffer, MmcDiscStructureMediaType.Dvd, 0, 0, @@ -962,9 +957,11 @@ namespace DiscImageChef.Core.Devices.Report.SCSI out duration); DicConsole.DebugWriteLine("SCSI Report", "Sense = {0}", !mediaTest.CanReadDMI); if(debug) + { DataFile.WriteTo("SCSI Report", "dmi", "_debug_" + report.SCSI.Inquiry.ProductIdentification + "_" + mediaType + ".bin", "read results", buffer); + } } if(mediaType == "DVD-ROM") @@ -977,9 +974,11 @@ namespace DiscImageChef.Core.Devices.Report.SCSI out duration); DicConsole.DebugWriteLine("SCSI Report", "Sense = {0}", !mediaTest.CanReadCMI); if(debug) + { DataFile.WriteTo("SCSI Report", "cmi", "_debug_" + report.SCSI.Inquiry.ProductIdentification + "_" + mediaType + ".bin", "read results", buffer); + } } if(mediaType == "DVD-ROM" || mediaType == "HD DVD-ROM") @@ -992,9 +991,11 @@ namespace DiscImageChef.Core.Devices.Report.SCSI 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 = @@ -1002,9 +1003,11 @@ namespace DiscImageChef.Core.Devices.Report.SCSI 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") @@ -1017,9 +1020,11 @@ namespace DiscImageChef.Core.Devices.Report.SCSI 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") @@ -1031,9 +1036,11 @@ namespace DiscImageChef.Core.Devices.Report.SCSI 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, @@ -1041,9 +1048,11 @@ namespace DiscImageChef.Core.Devices.Report.SCSI 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); + } } if(mediaType.StartsWith("BD-R", StringComparison.Ordinal) && mediaType != "BD-ROM") @@ -1056,9 +1065,11 @@ namespace DiscImageChef.Core.Devices.Report.SCSI MmcDiscStructureFormat.BdDds, 0, timeout, out duration); DicConsole.DebugWriteLine("SCSI Report", "Sense = {0}", !mediaTest.CanReadDDS); if(debug) + { DataFile.WriteTo("SCSI Report", "bddds", "_debug_" + report.SCSI.Inquiry.ProductIdentification + "_" + mediaType + ".bin", "read results", buffer); + } DicConsole.WriteLine("Querying BD SAI..."); mediaTest.CanReadSpareAreaInformation = !dev.ReadDiscStructure(out buffer, out senseBuffer, MmcDiscStructureMediaType.Bd, 0, 0, @@ -1067,9 +1078,11 @@ namespace DiscImageChef.Core.Devices.Report.SCSI DicConsole.DebugWriteLine("SCSI Report", "Sense = {0}", !mediaTest.CanReadSpareAreaInformation); if(debug) + { DataFile.WriteTo("SCSI Report", "bdsai", "_debug_" + report.SCSI.Inquiry.ProductIdentification + "_" + mediaType + ".bin", "read results", buffer); + } } if(mediaType == "DVD-R" || mediaType == "DVD-RW") @@ -1082,9 +1095,11 @@ namespace DiscImageChef.Core.Devices.Report.SCSI out duration); DicConsole.DebugWriteLine("SCSI Report", "Sense = {0}", !mediaTest.CanReadPRI); if(debug) + { DataFile.WriteTo("SCSI Report", "pri", "_debug_" + report.SCSI.Inquiry.ProductIdentification + "_" + mediaType + ".bin", "read results", buffer); + } } if(mediaType == "DVD-R" || mediaType == "DVD-RW" || mediaType == "HD DVD-R") @@ -1098,9 +1113,11 @@ namespace DiscImageChef.Core.Devices.Report.SCSI out duration); DicConsole.DebugWriteLine("SCSI Report", "Sense = {0}", !mediaTest.CanReadMediaID); if(debug) + { DataFile.WriteTo("SCSI Report", "mediaid", "_debug_" + report.SCSI.Inquiry.ProductIdentification + "_" + mediaType + ".bin", "read results", buffer); + } DicConsole.WriteLine("Querying DVD Embossed PFI..."); mediaTest.CanReadRecordablePFI = !dev.ReadDiscStructure(out buffer, out senseBuffer, MmcDiscStructureMediaType.Dvd, 0, 0, @@ -1108,9 +1125,11 @@ namespace DiscImageChef.Core.Devices.Report.SCSI out duration); DicConsole.DebugWriteLine("SCSI Report", "Sense = {0}", !mediaTest.CanReadRecordablePFI); if(debug) + { DataFile.WriteTo("SCSI Report", "epfi", "_debug_" + report.SCSI.Inquiry.ProductIdentification + "_" + mediaType + ".bin", "read results", buffer); + } } if(mediaType.StartsWith("DVD+R", StringComparison.Ordinal) || mediaType == "DVD+MRW") @@ -1123,18 +1142,22 @@ namespace DiscImageChef.Core.Devices.Report.SCSI MmcDiscStructureFormat.Adip, 0, timeout, out duration); DicConsole.DebugWriteLine("SCSI Report", "Sense = {0}", !mediaTest.CanReadADIP); if(debug) + { DataFile.WriteTo("SCSI Report", "adip", "_debug_" + report.SCSI.Inquiry.ProductIdentification + "_" + mediaType + ".bin", "read results", buffer); + } DicConsole.WriteLine("Querying DVD DCB..."); mediaTest.CanReadDCB = !dev.ReadDiscStructure(out buffer, out senseBuffer, MmcDiscStructureMediaType.Dvd, 0, 0, MmcDiscStructureFormat.Dcb, 0, timeout, out duration); DicConsole.DebugWriteLine("SCSI Report", "Sense = {0}", !mediaTest.CanReadDCB); if(debug) + { DataFile.WriteTo("SCSI Report", "dcb", "_debug_" + report.SCSI.Inquiry.ProductIdentification + "_" + mediaType + ".bin", "read results", buffer); + } } if(mediaType == "HD DVD-ROM") @@ -1147,9 +1170,11 @@ namespace DiscImageChef.Core.Devices.Report.SCSI out duration); DicConsole.DebugWriteLine("SCSI Report", "Sense = {0}", !mediaTest.CanReadHDCMI); if(debug) + { DataFile.WriteTo("SCSI Report", "hdcmi", "_debug_" + report.SCSI.Inquiry.ProductIdentification + "_" + mediaType + ".bin", "read results", buffer); + } } if(mediaType.EndsWith(" DL", StringComparison.Ordinal)) @@ -1162,9 +1187,11 @@ namespace DiscImageChef.Core.Devices.Report.SCSI out duration); DicConsole.DebugWriteLine("SCSI Report", "Sense = {0}", !mediaTest.CanReadLayerCapacity); if(debug) + { DataFile.WriteTo("SCSI Report", "layer", "_debug_" + report.SCSI.Inquiry.ProductIdentification + "_" + mediaType + ".bin", "read results", buffer); + } } if(mediaType.StartsWith("BD-R", StringComparison.Ordinal)) @@ -1178,18 +1205,22 @@ namespace DiscImageChef.Core.Devices.Report.SCSI out duration); DicConsole.DebugWriteLine("SCSI Report", "Sense = {0}", !mediaTest.CanReadDiscInformation); if(debug) + { DataFile.WriteTo("SCSI Report", "di", "_debug_" + report.SCSI.Inquiry.ProductIdentification + "_" + mediaType + ".bin", "read results", buffer); + } DicConsole.WriteLine("Querying BD PAC..."); mediaTest.CanReadPAC = !dev.ReadDiscStructure(out buffer, out senseBuffer, MmcDiscStructureMediaType.Bd, 0, 0, MmcDiscStructureFormat.Pac, 0, timeout, out duration); DicConsole.DebugWriteLine("SCSI Report", "Sense = {0}", !mediaTest.CanReadPAC); if(debug) + { DataFile.WriteTo("SCSI Report", "pac", "_debug_" + report.SCSI.Inquiry.ProductIdentification + "_" + mediaType + ".bin", "read results", buffer); + } } mediaTest.SupportsReadSpecified = true; @@ -1202,33 +1233,41 @@ namespace DiscImageChef.Core.Devices.Report.SCSI !dev.Read6(out buffer, out senseBuffer, 0, 2048, timeout, out duration); DicConsole.DebugWriteLine("SCSI Report", "Sense = {0}", !mediaTest.SupportsRead); if(debug) + { DataFile.WriteTo("SCSI Report", "read6", "_debug_" + report.SCSI.Inquiry.ProductIdentification + "_" + mediaType + ".bin", "read results", buffer); + } DicConsole.WriteLine("Trying SCSI READ (10)..."); mediaTest.SupportsRead10 = !dev.Read10(out buffer, out senseBuffer, 0, false, true, false, false, 0, 2048, 0, 1, timeout, out duration); DicConsole.DebugWriteLine("SCSI Report", "Sense = {0}", !mediaTest.SupportsRead10); if(debug) + { DataFile.WriteTo("SCSI Report", "read10", "_debug_" + report.SCSI.Inquiry.ProductIdentification + "_" + mediaType + ".bin", "read results", buffer); + } DicConsole.WriteLine("Trying SCSI READ (12)..."); mediaTest.SupportsRead12 = !dev.Read12(out buffer, out senseBuffer, 0, false, true, false, false, 0, 2048, 0, 1, false, timeout, out duration); DicConsole.DebugWriteLine("SCSI Report", "Sense = {0}", !mediaTest.SupportsRead12); if(debug) + { DataFile.WriteTo("SCSI Report", "read12", "_debug_" + report.SCSI.Inquiry.ProductIdentification + "_" + mediaType + ".bin", "read results", buffer); + } DicConsole.WriteLine("Trying SCSI READ (16)..."); mediaTest.SupportsRead16 = !dev.Read16(out buffer, out senseBuffer, 0, false, true, false, 0, 2048, 0, 1, false, timeout, out duration); DicConsole.DebugWriteLine("SCSI Report", "Sense = {0}", !mediaTest.SupportsRead16); if(debug) + { DataFile.WriteTo("SCSI Report", "read16", "_debug_" + report.SCSI.Inquiry.ProductIdentification + "_" + mediaType + ".bin", "read results", buffer); + } if(debug) { @@ -1274,9 +1313,11 @@ namespace DiscImageChef.Core.Devices.Report.SCSI out duration); DicConsole.DebugWriteLine("SCSI Report", "Sense = {0}", !mediaTest.SupportsReadCd); if(debug) + { DataFile.WriteTo("SCSI Report", "readcd", "_debug_" + report.SCSI.Inquiry.ProductIdentification + "_" + mediaType + ".bin", "read results", buffer); + } DicConsole.WriteLine("Trying SCSI READ CD MSF..."); mediaTest.SupportsReadCdMsf = !dev.ReadCdMsf(out buffer, out senseBuffer, 0x00000200, 0x00000201, 2352, MmcSectorTypes.Cdda, @@ -1285,9 +1326,11 @@ namespace DiscImageChef.Core.Devices.Report.SCSI MmcSubchannel.None, timeout, out duration); DicConsole.DebugWriteLine("SCSI Report", "Sense = {0}", !mediaTest.SupportsReadCdMsf); if(debug) + { DataFile.WriteTo("SCSI Report", "readcdmsf", "_debug_" + report.SCSI.Inquiry.ProductIdentification + "_" + mediaType + ".bin", "read results", buffer); + } } else { @@ -1299,9 +1342,11 @@ namespace DiscImageChef.Core.Devices.Report.SCSI out duration); DicConsole.DebugWriteLine("SCSI Report", "Sense = {0}", !mediaTest.SupportsReadCd); if(debug) + { DataFile.WriteTo("SCSI Report", "readcd", "_debug_" + report.SCSI.Inquiry.ProductIdentification + "_" + mediaType + ".bin", "read results", buffer); + } DicConsole.WriteLine("Trying SCSI READ CD MSF..."); mediaTest.SupportsReadCdMsf = !dev.ReadCdMsf(out buffer, out senseBuffer, 0x00000200, 0x00000201, 2048, MmcSectorTypes.AllTypes, @@ -1310,9 +1355,11 @@ namespace DiscImageChef.Core.Devices.Report.SCSI MmcSubchannel.None, timeout, out duration); DicConsole.DebugWriteLine("SCSI Report", "Sense = {0}", !mediaTest.SupportsReadCdMsf); if(debug) + { DataFile.WriteTo("SCSI Report", "readcdmsf", "_debug_" + report.SCSI.Inquiry.ProductIdentification + "_" + mediaType + ".bin", "read results", buffer); + } DicConsole.WriteLine("Trying SCSI READ CD full sector..."); mediaTest.SupportsReadCdRaw = !dev.ReadCd(out buffer, out senseBuffer, 0, 2352, 1, MmcSectorTypes.AllTypes, false, false, true, @@ -1321,9 +1368,11 @@ namespace DiscImageChef.Core.Devices.Report.SCSI timeout, out duration); DicConsole.DebugWriteLine("SCSI Report", "Sense = {0}", !mediaTest.SupportsReadCdRaw); if(debug) + { DataFile.WriteTo("SCSI Report", "readcdraw", "_debug_" + report.SCSI.Inquiry.ProductIdentification + "_" + mediaType + ".bin", "read results", buffer); + } DicConsole.WriteLine("Trying SCSI READ CD MSF full sector..."); mediaTest.SupportsReadCdMsfRaw = !dev.ReadCdMsf(out buffer, out senseBuffer, 0x00000200, 0x00000201, 2352, @@ -1334,9 +1383,11 @@ namespace DiscImageChef.Core.Devices.Report.SCSI DicConsole.DebugWriteLine("SCSI Report", "Sense = {0}", !mediaTest.SupportsReadCdMsfRaw); if(debug) + { DataFile.WriteTo("SCSI Report", "readcdmsfraw", "_debug_" + report.SCSI.Inquiry.ProductIdentification + "_" + mediaType + ".bin", "read results", buffer); + } } if(mediaTest.SupportsReadCdRaw || mediaType == "Audio CD") @@ -1345,20 +1396,26 @@ namespace DiscImageChef.Core.Devices.Report.SCSI for(int i = -150; i < 0; i++) { if(mediaType == "Audio CD") + { sense = dev.ReadCd(out buffer, out senseBuffer, (uint)i, 2352, 1, MmcSectorTypes.Cdda, false, false, false, MmcHeaderCodes.None, true, false, MmcErrorField.None, MmcSubchannel.None, timeout, out duration); + } else + { sense = dev.ReadCd(out buffer, out senseBuffer, (uint)i, 2352, 1, MmcSectorTypes.AllTypes, false, false, true, MmcHeaderCodes.AllHeaders, true, true, MmcErrorField.None, MmcSubchannel.None, timeout, out duration); + } DicConsole.DebugWriteLine("SCSI Report", "Sense = {0}", sense); if(debug) + { DataFile.WriteTo("SCSI Report", "leadin", "_debug_" + report.SCSI.Inquiry.ProductIdentification + "_" + mediaType + ".bin", "read results", buffer); + } if(!sense) { mediaTest.CanReadLeadIn = true; @@ -1368,24 +1425,30 @@ namespace DiscImageChef.Core.Devices.Report.SCSI DicConsole.WriteLine("Trying to read CD Lead-Out..."); if(mediaType == "Audio CD") + { mediaTest.CanReadLeadOut = !dev.ReadCd(out buffer, out senseBuffer, (uint)(mediaTest.Blocks + 1), 2352, 1, MmcSectorTypes.Cdda, false, false, false, MmcHeaderCodes.None, true, false, MmcErrorField.None, MmcSubchannel.None, timeout, out duration); + } else + { mediaTest.CanReadLeadOut = !dev.ReadCd(out buffer, out senseBuffer, (uint)(mediaTest.Blocks + 1), 2352, 1, MmcSectorTypes.AllTypes, false, false, true, MmcHeaderCodes.AllHeaders, true, true, MmcErrorField.None, MmcSubchannel.None, timeout, out duration); + } DicConsole.DebugWriteLine("SCSI Report", "Sense = {0}", !mediaTest.CanReadLeadOut); if(debug) + { DataFile.WriteTo("SCSI Report", "leadout", "_debug_" + report.SCSI.Inquiry.ProductIdentification + "_" + mediaType + ".bin", "read results", buffer); + } } if(mediaType == "Audio CD") @@ -1397,17 +1460,21 @@ namespace DiscImageChef.Core.Devices.Report.SCSI MmcErrorField.C2Pointers, MmcSubchannel.None, timeout, out duration); if(!mediaTest.CanReadC2Pointers) + { mediaTest.CanReadC2Pointers = !dev.ReadCd(out buffer, out senseBuffer, 0, 2648, 1, MmcSectorTypes.Cdda, false, false, false, MmcHeaderCodes.None, true, false, MmcErrorField.C2PointersAndBlock, MmcSubchannel.None, timeout, out duration); + } DicConsole.DebugWriteLine("SCSI Report", "Sense = {0}", !mediaTest.CanReadC2Pointers); if(debug) + { DataFile.WriteTo("SCSI Report", "readcdc2", "_debug_" + report.SCSI.Inquiry.ProductIdentification + "_" + mediaType + ".bin", "read results", buffer); + } DicConsole.WriteLine("Trying to read subchannels..."); mediaTest.CanReadPQSubchannel = !dev.ReadCd(out buffer, out senseBuffer, 0, 2368, 1, @@ -1417,9 +1484,11 @@ namespace DiscImageChef.Core.Devices.Report.SCSI timeout, out duration); DicConsole.DebugWriteLine("SCSI Report", "Sense = {0}", !mediaTest.CanReadPQSubchannel); if(debug) + { DataFile.WriteTo("SCSI Report", "readcdpq", "_debug_" + report.SCSI.Inquiry.ProductIdentification + "_" + mediaType + ".bin", "read results", buffer); + } mediaTest.CanReadRWSubchannel = !dev.ReadCd(out buffer, out senseBuffer, 0, 2448, 1, MmcSectorTypes.Cdda, false, false, false, MmcHeaderCodes.None, true, false, @@ -1427,9 +1496,11 @@ namespace DiscImageChef.Core.Devices.Report.SCSI timeout, out duration); DicConsole.DebugWriteLine("SCSI Report", "Sense = {0}", !mediaTest.CanReadRWSubchannel); if(debug) + { DataFile.WriteTo("SCSI Report", "readcdrw", "_debug_" + report.SCSI.Inquiry.ProductIdentification + "_" + mediaType + ".bin", "read results", buffer); + } mediaTest.CanReadCorrectedSubchannel = !dev.ReadCd(out buffer, out senseBuffer, 0, 2448, 1, MmcSectorTypes.Cdda, false, false, false, MmcHeaderCodes.None, true, @@ -1439,9 +1510,11 @@ namespace DiscImageChef.Core.Devices.Report.SCSI DicConsole.DebugWriteLine("SCSI Report", "Sense = {0}", !mediaTest.CanReadCorrectedSubchannel); if(debug) + { DataFile.WriteTo("SCSI Report", "readcdsub", "_debug_" + report.SCSI.Inquiry.ProductIdentification + "_" + mediaType + ".bin", "read results", buffer); + } DicConsole.WriteLine("Trying to read subchannels with C2 Pointers..."); mediaTest.CanReadPQSubchannelWithC2 = !dev.ReadCd(out buffer, out senseBuffer, 0, 2662, @@ -1451,6 +1524,7 @@ namespace DiscImageChef.Core.Devices.Report.SCSI MmcSubchannel.Q16, timeout, out duration); if(!mediaTest.CanReadPQSubchannelWithC2) + { mediaTest.CanReadPQSubchannelWithC2 = !dev.ReadCd(out buffer, out senseBuffer, 0, 2664, 1, MmcSectorTypes.Cdda, false, false, false, @@ -1458,12 +1532,15 @@ namespace DiscImageChef.Core.Devices.Report.SCSI MmcErrorField.C2PointersAndBlock, MmcSubchannel.Q16, timeout, out duration); + } DicConsole.DebugWriteLine("SCSI Report", "Sense = {0}", !mediaTest.CanReadPQSubchannelWithC2); if(debug) + { DataFile.WriteTo("SCSI Report", "readcdpqc2", "_debug_" + report.SCSI.Inquiry.ProductIdentification + "_" + mediaType + ".bin", "read results", buffer); + } mediaTest.CanReadRWSubchannelWithC2 = !dev.ReadCd(out buffer, out senseBuffer, 0, 2712, 1, MmcSectorTypes.Cdda, false, false, @@ -1472,6 +1549,7 @@ namespace DiscImageChef.Core.Devices.Report.SCSI MmcSubchannel.Raw, timeout, out duration); if(!mediaTest.CanReadRWSubchannelWithC2) + { mediaTest.CanReadRWSubchannelWithC2 = !dev.ReadCd(out buffer, out senseBuffer, 0, 2714, 1, MmcSectorTypes.Cdda, false, false, false, @@ -1479,12 +1557,15 @@ namespace DiscImageChef.Core.Devices.Report.SCSI MmcErrorField.C2PointersAndBlock, MmcSubchannel.Raw, timeout, out duration); + } DicConsole.DebugWriteLine("SCSI Report", "Sense = {0}", !mediaTest.CanReadRWSubchannelWithC2); if(debug) + { DataFile.WriteTo("SCSI Report", "readcdrwc2", "_debug_" + report.SCSI.Inquiry.ProductIdentification + "_" + mediaType + ".bin", "read results", buffer); + } mediaTest.CanReadCorrectedSubchannelWithC2 = !dev.ReadCd(out buffer, out senseBuffer, 0, 2712, 1, MmcSectorTypes.Cdda, @@ -1495,17 +1576,21 @@ namespace DiscImageChef.Core.Devices.Report.SCSI MmcSubchannel.Rw, timeout, out duration); if(!mediaTest.CanReadCorrectedSubchannelWithC2) + { mediaTest.CanReadCorrectedSubchannelWithC2 = !dev.ReadCd(out buffer, out senseBuffer, 0, 2714, 1, MmcSectorTypes.Cdda, false, false, false, MmcHeaderCodes.None, true, false, MmcErrorField.C2PointersAndBlock, MmcSubchannel.Rw, timeout, out duration); + } DicConsole.DebugWriteLine("SCSI Report", "Sense = {0}", !mediaTest.CanReadCorrectedSubchannelWithC2); if(debug) + { DataFile.WriteTo("SCSI Report", "readcdsubc2", "_debug_" + report.SCSI.Inquiry.ProductIdentification + "_" + mediaType + ".bin", "read results", buffer); + } } else if(mediaTest.SupportsReadCdRaw) { @@ -1516,17 +1601,21 @@ namespace DiscImageChef.Core.Devices.Report.SCSI MmcErrorField.C2Pointers, MmcSubchannel.None, timeout, out duration); if(!mediaTest.CanReadC2Pointers) + { mediaTest.CanReadC2Pointers = !dev.ReadCd(out buffer, out senseBuffer, 0, 2648, 1, MmcSectorTypes.AllTypes, false, false, true, MmcHeaderCodes.AllHeaders, true, true, MmcErrorField.C2PointersAndBlock, MmcSubchannel.None, timeout, out duration); + } DicConsole.DebugWriteLine("SCSI Report", "Sense = {0}", !mediaTest.CanReadC2Pointers); if(debug) + { DataFile.WriteTo("SCSI Report", "readcdc2", "_debug_" + report.SCSI.Inquiry.ProductIdentification + "_" + mediaType + ".bin", "read results", buffer); + } DicConsole.WriteLine("Trying to read subchannels..."); mediaTest.CanReadPQSubchannel = !dev.ReadCd(out buffer, out senseBuffer, 0, 2368, 1, @@ -1536,9 +1625,11 @@ namespace DiscImageChef.Core.Devices.Report.SCSI timeout, out duration); DicConsole.DebugWriteLine("SCSI Report", "Sense = {0}", !mediaTest.CanReadPQSubchannel); if(debug) + { DataFile.WriteTo("SCSI Report", "readcdpq", "_debug_" + report.SCSI.Inquiry.ProductIdentification + "_" + mediaType + ".bin", "read results", buffer); + } mediaTest.CanReadRWSubchannel = !dev.ReadCd(out buffer, out senseBuffer, 0, 2448, 1, MmcSectorTypes.AllTypes, false, false, true, MmcHeaderCodes.AllHeaders, true, true, @@ -1546,9 +1637,11 @@ namespace DiscImageChef.Core.Devices.Report.SCSI timeout, out duration); DicConsole.DebugWriteLine("SCSI Report", "Sense = {0}", !mediaTest.CanReadRWSubchannel); if(debug) + { DataFile.WriteTo("SCSI Report", "readcdrw", "_debug_" + report.SCSI.Inquiry.ProductIdentification + "_" + mediaType + ".bin", "read results", buffer); + } mediaTest.CanReadCorrectedSubchannel = !dev.ReadCd(out buffer, out senseBuffer, 0, 2448, 1, MmcSectorTypes.AllTypes, false, false, true, @@ -1559,9 +1652,11 @@ namespace DiscImageChef.Core.Devices.Report.SCSI DicConsole.DebugWriteLine("SCSI Report", "Sense = {0}", !mediaTest.CanReadCorrectedSubchannel); if(debug) + { DataFile.WriteTo("SCSI Report", "readcdsub", "_debug_" + report.SCSI.Inquiry.ProductIdentification + "_" + mediaType + ".bin", "read results", buffer); + } DicConsole.WriteLine("Trying to read subchannels with C2 Pointers..."); mediaTest.CanReadPQSubchannelWithC2 = !dev.ReadCd(out buffer, out senseBuffer, 0, 2662, @@ -1572,6 +1667,7 @@ namespace DiscImageChef.Core.Devices.Report.SCSI MmcSubchannel.Q16, timeout, out duration); if(!mediaTest.CanReadPQSubchannelWithC2) + { mediaTest.CanReadPQSubchannelWithC2 = !dev.ReadCd(out buffer, out senseBuffer, 0, 2664, 1, MmcSectorTypes.AllTypes, false, false, true, @@ -1580,12 +1676,15 @@ namespace DiscImageChef.Core.Devices.Report.SCSI MmcErrorField.C2PointersAndBlock, MmcSubchannel.Q16, timeout, out duration); + } DicConsole.DebugWriteLine("SCSI Report", "Sense = {0}", !mediaTest.CanReadPQSubchannelWithC2); if(debug) + { DataFile.WriteTo("SCSI Report", "readcdpqc2", "_debug_" + report.SCSI.Inquiry.ProductIdentification + "_" + mediaType + ".bin", "read results", buffer); + } mediaTest.CanReadRWSubchannelWithC2 = !dev.ReadCd(out buffer, out senseBuffer, 0, 2712, 1, MmcSectorTypes.AllTypes, false, @@ -1595,6 +1694,7 @@ namespace DiscImageChef.Core.Devices.Report.SCSI MmcSubchannel.Raw, timeout, out duration); if(!mediaTest.CanReadRWSubchannelWithC2) + { mediaTest.CanReadRWSubchannelWithC2 = !dev.ReadCd(out buffer, out senseBuffer, 0, 2714, 1, MmcSectorTypes.AllTypes, false, false, true, @@ -1603,12 +1703,15 @@ namespace DiscImageChef.Core.Devices.Report.SCSI MmcErrorField.C2PointersAndBlock, MmcSubchannel.Raw, timeout, out duration); + } DicConsole.DebugWriteLine("SCSI Report", "Sense = {0}", !mediaTest.CanReadRWSubchannelWithC2); if(debug) + { DataFile.WriteTo("SCSI Report", "readcdrwc2", "_debug_" + report.SCSI.Inquiry.ProductIdentification + "_" + mediaType + ".bin", "read results", buffer); + } mediaTest.CanReadCorrectedSubchannelWithC2 = !dev.ReadCd(out buffer, out senseBuffer, 0, 2712, 1, @@ -1620,17 +1723,21 @@ namespace DiscImageChef.Core.Devices.Report.SCSI MmcSubchannel.Rw, timeout, out duration); if(!mediaTest.CanReadCorrectedSubchannelWithC2) + { mediaTest.CanReadCorrectedSubchannelWithC2 = !dev.ReadCd(out buffer, out senseBuffer, 0, 2714, 1, MmcSectorTypes.AllTypes, false, false, true, MmcHeaderCodes.AllHeaders, true, true, MmcErrorField.C2PointersAndBlock, MmcSubchannel.Rw, timeout, out duration); + } DicConsole.DebugWriteLine("SCSI Report", "Sense = {0}", !mediaTest.CanReadCorrectedSubchannelWithC2); if(debug) + { DataFile.WriteTo("SCSI Report", "readcdsubc2", "_debug_" + report.SCSI.Inquiry.ProductIdentification + "_" + mediaType + ".bin", "read results", buffer); + } } else { @@ -1641,17 +1748,21 @@ namespace DiscImageChef.Core.Devices.Report.SCSI MmcErrorField.C2Pointers, MmcSubchannel.None, timeout, out duration); if(!mediaTest.CanReadC2Pointers) + { mediaTest.CanReadC2Pointers = !dev.ReadCd(out buffer, out senseBuffer, 0, 2344, 1, MmcSectorTypes.AllTypes, false, false, false, MmcHeaderCodes.None, true, false, MmcErrorField.C2PointersAndBlock, MmcSubchannel.None, timeout, out duration); + } DicConsole.DebugWriteLine("SCSI Report", "Sense = {0}", !mediaTest.CanReadC2Pointers); if(debug) + { DataFile.WriteTo("SCSI Report", "readcdc2", "_debug_" + report.SCSI.Inquiry.ProductIdentification + "_" + mediaType + ".bin", "read results", buffer); + } DicConsole.WriteLine("Trying to read subchannels..."); mediaTest.CanReadPQSubchannel = !dev.ReadCd(out buffer, out senseBuffer, 0, 2064, 1, @@ -1661,9 +1772,11 @@ namespace DiscImageChef.Core.Devices.Report.SCSI timeout, out duration); DicConsole.DebugWriteLine("SCSI Report", "Sense = {0}", !mediaTest.CanReadPQSubchannel); if(debug) + { DataFile.WriteTo("SCSI Report", "readcdpq", "_debug_" + report.SCSI.Inquiry.ProductIdentification + "_" + mediaType + ".bin", "read results", buffer); + } mediaTest.CanReadRWSubchannel = !dev.ReadCd(out buffer, out senseBuffer, 0, 2144, 1, MmcSectorTypes.AllTypes, false, false, false, MmcHeaderCodes.None, true, false, @@ -1671,9 +1784,11 @@ namespace DiscImageChef.Core.Devices.Report.SCSI timeout, out duration); DicConsole.DebugWriteLine("SCSI Report", "Sense = {0}", !mediaTest.CanReadRWSubchannel); if(debug) + { DataFile.WriteTo("SCSI Report", "readcdrw", "_debug_" + report.SCSI.Inquiry.ProductIdentification + "_" + mediaType + ".bin", "read results", buffer); + } mediaTest.CanReadCorrectedSubchannel = !dev.ReadCd(out buffer, out senseBuffer, 0, 2144, 1, MmcSectorTypes.AllTypes, false, false, false, MmcHeaderCodes.None, @@ -1683,9 +1798,11 @@ namespace DiscImageChef.Core.Devices.Report.SCSI DicConsole.DebugWriteLine("SCSI Report", "Sense = {0}", !mediaTest.CanReadCorrectedSubchannel); if(debug) + { DataFile.WriteTo("SCSI Report", "readcdsub", "_debug_" + report.SCSI.Inquiry.ProductIdentification + "_" + mediaType + ".bin", "read results", buffer); + } DicConsole.WriteLine("Trying to read subchannels with C2 Pointers..."); mediaTest.CanReadPQSubchannelWithC2 = !dev.ReadCd(out buffer, out senseBuffer, 0, 2358, @@ -1695,6 +1812,7 @@ namespace DiscImageChef.Core.Devices.Report.SCSI MmcSubchannel.Q16, timeout, out duration); if(!mediaTest.CanReadPQSubchannelWithC2) + { mediaTest.CanReadPQSubchannelWithC2 = !dev.ReadCd(out buffer, out senseBuffer, 0, 2360, 1, MmcSectorTypes.AllTypes, false, false, false, @@ -1702,12 +1820,15 @@ namespace DiscImageChef.Core.Devices.Report.SCSI MmcErrorField.C2PointersAndBlock, MmcSubchannel.Q16, timeout, out duration); + } DicConsole.DebugWriteLine("SCSI Report", "Sense = {0}", !mediaTest.CanReadPQSubchannelWithC2); if(debug) + { DataFile.WriteTo("SCSI Report", "readcdpqc2", "_debug_" + report.SCSI.Inquiry.ProductIdentification + "_" + mediaType + ".bin", "read results", buffer); + } mediaTest.CanReadRWSubchannelWithC2 = !dev.ReadCd(out buffer, out senseBuffer, 0, 2438, 1, MmcSectorTypes.AllTypes, false, @@ -1716,6 +1837,7 @@ namespace DiscImageChef.Core.Devices.Report.SCSI MmcSubchannel.Raw, timeout, out duration); if(!mediaTest.CanReadRWSubchannelWithC2) + { mediaTest.CanReadRWSubchannelWithC2 = !dev.ReadCd(out buffer, out senseBuffer, 0, 2440, 1, MmcSectorTypes.AllTypes, false, false, false, @@ -1723,12 +1845,15 @@ namespace DiscImageChef.Core.Devices.Report.SCSI MmcErrorField.C2PointersAndBlock, MmcSubchannel.Raw, timeout, out duration); + } DicConsole.DebugWriteLine("SCSI Report", "Sense = {0}", !mediaTest.CanReadRWSubchannelWithC2); if(debug) + { DataFile.WriteTo("SCSI Report", "readcdrwc2", "_debug_" + report.SCSI.Inquiry.ProductIdentification + "_" + mediaType + ".bin", "read results", buffer); + } mediaTest.CanReadCorrectedSubchannelWithC2 = !dev.ReadCd(out buffer, out senseBuffer, 0, 2438, 1, @@ -1740,17 +1865,21 @@ namespace DiscImageChef.Core.Devices.Report.SCSI MmcSubchannel.Rw, timeout, out duration); if(!mediaTest.CanReadCorrectedSubchannelWithC2) + { mediaTest.CanReadCorrectedSubchannelWithC2 = !dev.ReadCd(out buffer, out senseBuffer, 0, 2440, 1, MmcSectorTypes.AllTypes, false, false, false, MmcHeaderCodes.None, true, false, MmcErrorField.C2PointersAndBlock, MmcSubchannel.Rw, timeout, out duration); + } DicConsole.DebugWriteLine("SCSI Report", "Sense = {0}", !mediaTest.CanReadCorrectedSubchannelWithC2); if(debug) + { DataFile.WriteTo("SCSI Report", "readcdsubc2", "_debug_" + report.SCSI.Inquiry.ProductIdentification + "_" + mediaType + ".bin", "read results", buffer); + } } if(debug) @@ -1794,9 +1923,11 @@ namespace DiscImageChef.Core.Devices.Report.SCSI DicConsole.DebugWriteLine("SCSI Report", "Sense = {0}", !mediaTest.SupportsPlextorReadCDDA); if(debug) + { DataFile.WriteTo("SCSI Report", "plextorreadcdda", "_debug_" + report.SCSI.Inquiry.ProductIdentification + "_" + mediaType + ".bin", "read results", buffer); + } } if(tryPioneer) @@ -1810,9 +1941,11 @@ namespace DiscImageChef.Core.Devices.Report.SCSI DicConsole.DebugWriteLine("SCSI Report", "Sense = {0}", !mediaTest.SupportsPioneerReadCDDA); if(debug) + { DataFile.WriteTo("SCSI Report", "pioneerreadcdda", "_debug_" + report.SCSI.Inquiry.ProductIdentification + "_" + mediaType + ".bin", "read results", buffer); + } DicConsole.WriteLine("Trying Pioneer READ CD-DA MSF..."); mediaTest.SupportsPioneerReadCDDAMSF = !dev.PioneerReadCdDaMsf(out buffer, out senseBuffer, 0x00000200, 0x00000201, 2352, @@ -1820,9 +1953,11 @@ namespace DiscImageChef.Core.Devices.Report.SCSI DicConsole.DebugWriteLine("SCSI Report", "Sense = {0}", !mediaTest.SupportsPioneerReadCDDAMSF); if(debug) + { DataFile.WriteTo("SCSI Report", "pioneerreadcddamsf", "_debug_" + report.SCSI.Inquiry.ProductIdentification + "_" + mediaType + ".bin", "read results", buffer); + } } if(tryNec) @@ -1833,9 +1968,11 @@ namespace DiscImageChef.Core.Devices.Report.SCSI !dev.NecReadCdDa(out buffer, out senseBuffer, 0, 1, timeout, out duration); DicConsole.DebugWriteLine("SCSI Report", "Sense = {0}", !mediaTest.SupportsNECReadCDDA); if(debug) + { DataFile.WriteTo("SCSI Report", "necreadcdda", "_debug_" + report.SCSI.Inquiry.ProductIdentification + "_" + mediaType + ".bin", "read results", buffer); + } } } @@ -1900,9 +2037,11 @@ namespace DiscImageChef.Core.Devices.Report.SCSI DicConsole.DebugWriteLine("SCSI Report", "Sense = {0}", !mediaTest.SupportsPlextorReadRawDVD); if(debug) + { DataFile.WriteTo("SCSI Report", "plextorrawdvd", "_debug_" + report.SCSI.Inquiry.ProductIdentification + "_" + mediaType + ".bin", "read results", buffer); + } if(mediaTest.SupportsPlextorReadRawDVD) mediaTest.SupportsPlextorReadRawDVD = !ArrayHelpers.ArrayIsNullOrEmpty(buffer); } @@ -1916,9 +2055,11 @@ namespace DiscImageChef.Core.Devices.Report.SCSI DicConsole.DebugWriteLine("SCSI Report", "Sense = {0}", !mediaTest.SupportsHLDTSTReadRawDVD); if(debug) + { DataFile.WriteTo("SCSI Report", "hldtstrawdvd", "_debug_" + report.SCSI.Inquiry.ProductIdentification + "_" + mediaType + ".bin", "read results", buffer); + } } if(mediaTest.SupportsReadLong && mediaTest.LongBlockSize == mediaTest.BlockSize) @@ -1967,9 +2108,11 @@ namespace DiscImageChef.Core.Devices.Report.SCSI sense = dev.ReadLong10(out buffer, out senseBuffer, false, false, 0, (ushort)mediaTest.LongBlockSize, timeout, out duration); if(!sense) + { DataFile.WriteTo("SCSI Report", "readlong10", "_debug_" + report.SCSI.Inquiry.ProductIdentification + "_" + mediaType + ".bin", "read results", buffer); + } } } diff --git a/DiscImageChef.Core/Devices/Report/SCSI/SSC.cs b/DiscImageChef.Core/Devices/Report/SCSI/SSC.cs index a49c51971..cd049ee73 100644 --- a/DiscImageChef.Core/Devices/Report/SCSI/SSC.cs +++ b/DiscImageChef.Core/Devices/Report/SCSI/SSC.cs @@ -138,8 +138,10 @@ namespace DiscImageChef.Core.Devices.Report.SCSI report.SCSI.SequentialDevice.SupportedMediaTypes[i].DensityCodes = new int[mtsh.Value.descriptors[i].densityCodes.Length]; for(int j = 0; j < mtsh.Value.descriptors.Length; j++) + { report.SCSI.SequentialDevice.SupportedMediaTypes[i].DensityCodes[j] = mtsh.Value.descriptors[i].densityCodes[j]; + } } } } @@ -300,8 +302,10 @@ namespace DiscImageChef.Core.Devices.Report.SCSI seqTest.SupportedMediaTypes[i].DensityCodes = new int[mtsh.Value.descriptors[i].densityCodes.Length]; for(int j = 0; j < mtsh.Value.descriptors.Length; j++) + { seqTest.SupportedMediaTypes[i].DensityCodes[j] = mtsh.Value.descriptors[i].densityCodes[j]; + } } } } diff --git a/DiscImageChef.Core/Devices/Scanning/ATA.cs b/DiscImageChef.Core/Devices/Scanning/ATA.cs index f688f4db7..b323a77aa 100644 --- a/DiscImageChef.Core/Devices/Scanning/ATA.cs +++ b/DiscImageChef.Core/Devices/Scanning/ATA.cs @@ -145,12 +145,12 @@ namespace DiscImageChef.Core.Devices.Scanning if(!error) { - if(duration >= 500) { results.F += blocksToRead; } - else if(duration >= 150) { results.E += blocksToRead; } - else if(duration >= 50) { results.D += blocksToRead; } - else if(duration >= 10) { results.C += blocksToRead; } - else if(duration >= 3) { results.B += blocksToRead; } - else { results.A += blocksToRead; } + if(duration >= 500) results.F += blocksToRead; + else if(duration >= 150) results.E += blocksToRead; + else if(duration >= 50) results.D += blocksToRead; + else if(duration >= 10) results.C += blocksToRead; + else if(duration >= 3) results.B += blocksToRead; + else results.A += blocksToRead; mhddLog.Write(i, duration); ibgLog.Write(i, currentSpeed * 1024); @@ -182,7 +182,6 @@ namespace DiscImageChef.Core.Devices.Scanning #pragma warning restore IDE0004 // Without this specific cast, it gives incorrect values if(ataReader.CanSeekLba) - { for(int i = 0; i < SEEK_TIMES; i++) { if(aborted) break; @@ -201,7 +200,6 @@ namespace DiscImageChef.Core.Devices.Scanning results.SeekTotal += seekCur; GC.Collect(); } - } } else { @@ -233,12 +231,12 @@ namespace DiscImageChef.Core.Devices.Scanning if(!error) { - if(duration >= 500) { results.F += blocksToRead; } - else if(duration >= 150) { results.E += blocksToRead; } - else if(duration >= 50) { results.D += blocksToRead; } - else if(duration >= 10) { results.C += blocksToRead; } - else if(duration >= 3) { results.B += blocksToRead; } - else { results.A += blocksToRead; } + if(duration >= 500) results.F += blocksToRead; + else if(duration >= 150) results.E += blocksToRead; + else if(duration >= 50) results.D += blocksToRead; + else if(duration >= 10) results.C += blocksToRead; + else if(duration >= 3) results.B += blocksToRead; + else results.A += blocksToRead; mhddLog.Write(currentBlock, duration); ibgLog.Write(currentBlock, currentSpeed * 1024); @@ -273,7 +271,6 @@ namespace DiscImageChef.Core.Devices.Scanning #pragma warning restore IDE0004 // Without this specific cast, it gives incorrect values if(ataReader.CanSeek) - { for(int i = 0; i < SEEK_TIMES; i++) { if(aborted) break; @@ -295,7 +292,6 @@ namespace DiscImageChef.Core.Devices.Scanning results.SeekTotal += seekCur; GC.Collect(); } - } } DicConsole.WriteLine(); diff --git a/DiscImageChef.Core/Devices/Scanning/SCSI.cs b/DiscImageChef.Core/Devices/Scanning/SCSI.cs index bcbb378d6..893fa909f 100644 --- a/DiscImageChef.Core/Devices/Scanning/SCSI.cs +++ b/DiscImageChef.Core/Devices/Scanning/SCSI.cs @@ -61,7 +61,6 @@ namespace DiscImageChef.Core.Devices.Scanning { Decoders.SCSI.FixedSense? decSense = Decoders.SCSI.Sense.DecodeFixed(senseBuf); if(decSense.HasValue) - { if(decSense.Value.ASC == 0x3A) { int leftRetries = 5; @@ -128,7 +127,6 @@ namespace DiscImageChef.Core.Devices.Scanning Decoders.SCSI.Sense.PrettifySense(senseBuf)); return results; } - } else { DicConsole.ErrorWriteLine("Unknown testing unit was ready."); @@ -307,12 +305,12 @@ namespace DiscImageChef.Core.Devices.Scanning if(!sense) { - if(cmdDuration >= 500) { results.F += blocksToRead; } - else if(cmdDuration >= 150) { results.E += blocksToRead; } - else if(cmdDuration >= 50) { results.D += blocksToRead; } - else if(cmdDuration >= 10) { results.C += blocksToRead; } - else if(cmdDuration >= 3) { results.B += blocksToRead; } - else { results.A += blocksToRead; } + if(cmdDuration >= 500) results.F += blocksToRead; + else if(cmdDuration >= 150) results.E += blocksToRead; + else if(cmdDuration >= 50) results.D += blocksToRead; + else if(cmdDuration >= 10) results.C += blocksToRead; + else if(cmdDuration >= 3) results.B += blocksToRead; + else results.A += blocksToRead; mhddLog.Write(i, cmdDuration); ibgLog.Write(i, currentSpeed * 1024); diff --git a/DiscImageChef.Core/Devices/Scanning/SecureDigital.cs b/DiscImageChef.Core/Devices/Scanning/SecureDigital.cs index 5e346e3cb..9b5b69ccf 100644 --- a/DiscImageChef.Core/Devices/Scanning/SecureDigital.cs +++ b/DiscImageChef.Core/Devices/Scanning/SecureDigital.cs @@ -179,12 +179,12 @@ namespace DiscImageChef.Core.Devices.Scanning if(!error) { - if(duration >= 500) { results.F += blocksToRead; } - else if(duration >= 150) { results.E += blocksToRead; } - else if(duration >= 50) { results.D += blocksToRead; } - else if(duration >= 10) { results.C += blocksToRead; } - else if(duration >= 3) { results.B += blocksToRead; } - else { results.A += blocksToRead; } + if(duration >= 500) results.F += blocksToRead; + else if(duration >= 150) results.E += blocksToRead; + else if(duration >= 50) results.D += blocksToRead; + else if(duration >= 10) results.C += blocksToRead; + else if(duration >= 3) results.B += blocksToRead; + else results.A += blocksToRead; mhddLog.Write(i, duration); ibgLog.Write(i, currentSpeed * 1024); diff --git a/DiscImageChef.Core/Filesystems.cs b/DiscImageChef.Core/Filesystems.cs index 371ced3f7..56a8b5456 100644 --- a/DiscImageChef.Core/Filesystems.cs +++ b/DiscImageChef.Core/Filesystems.cs @@ -45,10 +45,7 @@ namespace DiscImageChef.Core PluginBase plugins = new PluginBase(); plugins.RegisterAllPlugins(); - foreach(Filesystem plugin in plugins.PluginsList.Values) - { - if(plugin.Identify(imagePlugin, partition)) idPlugins.Add(plugin.Name.ToLower()); - } + foreach(Filesystem plugin in plugins.PluginsList.Values) if(plugin.Identify(imagePlugin, partition)) idPlugins.Add(plugin.Name.ToLower()); } } } \ No newline at end of file diff --git a/DiscImageChef.Core/ImageFormat.cs b/DiscImageChef.Core/ImageFormat.cs index c69892e59..81a9d48f4 100644 --- a/DiscImageChef.Core/ImageFormat.cs +++ b/DiscImageChef.Core/ImageFormat.cs @@ -93,7 +93,7 @@ namespace DiscImageChef.Core } // Still not recognized - if(imageFormat == null) { return null; } + if(imageFormat == null) return null; return imageFormat; } diff --git a/DiscImageChef.Core/Partitions.cs b/DiscImageChef.Core/Partitions.cs index b0fc3b7fd..0090f675e 100644 --- a/DiscImageChef.Core/Partitions.cs +++ b/DiscImageChef.Core/Partitions.cs @@ -135,10 +135,7 @@ namespace DiscImageChef.Core foreach(Partition detectedPartition in childPartitions) startLocations.Add(detectedPartition.Start); - foreach(Partition imagePartition in image.GetPartitions()) - { - if(!startLocations.Contains(imagePartition.Start)) childPartitions.Add(imagePartition); - } + foreach(Partition imagePartition in image.GetPartitions()) if(!startLocations.Contains(imagePartition.Start)) childPartitions.Add(imagePartition); } Partition[] childArray = childPartitions @@ -155,7 +152,7 @@ namespace DiscImageChef.Core List schemes = new List(); - foreach(Partition part in partitions) { if(!schemes.Contains(part.Scheme)) schemes.Add(part.Scheme); } + foreach(Partition part in partitions) if(!schemes.Contains(part.Scheme)) schemes.Add(part.Scheme); foreach(string scheme in schemes) Statistics.AddPartition(scheme); } diff --git a/DiscImageChef.Core/PluginBase.cs b/DiscImageChef.Core/PluginBase.cs index 3225ac8b5..d3dcbb81d 100644 --- a/DiscImageChef.Core/PluginBase.cs +++ b/DiscImageChef.Core/PluginBase.cs @@ -98,8 +98,10 @@ namespace DiscImageChef.Core { Filesystem plugin; if(encoding != null) + { plugin = (Filesystem)type.GetConstructor(new Type[] {encoding.GetType()}) .Invoke(new object[] {encoding}); + } else plugin = (Filesystem)type.GetConstructor(Type.EmptyTypes).Invoke(new object[] { }); RegisterPlugin(plugin); } @@ -110,23 +112,17 @@ namespace DiscImageChef.Core void RegisterImagePlugin(ImagePlugin plugin) { - if(!ImagePluginsList.ContainsKey(plugin.Name.ToLower())) - { - ImagePluginsList.Add(plugin.Name.ToLower(), plugin); - } + if(!ImagePluginsList.ContainsKey(plugin.Name.ToLower())) ImagePluginsList.Add(plugin.Name.ToLower(), plugin); } void RegisterPlugin(Filesystem plugin) { - if(!PluginsList.ContainsKey(plugin.Name.ToLower())) { PluginsList.Add(plugin.Name.ToLower(), plugin); } + if(!PluginsList.ContainsKey(plugin.Name.ToLower())) PluginsList.Add(plugin.Name.ToLower(), plugin); } void RegisterPartPlugin(PartitionPlugin partplugin) { - if(!PartPluginsList.ContainsKey(partplugin.Name.ToLower())) - { - PartPluginsList.Add(partplugin.Name.ToLower(), partplugin); - } + if(!PartPluginsList.ContainsKey(partplugin.Name.ToLower())) PartPluginsList.Add(partplugin.Name.ToLower(), partplugin); } } } \ No newline at end of file diff --git a/DiscImageChef.Core/Sidecar/BlockMedia.cs b/DiscImageChef.Core/Sidecar/BlockMedia.cs index 0c7550269..570badfab 100644 --- a/DiscImageChef.Core/Sidecar/BlockMedia.cs +++ b/DiscImageChef.Core/Sidecar/BlockMedia.cs @@ -234,10 +234,7 @@ namespace DiscImageChef.Core // If there is only one track, and it's the same as the image file (e.g. ".iso" files), don't re-checksum. if(image.PluginUuid == new System.Guid("12345678-AAAA-BBBB-CCCC-123456789000") && - filterId == new System.Guid("12345678-AAAA-BBBB-CCCC-123456789000")) - { - sidecar.BlockMedia[0].ContentChecksums = sidecar.BlockMedia[0].Checksums; - } + filterId == new System.Guid("12345678-AAAA-BBBB-CCCC-123456789000")) sidecar.BlockMedia[0].ContentChecksums = sidecar.BlockMedia[0].Checksums; else { Checksum contentChkWorker = new Checksum(); @@ -593,14 +590,18 @@ namespace DiscImageChef.Core scpBlockTrackTypes.OrderBy(t => t.Cylinder).ThenBy(t => t.Head).ToArray(); } else + { DicConsole .ErrorWriteLine("SuperCardPro image do not contain same number of tracks ({0}) than disk image ({1}), ignoring...", scpImage.Header.end + 1, image.ImageInfo.Cylinders); + } } else + { DicConsole .ErrorWriteLine("SuperCardPro image do not contain same number of heads ({0}) than disk image ({1}), ignoring...", 2, image.ImageInfo.Heads); + } } } #endregion @@ -679,14 +680,18 @@ namespace DiscImageChef.Core kfBlockTrackTypes.OrderBy(t => t.Cylinder).ThenBy(t => t.Head).ToArray(); } else + { DicConsole .ErrorWriteLine("KryoFlux image do not contain same number of tracks ({0}) than disk image ({1}), ignoring...", kfImage.ImageInfo.Cylinders, image.ImageInfo.Cylinders); + } } else + { DicConsole .ErrorWriteLine("KryoFluximage do not contain same number of heads ({0}) than disk image ({1}), ignoring...", kfImage.ImageInfo.Heads, image.ImageInfo.Heads); + } } } #endregion @@ -751,14 +756,18 @@ namespace DiscImageChef.Core dfiBlockTrackTypes.OrderBy(t => t.Cylinder).ThenBy(t => t.Head).ToArray(); } else + { DicConsole .ErrorWriteLine("DiscFerret image do not contain same number of tracks ({0}) than disk image ({1}), ignoring...", dfiImage.ImageInfo.Cylinders, image.ImageInfo.Cylinders); + } } else + { DicConsole .ErrorWriteLine("DiscFerret image do not contain same number of heads ({0}) than disk image ({1}), ignoring...", dfiImage.ImageInfo.Heads, image.ImageInfo.Heads); + } } } #endregion diff --git a/DiscImageChef.Core/Sidecar/OpticalDisc.cs b/DiscImageChef.Core/Sidecar/OpticalDisc.cs index 4c7d44b3d..11b7b1076 100644 --- a/DiscImageChef.Core/Sidecar/OpticalDisc.cs +++ b/DiscImageChef.Core/Sidecar/OpticalDisc.cs @@ -75,7 +75,6 @@ namespace DiscImageChef.Core MediaType dskType = image.ImageInfo.MediaType; foreach(MediaTagType tagType in image.ImageInfo.ReadableMediaTags) - { switch(tagType) { case MediaTagType.CD_ATIP: @@ -87,10 +86,8 @@ namespace DiscImageChef.Core Decoders.CD.ATIP.CDATIP? atip = Decoders.CD.ATIP.Decode(image.ReadDiskTag(MediaTagType.CD_ATIP)); if(atip.HasValue) - { if(atip.Value.DDCD) dskType = atip.Value.DiscType ? MediaType.DDCDRW : MediaType.DDCDR; else dskType = atip.Value.DiscType ? MediaType.CDRW : MediaType.CDR; - } break; case MediaTagType.DVD_BCA: sidecar.OpticalDisc[0].BCA = new DumpType @@ -115,7 +112,6 @@ namespace DiscImageChef.Core Decoders.DVD.CSS_CPRM.LeadInCopyright? cmi = Decoders.DVD.CSS_CPRM.DecodeLeadInCopyright(image.ReadDiskTag(MediaTagType.DVD_CMI)); if(cmi.HasValue) - { switch(cmi.Value.CopyrightType) { case Decoders.DVD.CopyrightType.AACS: @@ -128,7 +124,6 @@ namespace DiscImageChef.Core sidecar.OpticalDisc[0].CopyProtection = "CPRM"; break; } - } break; case MediaTagType.DVD_DMI: @@ -157,7 +152,6 @@ namespace DiscImageChef.Core Decoders.DVD.PFI.PhysicalFormatInformation? pfi = Decoders.DVD.PFI.Decode(image.ReadDiskTag(MediaTagType.DVD_PFI)); if(pfi.HasValue) - { if(dskType != MediaType.XGD && dskType != MediaType.XGD2 && dskType != MediaType.XGD3) { switch(pfi.Value.DiskCategory) @@ -219,7 +213,6 @@ namespace DiscImageChef.Core else if(pfi.Value.DiscSize == Decoders.DVD.DVDSize.OneTwenty) sidecar.OpticalDisc[0].Dimensions.Diameter = 120; } - } break; case MediaTagType.CD_PMA: @@ -230,7 +223,6 @@ namespace DiscImageChef.Core }; break; } - } try { @@ -297,10 +289,7 @@ namespace DiscImageChef.Core xmlTrk.StartSector = (long)trk.TrackStartSector; xmlTrk.EndSector = (long)trk.TrackEndSector; - if(trk.Indexes != null && trk.Indexes.ContainsKey(0)) - { - if(trk.Indexes.TryGetValue(0, out ulong idx0)) xmlTrk.StartSector = (long)idx0; - } + if(trk.Indexes != null && trk.Indexes.ContainsKey(0)) if(trk.Indexes.TryGetValue(0, out ulong idx0)) xmlTrk.StartSector = (long)idx0; if(sidecar.OpticalDisc[0].DiscType == "CD" || sidecar.OpticalDisc[0].DiscType == "GD") { @@ -333,10 +322,7 @@ namespace DiscImageChef.Core // Only if filter is none... (filterId == new System.Guid("12345678-AAAA-BBBB-CCCC-123456789000") || // ...or AppleDouble - filterId == new System.Guid("1b2165ee-c9df-4b21-bbbb-9e5892b2df4d"))) - { - xmlTrk.Checksums = sidecar.OpticalDisc[0].Checksums; - } + filterId == new System.Guid("1b2165ee-c9df-4b21-bbbb-9e5892b2df4d"))) xmlTrk.Checksums = sidecar.OpticalDisc[0].Checksums; else { UpdateProgress("Track {0} of {1}", trk.TrackSequence, tracks.Count); @@ -474,7 +460,6 @@ namespace DiscImageChef.Core List lstFs = new List(); foreach(Filesystem plugin in plugins.PluginsList.Values) - { try { if(plugin.Identify(image, partitions[i])) @@ -497,7 +482,6 @@ namespace DiscImageChef.Core { //DicConsole.DebugWriteLine("Create-sidecar command", "Plugin {0} crashed", _plugin.Name); } - } if(lstFs.Count > 0) xmlTrk.FileSystemInformation[i].FileSystems = lstFs.ToArray(); } @@ -520,7 +504,6 @@ namespace DiscImageChef.Core Sequence = (ulong)xmlTrk.Sequence.TrackNumber }; foreach(Filesystem plugin in plugins.PluginsList.Values) - { try { if(plugin.Identify(image, xmlPart)) @@ -541,7 +524,6 @@ namespace DiscImageChef.Core { //DicConsole.DebugWriteLine("Create-sidecar command", "Plugin {0} crashed", _plugin.Name); } - } if(lstFs.Count > 0) xmlTrk.FileSystemInformation[0].FileSystems = lstFs.ToArray(); } @@ -573,7 +555,6 @@ namespace DiscImageChef.Core !string.IsNullOrEmpty(image.ImageInfo.DriveModel) || !string.IsNullOrEmpty(image.ImageInfo.DriveFirmwareRevision) || !string.IsNullOrEmpty(image.ImageInfo.DriveSerialNumber)) - { sidecar.OpticalDisc[0].DumpHardwareArray = new[] { new DumpHardwareType @@ -590,7 +571,6 @@ namespace DiscImageChef.Core } } }; - } } } } \ No newline at end of file diff --git a/DiscImageChef.Decoders/ATA/Identify.cs b/DiscImageChef.Decoders/ATA/Identify.cs index 02106f273..813eb04b8 100644 --- a/DiscImageChef.Decoders/ATA/Identify.cs +++ b/DiscImageChef.Decoders/ATA/Identify.cs @@ -1883,7 +1883,6 @@ namespace DiscImageChef.Decoders.ATA IdentifyDevice ATAID = IdentifyDeviceResponse.Value; if(ATAID.GeneralConfiguration.HasFlag(GeneralConfigurationBit.NonMagnetic)) - { if((ushort)ATAID.GeneralConfiguration != 0x848A) { //if (ATAID.CommandSet.HasFlag(CommandSetBit.Packet)) @@ -1897,7 +1896,6 @@ namespace DiscImageChef.Decoders.ATA atapi = false; cfa = true; } - } if(atapi && !cfa) sb.AppendLine("ATAPI device"); else if(!atapi && cfa) sb.AppendLine("CompactFlash device"); @@ -1920,10 +1918,7 @@ namespace DiscImageChef.Decoders.ATA if(ATAID.MediaSerial != "") sb.AppendFormat("Media serial #: {0}", ATAID.MediaSerial).AppendLine(); } - if(ATAID.EnabledCommandSet3.HasFlag(CommandSetBit3.WWN)) - { - sb.AppendFormat("World Wide Name: {0:X16}", ATAID.WWN).AppendLine(); - } + if(ATAID.EnabledCommandSet3.HasFlag(CommandSetBit3.WWN)) sb.AppendFormat("World Wide Name: {0:X16}", ATAID.WWN).AppendLine(); } bool ata1 = false, @@ -2045,7 +2040,6 @@ namespace DiscImageChef.Decoders.ATA sb.Append("Maximum ATA revision supported: "); if(maxatalevel >= 3) - { switch(ATAID.MinorVersion) { case 0x0000: @@ -2194,7 +2188,6 @@ namespace DiscImageChef.Decoders.ATA sb.AppendFormat("Unknown ATA revision 0x{0:X4}", ATAID.MinorVersion).AppendLine(); break; } - } switch((ATAID.TransportMajorVersion & 0xF000) >> 12) { @@ -2334,10 +2327,8 @@ namespace DiscImageChef.Decoders.ATA else if(!cfa) { if(minatalevel >= 5) - { if(ATAID.GeneralConfiguration.HasFlag(GeneralConfigurationBit.IncompleteResponse)) sb.AppendLine("Incomplete identify response"); - } if(ATAID.GeneralConfiguration.HasFlag(GeneralConfigurationBit.NonMagnetic)) sb.AppendLine("Device uses non-magnetic media"); @@ -2345,10 +2336,8 @@ namespace DiscImageChef.Decoders.ATA sb.AppendLine("Device is removable"); if(minatalevel <= 5) - { if(ATAID.GeneralConfiguration.HasFlag(GeneralConfigurationBit.Fixed)) sb.AppendLine("Device is fixed"); - } if(ata1) { @@ -2380,10 +2369,8 @@ namespace DiscImageChef.Decoders.ATA } if(ATAID.NominalRotationRate != 0x0000 && ATAID.NominalRotationRate != 0xFFFF) - { if(ATAID.NominalRotationRate == 0x0001) sb.AppendLine("Device does not rotate."); else sb.AppendFormat("Device rotate at {0} rpm", ATAID.NominalRotationRate).AppendLine(); - } uint logicalsectorsize = 0; if(!atapi) @@ -2393,10 +2380,8 @@ namespace DiscImageChef.Decoders.ATA if((ATAID.PhysLogSectorSize & 0x8000) == 0x0000 && (ATAID.PhysLogSectorSize & 0x4000) == 0x4000) { if((ATAID.PhysLogSectorSize & 0x1000) == 0x1000) - { if(ATAID.LogicalSectorWords <= 255 || ATAID.LogicalAlignment == 0xFFFF) logicalsectorsize = 512; else logicalsectorsize = ATAID.LogicalSectorWords * 2; - } else logicalsectorsize = 512; if((ATAID.PhysLogSectorSize & 0x2000) == 0x2000) @@ -2419,13 +2404,10 @@ namespace DiscImageChef.Decoders.ATA if(logicalsectorsize != physicalsectorsize && (ATAID.LogicalAlignment & 0x8000) == 0x0000 && (ATAID.LogicalAlignment & 0x4000) == 0x4000) - { sb.AppendFormat("Logical sector starts at offset {0} from physical sector", ATAID.LogicalAlignment & 0x3FFF).AppendLine(); - } if(minatalevel <= 5) - { if(ATAID.CurrentCylinders > 0 && ATAID.CurrentHeads > 0 && ATAID.CurrentSectorsPerTrack > 0) { sb.AppendFormat("Cylinders: {0} max., {1} current", ATAID.Cylinders, ATAID.CurrentCylinders) @@ -2445,20 +2427,12 @@ namespace DiscImageChef.Decoders.ATA sb.AppendFormat("Sectors addressable in CHS mode: {0}", ATAID.Cylinders * ATAID.Heads * ATAID.SectorsPerTrack).AppendLine(); } - } - if(ATAID.Capabilities.HasFlag(CapabilitiesBit.LBASupport)) - { - sb.AppendFormat("{0} sectors in 28-bit LBA mode", ATAID.LBASectors).AppendLine(); - } + if(ATAID.Capabilities.HasFlag(CapabilitiesBit.LBASupport)) sb.AppendFormat("{0} sectors in 28-bit LBA mode", ATAID.LBASectors).AppendLine(); - if(ATAID.CommandSet2.HasFlag(CommandSetBit2.LBA48)) - { - sb.AppendFormat("{0} sectors in 48-bit LBA mode", ATAID.LBA48Sectors).AppendLine(); - } + if(ATAID.CommandSet2.HasFlag(CommandSetBit2.LBA48)) sb.AppendFormat("{0} sectors in 48-bit LBA mode", ATAID.LBA48Sectors).AppendLine(); if(minatalevel <= 5) - { if(ATAID.CurrentSectors > 0) sb.AppendFormat("Device size in CHS mode: {0} bytes, {1} Mb, {2} MiB", (ulong)ATAID.CurrentSectors * logicalsectorsize, @@ -2472,91 +2446,66 @@ namespace DiscImageChef.Decoders.ATA currentSectors * logicalsectorsize / 1000 / 1000, currentSectors * 512 / 1024 / 1024).AppendLine(); } - } if(ATAID.Capabilities.HasFlag(CapabilitiesBit.LBASupport)) - { if((ulong)ATAID.LBASectors * logicalsectorsize / 1024 / 1024 > 1000000) - { sb.AppendFormat("Device size in 28-bit LBA mode: {0} bytes, {1} Tb, {2} TiB", (ulong)ATAID.LBASectors * logicalsectorsize, (ulong)ATAID.LBASectors * logicalsectorsize / 1000 / 1000 / 1000 / 1000, (ulong)ATAID.LBASectors * 512 / 1024 / 1024 / 1024 / 1024).AppendLine(); - } else if((ulong)ATAID.LBASectors * logicalsectorsize / 1024 / 1024 > 1000) - { sb.AppendFormat("Device size in 28-bit LBA mode: {0} bytes, {1} Gb, {2} GiB", (ulong)ATAID.LBASectors * logicalsectorsize, (ulong)ATAID.LBASectors * logicalsectorsize / 1000 / 1000 / 1000, (ulong)ATAID.LBASectors * 512 / 1024 / 1024 / 1024).AppendLine(); - } else - { sb.AppendFormat("Device size in 28-bit LBA mode: {0} bytes, {1} Mb, {2} MiB", (ulong)ATAID.LBASectors * logicalsectorsize, (ulong)ATAID.LBASectors * logicalsectorsize / 1000 / 1000, (ulong)ATAID.LBASectors * 512 / 1024 / 1024).AppendLine(); - } - } if(ATAID.CommandSet2.HasFlag(CommandSetBit2.LBA48)) - { if(ATAID.CommandSet5.HasFlag(CommandSetBit5.ExtSectors)) - { if(ATAID.ExtendedUserSectors * logicalsectorsize / 1024 / 1024 > 1000000) - { sb.AppendFormat("Device size in 48-bit LBA mode: {0} bytes, {1} Tb, {2} TiB", ATAID.ExtendedUserSectors * logicalsectorsize, ATAID.ExtendedUserSectors * logicalsectorsize / 1000 / 1000 / 1000 / 1000, ATAID.ExtendedUserSectors * logicalsectorsize / 1024 / 1024 / 1024 / 1024) .AppendLine(); - } else if(ATAID.ExtendedUserSectors * logicalsectorsize / 1024 / 1024 > 1000) - { sb.AppendFormat("Device size in 48-bit LBA mode: {0} bytes, {1} Gb, {2} GiB", ATAID.ExtendedUserSectors * logicalsectorsize, ATAID.ExtendedUserSectors * logicalsectorsize / 1000 / 1000 / 1000, ATAID.ExtendedUserSectors * logicalsectorsize / 1024 / 1024 / 1024) .AppendLine(); - } else - { sb.AppendFormat("Device size in 48-bit LBA mode: {0} bytes, {1} Mb, {2} MiB", ATAID.ExtendedUserSectors * logicalsectorsize, ATAID.ExtendedUserSectors * logicalsectorsize / 1000 / 1000, ATAID.ExtendedUserSectors * logicalsectorsize / 1024 / 1024).AppendLine(); - } - } else { if(ATAID.LBA48Sectors * logicalsectorsize / 1024 / 1024 > 1000000) - { sb.AppendFormat("Device size in 48-bit LBA mode: {0} bytes, {1} Tb, {2} TiB", ATAID.LBA48Sectors * logicalsectorsize, ATAID.LBA48Sectors * logicalsectorsize / 1000 / 1000 / 1000 / 1000, ATAID.LBA48Sectors * logicalsectorsize / 1024 / 1024 / 1024 / 1024) .AppendLine(); - } else if(ATAID.LBA48Sectors * logicalsectorsize / 1024 / 1024 > 1000) - { sb.AppendFormat("Device size in 48-bit LBA mode: {0} bytes, {1} Gb, {2} GiB", ATAID.LBA48Sectors * logicalsectorsize, ATAID.LBA48Sectors * logicalsectorsize / 1000 / 1000 / 1000, ATAID.LBA48Sectors * logicalsectorsize / 1024 / 1024 / 1024).AppendLine(); - } else - { sb.AppendFormat("Device size in 48-bit LBA mode: {0} bytes, {1} Mb, {2} MiB", ATAID.LBA48Sectors * logicalsectorsize, ATAID.LBA48Sectors * logicalsectorsize / 1000 / 1000, ATAID.LBA48Sectors * logicalsectorsize / 1024 / 1024).AppendLine(); - } } - } if(ata1 || cfa) { - if(cfa) { sb.AppendFormat("{0} sectors in card", ATAID.SectorsPerCard).AppendLine(); } + if(cfa) sb.AppendFormat("{0} sectors in card", ATAID.SectorsPerCard).AppendLine(); if(ATAID.UnformattedBPT > 0) sb.AppendFormat("{0} bytes per unformatted track", ATAID.UnformattedBPT).AppendLine(); if(ATAID.UnformattedBPS > 0) @@ -2564,7 +2513,6 @@ namespace DiscImageChef.Decoders.ATA } } if((ushort)ATAID.SpecificConfiguration != 0x0000 && (ushort)ATAID.SpecificConfiguration != 0xFFFF) - { switch(ATAID.SpecificConfiguration) { case SpecificConfigurationEnum.RequiresSetIncompleteResponse: @@ -2584,12 +2532,10 @@ namespace DiscImageChef.Decoders.ATA (ushort)ATAID.SpecificConfiguration).AppendLine(); break; } - } // Obsolete since ATA-2, however, it is yet used in ATA-8 devices if(ATAID.BufferSize != 0x0000 && ATAID.BufferSize != 0xFFFF && ATAID.BufferType != 0x0000 && ATAID.BufferType != 0xFFFF) - { switch(ATAID.BufferType) { case 1: @@ -2609,7 +2555,6 @@ namespace DiscImageChef.Decoders.ATA ATAID.BufferType).AppendLine(); break; } - } if(ATAID.EccBytes != 0x0000 && ATAID.EccBytes != 0xFFFF) sb.AppendFormat("READ/WRITE LONG has {0} extra bytes", ATAID.EccBytes).AppendLine(); @@ -2628,10 +2573,8 @@ namespace DiscImageChef.Decoders.ATA if(ATAID.Capabilities2.HasFlag(CapabilitiesBit2.MustBeSet) && !ATAID.Capabilities2.HasFlag(CapabilitiesBit2.MustBeClear)) - { if(ATAID.Capabilities2.HasFlag(CapabilitiesBit2.SpecificStandbyTimer)) sb.AppendLine().Append("Device indicates a specific minimum standby timer value"); - } if(ATAID.Capabilities3.HasFlag(CapabilitiesBit3.MultipleValid)) { @@ -2644,16 +2587,12 @@ namespace DiscImageChef.Decoders.ATA if(ATAID.Capabilities.HasFlag(CapabilitiesBit.PhysicalAlignment1) || ATAID.Capabilities.HasFlag(CapabilitiesBit.PhysicalAlignment0)) - { sb.AppendLine().AppendFormat("Long Physical Alignment setting is {0}", (ushort)ATAID.Capabilities & 0x03); - } if(ata1) - { if(ATAID.TrustedComputing.HasFlag(TrustedComputingBit.TrustedComputing)) sb.AppendLine().Append("Device supports doubleword I/O"); - } if(atapi) { @@ -2674,14 +2613,14 @@ namespace DiscImageChef.Decoders.ATA } sb.AppendLine().Append("Advanced PIO: "); - if(ATAID.APIOSupported.HasFlag(TransferMode.Mode0)) { sb.Append("PIO0 "); } - if(ATAID.APIOSupported.HasFlag(TransferMode.Mode1)) { sb.Append("PIO1 "); } - if(ATAID.APIOSupported.HasFlag(TransferMode.Mode2)) { sb.Append("PIO2 "); } - if(ATAID.APIOSupported.HasFlag(TransferMode.Mode3)) { sb.Append("PIO3 "); } - if(ATAID.APIOSupported.HasFlag(TransferMode.Mode4)) { sb.Append("PIO4 "); } - if(ATAID.APIOSupported.HasFlag(TransferMode.Mode5)) { sb.Append("PIO5 "); } - if(ATAID.APIOSupported.HasFlag(TransferMode.Mode6)) { sb.Append("PIO6 "); } - if(ATAID.APIOSupported.HasFlag(TransferMode.Mode7)) { sb.Append("PIO7 "); } + if(ATAID.APIOSupported.HasFlag(TransferMode.Mode0)) sb.Append("PIO0 "); + if(ATAID.APIOSupported.HasFlag(TransferMode.Mode1)) sb.Append("PIO1 "); + if(ATAID.APIOSupported.HasFlag(TransferMode.Mode2)) sb.Append("PIO2 "); + if(ATAID.APIOSupported.HasFlag(TransferMode.Mode3)) sb.Append("PIO3 "); + if(ATAID.APIOSupported.HasFlag(TransferMode.Mode4)) sb.Append("PIO4 "); + if(ATAID.APIOSupported.HasFlag(TransferMode.Mode5)) sb.Append("PIO5 "); + if(ATAID.APIOSupported.HasFlag(TransferMode.Mode6)) sb.Append("PIO6 "); + if(ATAID.APIOSupported.HasFlag(TransferMode.Mode7)) sb.Append("PIO7 "); if(minatalevel <= 3 && !atapi) { @@ -2813,28 +2752,19 @@ namespace DiscImageChef.Decoders.ATA } if(ATAID.MinMDMACycleTime != 0 && ATAID.RecMDMACycleTime != 0) - { sb.AppendLine() .AppendFormat("At minimum {0} ns. transfer cycle time per word in MDMA, " + "{1} ns. recommended", ATAID.MinMDMACycleTime, ATAID.RecMDMACycleTime); - } if(ATAID.MinPIOCycleTimeNoFlow != 0) - { sb.AppendLine() .AppendFormat("At minimum {0} ns. transfer cycle time per word in PIO, " + "without flow control", ATAID.MinPIOCycleTimeNoFlow); - } if(ATAID.MinPIOCycleTimeFlow != 0) - { sb.AppendLine() .AppendFormat("At minimum {0} ns. transfer cycle time per word in PIO, " + "with IORDY flow control", ATAID.MinPIOCycleTimeFlow); - } - if(ATAID.MaxQueueDepth != 0) - { - sb.AppendLine().AppendFormat("{0} depth of queue maximum", ATAID.MaxQueueDepth + 1); - } + if(ATAID.MaxQueueDepth != 0) sb.AppendLine().AppendFormat("{0} depth of queue maximum", ATAID.MaxQueueDepth + 1); if(atapi) { @@ -2851,46 +2781,19 @@ namespace DiscImageChef.Decoders.ATA { if(!ATAID.SATACapabilities.HasFlag(SATACapabilitiesBit.Clear)) { - if(ATAID.SATACapabilities.HasFlag(SATACapabilitiesBit.Gen1Speed)) - { - sb.AppendLine().Append("SATA 1.5Gb/s is supported"); - } - if(ATAID.SATACapabilities.HasFlag(SATACapabilitiesBit.Gen2Speed)) - { - sb.AppendLine().Append("SATA 3.0Gb/s is supported"); - } - if(ATAID.SATACapabilities.HasFlag(SATACapabilitiesBit.Gen3Speed)) - { - sb.AppendLine().Append("SATA 6.0Gb/s is supported"); - } - if(ATAID.SATACapabilities.HasFlag(SATACapabilitiesBit.PowerReceipt)) - { - sb.AppendLine().Append("Receipt of host initiated power management requests is supported"); - } - if(ATAID.SATACapabilities.HasFlag(SATACapabilitiesBit.PHYEventCounter)) - { - sb.AppendLine().Append("PHY Event counters are supported"); - } - if(ATAID.SATACapabilities.HasFlag(SATACapabilitiesBit.HostSlumbTrans)) - { - sb.AppendLine().Append("Supports host automatic partial to slumber transitions is supported"); - } - if(ATAID.SATACapabilities.HasFlag(SATACapabilitiesBit.DevSlumbTrans)) - { - sb.AppendLine().Append("Supports device automatic partial to slumber transitions is supported"); - } + if(ATAID.SATACapabilities.HasFlag(SATACapabilitiesBit.Gen1Speed)) sb.AppendLine().Append("SATA 1.5Gb/s is supported"); + if(ATAID.SATACapabilities.HasFlag(SATACapabilitiesBit.Gen2Speed)) sb.AppendLine().Append("SATA 3.0Gb/s is supported"); + if(ATAID.SATACapabilities.HasFlag(SATACapabilitiesBit.Gen3Speed)) sb.AppendLine().Append("SATA 6.0Gb/s is supported"); + if(ATAID.SATACapabilities.HasFlag(SATACapabilitiesBit.PowerReceipt)) sb.AppendLine().Append("Receipt of host initiated power management requests is supported"); + if(ATAID.SATACapabilities.HasFlag(SATACapabilitiesBit.PHYEventCounter)) sb.AppendLine().Append("PHY Event counters are supported"); + if(ATAID.SATACapabilities.HasFlag(SATACapabilitiesBit.HostSlumbTrans)) sb.AppendLine().Append("Supports host automatic partial to slumber transitions is supported"); + if(ATAID.SATACapabilities.HasFlag(SATACapabilitiesBit.DevSlumbTrans)) sb.AppendLine().Append("Supports device automatic partial to slumber transitions is supported"); if(ATAID.SATACapabilities.HasFlag(SATACapabilitiesBit.NCQ)) { sb.AppendLine().Append("NCQ is supported"); - if(ATAID.SATACapabilities.HasFlag(SATACapabilitiesBit.NCQPriority)) - { - sb.AppendLine().Append("NCQ priority is supported"); - } - if(ATAID.SATACapabilities.HasFlag(SATACapabilitiesBit.UnloadNCQ)) - { - sb.AppendLine().Append("Unload is supported with outstanding NCQ commands"); - } + if(ATAID.SATACapabilities.HasFlag(SATACapabilitiesBit.NCQPriority)) sb.AppendLine().Append("NCQ priority is supported"); + if(ATAID.SATACapabilities.HasFlag(SATACapabilitiesBit.UnloadNCQ)) sb.AppendLine().Append("Unload is supported with outstanding NCQ commands"); } } @@ -2899,26 +2802,14 @@ namespace DiscImageChef.Decoders.ATA if(!ATAID.SATACapabilities.HasFlag(SATACapabilitiesBit.Clear) && ATAID.SATACapabilities.HasFlag(SATACapabilitiesBit.NCQ)) { - if(ATAID.SATACapabilities2.HasFlag(SATACapabilitiesBit2.NCQMgmt)) - { - sb.AppendLine().Append("NCQ queue management is supported"); - } - if(ATAID.SATACapabilities2.HasFlag(SATACapabilitiesBit2.NCQStream)) - { - sb.AppendLine().Append("NCQ streaming is supported"); - } + if(ATAID.SATACapabilities2.HasFlag(SATACapabilitiesBit2.NCQMgmt)) sb.AppendLine().Append("NCQ queue management is supported"); + if(ATAID.SATACapabilities2.HasFlag(SATACapabilitiesBit2.NCQStream)) sb.AppendLine().Append("NCQ streaming is supported"); } if(atapi) { - if(ATAID.SATACapabilities2.HasFlag(SATACapabilitiesBit2.HostEnvDetect)) - { - sb.AppendLine().Append("ATAPI device supports host environment detection"); - } - if(ATAID.SATACapabilities2.HasFlag(SATACapabilitiesBit2.DevAttSlimline)) - { - sb.AppendLine().Append("ATAPI device supports attention on slimline connected devices"); - } + if(ATAID.SATACapabilities2.HasFlag(SATACapabilitiesBit2.HostEnvDetect)) sb.AppendLine().Append("ATAPI device supports host environment detection"); + if(ATAID.SATACapabilities2.HasFlag(SATACapabilitiesBit2.DevAttSlimline)) sb.AppendLine().Append("ATAPI device supports attention on slimline connected devices"); } //sb.AppendFormat("Negotiated speed = {0}", ((ushort)ATAID.SATACapabilities2 & 0x000E) >> 1); @@ -2926,13 +2817,10 @@ namespace DiscImageChef.Decoders.ATA } if(ATAID.InterseekDelay != 0x0000 && ATAID.InterseekDelay != 0xFFFF) - { sb.AppendLine().AppendFormat("{0} microseconds of interseek delay for ISO-7779 accoustic testing", ATAID.InterseekDelay); - } if((ushort)ATAID.DeviceFormFactor != 0x0000 && (ushort)ATAID.DeviceFormFactor != 0xFFFF) - { switch(ATAID.DeviceFormFactor) { case DeviceFormFactorEnum.FiveAndQuarter: @@ -2955,16 +2843,12 @@ namespace DiscImageChef.Decoders.ATA ATAID.DeviceFormFactor); break; } - } if(atapi) - { if(ATAID.ATAPIByteCount > 0) sb.AppendLine().AppendFormat("{0} bytes count limit for ATAPI", ATAID.ATAPIByteCount); - } if(cfa) - { if((ATAID.CFAPowerMode & 0x8000) == 0x8000) { sb.AppendLine().Append("CompactFlash device supports power mode 1"); @@ -2976,7 +2860,6 @@ namespace DiscImageChef.Decoders.ATA sb.AppendLine().AppendFormat("CompactFlash device uses a maximum of {0} mA", ATAID.CFAPowerMode & 0x0FFF); } - } sb.AppendLine(); @@ -3076,10 +2959,8 @@ namespace DiscImageChef.Decoders.ATA { sb.AppendLine().Append("Automatic Acoustic Management is supported"); if(ATAID.EnabledCommandSet2.HasFlag(CommandSetBit2.AAM)) - { sb.AppendFormat(" and enabled with value {0} (vendor recommends {1}", ATAID.CurrentAAM, ATAID.RecommendedAAM); - } } if(ATAID.CommandSet2.HasFlag(CommandSetBit2.SetMax)) { @@ -3092,10 +2973,7 @@ namespace DiscImageChef.Decoders.ATA if(ATAID.EnabledCommandSet2.HasFlag(CommandSetBit2.AddressOffsetReservedAreaBoot)) sb.Append(" and enabled"); } - if(ATAID.CommandSet2.HasFlag(CommandSetBit2.SetFeaturesRequired)) - { - sb.AppendLine().Append("SET FEATURES is required before spin-up"); - } + if(ATAID.CommandSet2.HasFlag(CommandSetBit2.SetFeaturesRequired)) sb.AppendLine().Append("SET FEATURES is required before spin-up"); if(ATAID.CommandSet2.HasFlag(CommandSetBit2.PowerUpInStandby)) { sb.AppendLine().Append("Power-up in standby is supported"); @@ -3110,10 +2988,7 @@ namespace DiscImageChef.Decoders.ATA if(ATAID.CommandSet2.HasFlag(CommandSetBit2.APM)) { sb.AppendLine().Append("Advanced Power Management is supported"); - if(ATAID.EnabledCommandSet2.HasFlag(CommandSetBit2.APM)) - { - sb.AppendFormat(" and enabled with value {0}", ATAID.CurrentAPM); - } + if(ATAID.EnabledCommandSet2.HasFlag(CommandSetBit2.APM)) sb.AppendFormat(" and enabled with value {0}", ATAID.CurrentAPM); } if(ATAID.CommandSet2.HasFlag(CommandSetBit2.CompactFlash)) { @@ -3159,18 +3034,9 @@ namespace DiscImageChef.Decoders.ATA sb.AppendLine().Append("IDLE IMMEDIATE with UNLOAD FEATURE is supported"); if(ATAID.EnabledCommandSet3.HasFlag(CommandSetBit3.IdleImmediate)) sb.Append(" and enabled"); } - if(ATAID.CommandSet3.HasFlag(CommandSetBit3.WriteURG)) - { - sb.AppendLine().Append("URG bit is supported in WRITE STREAM DMA EXT and WRITE STREAM EXT"); - } - if(ATAID.CommandSet3.HasFlag(CommandSetBit3.ReadURG)) - { - sb.AppendLine().Append("URG bit is supported in READ STREAM DMA EXT and READ STREAM EXT"); - } - if(ATAID.CommandSet3.HasFlag(CommandSetBit3.WWN)) - { - sb.AppendLine().Append("Device has a World Wide Name"); - } + if(ATAID.CommandSet3.HasFlag(CommandSetBit3.WriteURG)) sb.AppendLine().Append("URG bit is supported in WRITE STREAM DMA EXT and WRITE STREAM EXT"); + if(ATAID.CommandSet3.HasFlag(CommandSetBit3.ReadURG)) sb.AppendLine().Append("URG bit is supported in READ STREAM DMA EXT and READ STREAM EXT"); + if(ATAID.CommandSet3.HasFlag(CommandSetBit3.WWN)) sb.AppendLine().Append("Device has a World Wide Name"); if(ATAID.CommandSet3.HasFlag(CommandSetBit3.FUAWriteQ)) { sb.AppendLine().Append("WRITE DMA QUEUED FUA EXT is supported"); @@ -3270,62 +3136,27 @@ namespace DiscImageChef.Decoders.ATA sb.AppendLine().Append("CRYPTO SCRAMBLE EXT is supported"); if(ATAID.CommandSet5.HasFlag(CommandSetBit5.DeviceConfDMA)) - { sb.AppendLine() .Append("DEVICE CONFIGURATION IDENTIFY DMA and DEVICE CONFIGURATION SET DMA are supported"); - } - if(ATAID.CommandSet5.HasFlag(CommandSetBit5.ReadBufferDMA)) - { - sb.AppendLine().Append("READ BUFFER DMA is supported"); - } - if(ATAID.CommandSet5.HasFlag(CommandSetBit5.WriteBufferDMA)) - { - sb.AppendLine().Append("WRITE BUFFER DMA is supported"); - } - if(ATAID.CommandSet5.HasFlag(CommandSetBit5.DownloadMicroCodeDMA)) - { - sb.AppendLine().Append("DOWNLOAD MICROCODE DMA is supported"); - } - if(ATAID.CommandSet5.HasFlag(CommandSetBit5.SetMaxDMA)) - { - sb.AppendLine().Append("SET PASSWORD DMA and SET UNLOCK DMA are supported"); - } - if(ATAID.CommandSet5.HasFlag(CommandSetBit5.Ata28)) - { - sb.AppendLine().Append("Not all 28-bit commands are supported"); - } + if(ATAID.CommandSet5.HasFlag(CommandSetBit5.ReadBufferDMA)) sb.AppendLine().Append("READ BUFFER DMA is supported"); + if(ATAID.CommandSet5.HasFlag(CommandSetBit5.WriteBufferDMA)) sb.AppendLine().Append("WRITE BUFFER DMA is supported"); + if(ATAID.CommandSet5.HasFlag(CommandSetBit5.DownloadMicroCodeDMA)) sb.AppendLine().Append("DOWNLOAD MICROCODE DMA is supported"); + if(ATAID.CommandSet5.HasFlag(CommandSetBit5.SetMaxDMA)) sb.AppendLine().Append("SET PASSWORD DMA and SET UNLOCK DMA are supported"); + if(ATAID.CommandSet5.HasFlag(CommandSetBit5.Ata28)) sb.AppendLine().Append("Not all 28-bit commands are supported"); - if(ATAID.CommandSet5.HasFlag(CommandSetBit5.CFast)) - { - sb.AppendLine().Append("Device follows CFast specification"); - } - if(ATAID.CommandSet5.HasFlag(CommandSetBit5.IEEE1667)) - { - sb.AppendLine().Append("Device follows IEEE-1667"); - } + if(ATAID.CommandSet5.HasFlag(CommandSetBit5.CFast)) sb.AppendLine().Append("Device follows CFast specification"); + if(ATAID.CommandSet5.HasFlag(CommandSetBit5.IEEE1667)) sb.AppendLine().Append("Device follows IEEE-1667"); if(ATAID.CommandSet5.HasFlag(CommandSetBit5.DeterministicTrim)) { sb.AppendLine().Append("Read after TRIM is deterministic"); - if(ATAID.CommandSet5.HasFlag(CommandSetBit5.ReadZeroTrim)) - { - sb.AppendLine().Append("Read after TRIM returns empty data"); - } - } - if(ATAID.CommandSet5.HasFlag(CommandSetBit5.LongPhysSectorAligError)) - { - sb.AppendLine().Append("Device supports Long Physical Sector Alignment Error Reporting Control"); - } - if(ATAID.CommandSet5.HasFlag(CommandSetBit5.Encrypted)) - { - sb.AppendLine().Append("Device encrypts all user data"); - } - if(ATAID.CommandSet5.HasFlag(CommandSetBit5.AllCacheNV)) - { - sb.AppendLine().Append("Device's write cache is non-volatile"); + if(ATAID.CommandSet5.HasFlag(CommandSetBit5.ReadZeroTrim)) sb.AppendLine().Append("Read after TRIM returns empty data"); } + if(ATAID.CommandSet5.HasFlag(CommandSetBit5.LongPhysSectorAligError)) sb.AppendLine().Append("Device supports Long Physical Sector Alignment Error Reporting Control"); + if(ATAID.CommandSet5.HasFlag(CommandSetBit5.Encrypted)) sb.AppendLine().Append("Device encrypts all user data"); + if(ATAID.CommandSet5.HasFlag(CommandSetBit5.AllCacheNV)) sb.AppendLine().Append("Device's write cache is non-volatile"); if(ATAID.CommandSet5.HasFlag(CommandSetBit5.ZonedBit0) || - ATAID.CommandSet5.HasFlag(CommandSetBit5.ZonedBit1)) { sb.AppendLine().Append("Device is zoned"); } + ATAID.CommandSet5.HasFlag(CommandSetBit5.ZonedBit1)) sb.AppendLine().Append("Device is zoned"); if(ATAID.Capabilities3.HasFlag(CapabilitiesBit3.Sanitize)) { @@ -3339,27 +3170,21 @@ namespace DiscImageChef.Decoders.ATA } if(!ata1 && maxatalevel >= 8) - { if(ATAID.TrustedComputing.HasFlag(TrustedComputingBit.Set) && !ATAID.TrustedComputing.HasFlag(TrustedComputingBit.Clear) && ATAID.TrustedComputing.HasFlag(TrustedComputingBit.TrustedComputing)) sb.AppendLine().Append("Trusted Computing feature set is supported"); - } if((ATAID.TransportMajorVersion & 0xF000) >> 12 == 0x1 || (ATAID.TransportMajorVersion & 0xF000) >> 12 == 0xE) { if(!ATAID.SATACapabilities.HasFlag(SATACapabilitiesBit.Clear)) - { if(ATAID.SATACapabilities.HasFlag(SATACapabilitiesBit.ReadLogDMAExt)) sb.AppendLine().Append("READ LOG DMA EXT is supported"); - } if(!ATAID.SATACapabilities2.HasFlag(SATACapabilitiesBit2.Clear)) - { if(ATAID.SATACapabilities2.HasFlag(SATACapabilitiesBit2.FPDMAQ)) sb.AppendLine().Append("RECEIVE FPDMA QUEUED and SEND FPDMA QUEUED are supported"); - } if(!ATAID.SATAFeatures.HasFlag(SATAFeaturesBit.Clear)) { @@ -3385,55 +3210,37 @@ namespace DiscImageChef.Decoders.ATA if(ATAID.EnabledSATAFeatures.HasFlag(SATAFeaturesBit.InOrderData)) sb.Append(" and enabled"); } if(!atapi) - { if(ATAID.SATAFeatures.HasFlag(SATAFeaturesBit.HardwareFeatureControl)) { sb.AppendLine().Append("Hardware Feature Control is supported"); if(ATAID.EnabledSATAFeatures.HasFlag(SATAFeaturesBit.HardwareFeatureControl)) sb.Append(" and enabled"); } - } if(atapi) - { if(ATAID.SATAFeatures.HasFlag(SATAFeaturesBit.AsyncNotification)) { sb.AppendLine().Append("Asynchronous notification is supported"); if(ATAID.EnabledSATAFeatures.HasFlag(SATAFeaturesBit.AsyncNotification)) sb.Append(" and enabled"); } - } if(ATAID.SATAFeatures.HasFlag(SATAFeaturesBit.SettingsPreserve)) { sb.AppendLine().Append("Software Settings Preservation is supported"); if(ATAID.EnabledSATAFeatures.HasFlag(SATAFeaturesBit.SettingsPreserve)) sb.Append(" and enabled"); } - if(ATAID.SATAFeatures.HasFlag(SATAFeaturesBit.NCQAutoSense)) - { - sb.AppendLine().Append("NCQ Autosense is supported"); - } - if(ATAID.EnabledSATAFeatures.HasFlag(SATAFeaturesBit.EnabledSlumber)) - { - sb.AppendLine().Append("Automatic Partial to Slumber transitions are enabled"); - } + if(ATAID.SATAFeatures.HasFlag(SATAFeaturesBit.NCQAutoSense)) sb.AppendLine().Append("NCQ Autosense is supported"); + if(ATAID.EnabledSATAFeatures.HasFlag(SATAFeaturesBit.EnabledSlumber)) sb.AppendLine().Append("Automatic Partial to Slumber transitions are enabled"); } } - if((ATAID.RemovableStatusSet & 0x03) > 0) - { - sb.AppendLine().Append("Removable Media Status Notification feature set is supported"); - } + if((ATAID.RemovableStatusSet & 0x03) > 0) sb.AppendLine().Append("Removable Media Status Notification feature set is supported"); - if(ATAID.FreeFallSensitivity != 0x00 && ATAID.FreeFallSensitivity != 0xFF) - { - sb.AppendLine().AppendFormat("Free-fall sensitivity set to {0}", ATAID.FreeFallSensitivity); - } + if(ATAID.FreeFallSensitivity != 0x00 && ATAID.FreeFallSensitivity != 0xFF) sb.AppendLine().AppendFormat("Free-fall sensitivity set to {0}", ATAID.FreeFallSensitivity); if(ATAID.DataSetMgmt.HasFlag(DataSetMgmtBit.Trim)) sb.AppendLine().Append("TRIM is supported"); if(ATAID.DataSetMgmtSize > 0) - { sb.AppendLine().AppendFormat("DATA SET MANAGEMENT can receive a maximum of {0} blocks of 512 bytes", ATAID.DataSetMgmtSize); - } sb.AppendLine().AppendLine(); if(ATAID.SecurityStatus.HasFlag(SecurityStatusBit.Supported)) @@ -3533,20 +3340,14 @@ namespace DiscImageChef.Decoders.ATA if(ATAID.ReservedWord116 != 0x0000 && ATAID.ReservedWord116 != 0xFFFF) sb.AppendFormat("Word 116: 0x{0:X4}", ATAID.ReservedWord116).AppendLine(); for(int i = 0; i < ATAID.ReservedWords121.Length; i++) - { if(ATAID.ReservedWords121[i] != 0x0000 && ATAID.ReservedWords121[i] != 0xFFFF) sb.AppendFormat("Word {1}: 0x{0:X4}", ATAID.ReservedWords121[i], 121 + i).AppendLine(); - } for(int i = 0; i < ATAID.ReservedWords129.Length; i++) - { if(ATAID.ReservedWords129[i] != 0x0000 && ATAID.ReservedWords129[i] != 0xFFFF) sb.AppendFormat("Word {1}: 0x{0:X4}", ATAID.ReservedWords129[i], 129 + i).AppendLine(); - } for(int i = 0; i < ATAID.ReservedCFA.Length; i++) - { if(ATAID.ReservedCFA[i] != 0x0000 && ATAID.ReservedCFA[i] != 0xFFFF) sb.AppendFormat("Word {1} (CFA): 0x{0:X4}", ATAID.ReservedCFA[i], 161 + i).AppendLine(); - } if(ATAID.ReservedWord174 != 0x0000 && ATAID.ReservedWord174 != 0xFFFF) sb.AppendFormat("Word 174: 0x{0:X4}", ATAID.ReservedWord174).AppendLine(); @@ -3563,15 +3364,11 @@ namespace DiscImageChef.Decoders.ATA if(ATAID.ReservedWord221 != 0x0000 && ATAID.ReservedWord221 != 0xFFFF) sb.AppendFormat("Word 221: 0x{0:X4}", ATAID.ReservedWord221).AppendLine(); for(int i = 0; i < ATAID.ReservedCEATA224.Length; i++) - { if(ATAID.ReservedCEATA224[i] != 0x0000 && ATAID.ReservedCEATA224[i] != 0xFFFF) sb.AppendFormat("Word {1} (CE-ATA): 0x{0:X4}", ATAID.ReservedCEATA224[i], 224 + i).AppendLine(); - } for(int i = 0; i < ATAID.ReservedWords.Length; i++) - { if(ATAID.ReservedWords[i] != 0x0000 && ATAID.ReservedWords[i] != 0xFFFF) sb.AppendFormat("Word {1}: 0x{0:X4}", ATAID.ReservedWords[i], 236 + i).AppendLine(); - } #endif return sb.ToString(); } diff --git a/DiscImageChef.Decoders/CD/Sector.cs b/DiscImageChef.Decoders/CD/Sector.cs index 646adfcdc..d3637f2f2 100644 --- a/DiscImageChef.Decoders/CD/Sector.cs +++ b/DiscImageChef.Decoders/CD/Sector.cs @@ -187,7 +187,7 @@ namespace DiscImageChef.Decoders.CD byte[] scrambled = new byte[sector.Length]; for(int i = 0; i < 2352; i++) scrambled[i] = (byte)(sector[i] ^ ScrambleTable[i]); - if(sector.Length > 2352) { for(int i = 2352; i < sector.Length; i++) scrambled[i] = sector[i]; } + if(sector.Length > 2352) for(int i = 2352; i < sector.Length; i++) scrambled[i] = sector[i]; return scrambled; } diff --git a/DiscImageChef.Decoders/DVD/PFI.cs b/DiscImageChef.Decoders/DVD/PFI.cs index 39d2fabcb..934230ddd 100644 --- a/DiscImageChef.Decoders/DVD/PFI.cs +++ b/DiscImageChef.Decoders/DVD/PFI.cs @@ -1079,10 +1079,7 @@ namespace DiscImageChef.Decoders.DVD pfi.BCA |= (response[20] & 0x80) == 0x80; // UMD - if(pfi.DiskCategory == DiskCategory.UMD) - { - pfi.MediaAttribute = (ushort)((response[21] << 8) + response[22]); - } + if(pfi.DiskCategory == DiskCategory.UMD) pfi.MediaAttribute = (ushort)((response[21] << 8) + response[22]); // DVD-RAM if(pfi.DiskCategory == DiskCategory.DVDRAM) @@ -1273,10 +1270,7 @@ namespace DiscImageChef.Decoders.DVD } // DVD+R DL - if(pfi.DiskCategory == DiskCategory.DVDPRDL) - { - pfi.LayerStructure = (DVDLayerStructure)((response[34] & 0xC0) >> 6); - } + if(pfi.DiskCategory == DiskCategory.DVDPRDL) pfi.LayerStructure = (DVDLayerStructure)((response[34] & 0xC0) >> 6); // DVD+RW DL if(pfi.DiskCategory == DiskCategory.DVDPRWDL) @@ -1468,13 +1462,11 @@ namespace DiscImageChef.Decoders.DVD break; case DiskCategory.Nintendo: if(decoded.PartVersion == 15) - { if(decoded.DiscSize == DVDSize.Eighty) sb.AppendLine("Disc is a Nintendo Gamecube Optical Disc (GOD)"); else if(decoded.DiscSize == DVDSize.OneTwenty) sb.AppendLine("Disc is a Nintendo Wii Optical Disc (WOD)"); else goto default; - } else goto default; break; case DiskCategory.HDDVDROM: @@ -1576,7 +1568,6 @@ namespace DiscImageChef.Decoders.DVD } if(decoded.DataAreaStartPSN > 0) - { if(decoded.DataAreaEndPSN > 0) { sb.AppendFormat("Data area starts at PSN {0:X}h", decoded.DataAreaStartPSN).AppendLine(); @@ -1585,7 +1576,6 @@ namespace DiscImageChef.Decoders.DVD sb.AppendFormat("Layer 0 ends at PSN {0:X}h", decoded.Layer0EndPSN).AppendLine(); } else sb.AppendLine("Disc is empty"); - } else sb.AppendLine("Disc is empty"); if(decoded.BCA) sb.AppendLine("Disc has a burst cutting area"); diff --git a/DiscImageChef.Decoders/MMC/CSD.cs b/DiscImageChef.Decoders/MMC/CSD.cs index 190ddfa64..8418f3fa7 100644 --- a/DiscImageChef.Decoders/MMC/CSD.cs +++ b/DiscImageChef.Decoders/MMC/CSD.cs @@ -337,10 +337,7 @@ namespace DiscImageChef.Decoders.MMC sb.AppendFormat("\tDevice's clock frequency: {0}{1}", result, unit).AppendLine(); unit = ""; - for(int cl = 0, mask = 1; cl <= 11; cl++, mask <<= 1) - { - if((csd.Classes & mask) == mask) unit += string.Format(" {0}", cl); - } + for(int cl = 0, mask = 1; cl <= 11; cl++, mask <<= 1) if((csd.Classes & mask) == mask) unit += string.Format(" {0}", cl); sb.AppendFormat("\tDevice support command classes {0}", unit).AppendLine(); if(csd.ReadBlockLength == 15) sb.AppendLine("\tRead block length size is defined in extended CSD"); @@ -522,7 +519,6 @@ namespace DiscImageChef.Decoders.MMC if(csd.TemporaryWriteProtect) sb.AppendLine("\tDevice is temporarily write protected"); if(!csd.FileFormatGroup) - { switch(csd.FileFormat) { case 0: @@ -538,7 +534,6 @@ namespace DiscImageChef.Decoders.MMC sb.AppendFormat("\tDevice uses unknown file format code {0}", csd.FileFormat).AppendLine(); break; } - } else sb.AppendFormat("\tDevice uses unknown file format code {0} and file format group 1", csd.FileFormat) .AppendLine(); diff --git a/DiscImageChef.Decoders/PCMCIA/CIS.cs b/DiscImageChef.Decoders/PCMCIA/CIS.cs index a61baf239..b69d8e961 100644 --- a/DiscImageChef.Decoders/PCMCIA/CIS.cs +++ b/DiscImageChef.Decoders/PCMCIA/CIS.cs @@ -279,10 +279,7 @@ namespace DiscImageChef.Decoders.PCMCIA else { sb.AppendLine("\tAdditional information:"); - foreach(string info in tuple.AdditionalInformation) - { - if(!string.IsNullOrEmpty(info)) sb.AppendFormat("\t\t{0}", info).AppendLine(); - } + foreach(string info in tuple.AdditionalInformation) if(!string.IsNullOrEmpty(info)) sb.AppendFormat("\t\t{0}", info).AppendLine(); } return sb.ToString(); diff --git a/DiscImageChef.Decoders/SCSI/Inquiry.cs b/DiscImageChef.Decoders/SCSI/Inquiry.cs index f6aac1483..f828a51db 100644 --- a/DiscImageChef.Decoders/SCSI/Inquiry.cs +++ b/DiscImageChef.Decoders/SCSI/Inquiry.cs @@ -223,10 +223,7 @@ namespace DiscImageChef.Decoders.SCSI else descriptorsNo = (SCSIInquiryResponse.Length - 58) / 2; decoded.VersionDescriptors = new ushort[descriptorsNo]; - for(int i = 0; i < descriptorsNo; i++) - { - decoded.VersionDescriptors[i] = BitConverter.ToUInt16(SCSIInquiryResponse, 58 + i * 2); - } + for(int i = 0; i < descriptorsNo; i++) decoded.VersionDescriptors[i] = BitConverter.ToUInt16(SCSIInquiryResponse, 58 + i * 2); } if(SCSIInquiryResponse.Length >= 75 && SCSIInquiryResponse.Length < 96) @@ -500,9 +497,7 @@ namespace DiscImageChef.Decoders.SCSI } if(response.VersionDescriptors != null) - { foreach(ushort VersionDescriptor in response.VersionDescriptors) - { switch(VersionDescriptor) { case 0xFFFF: @@ -1917,8 +1912,6 @@ namespace DiscImageChef.Decoders.SCSI .AppendLine(); break; } - } - } #region Quantum vendor prettifying if(response.QuantumPresent && @@ -2027,10 +2020,8 @@ namespace DiscImageChef.Decoders.SCSI #region Kreon vendor prettifying if(response.KreonPresent) - { sb.AppendFormat("Drive is flashed with Kreon firmware {0}.", StringHandlers.CToString(response.KreonVersion)).AppendLine(); - } #endregion Kreon vendor prettifying #if DEBUG @@ -2051,7 +2042,6 @@ namespace DiscImageChef.Decoders.SCSI } if(response.VendorSpecific != null) - { if(response.KreonPresent) { byte[] vendor = new byte[7]; @@ -2068,7 +2058,6 @@ namespace DiscImageChef.Decoders.SCSI sb.AppendLine(PrintHex.ByteArrayToHexArrayString(response.VendorSpecific, 60)); sb.AppendLine("============================================================"); } - } if(response.VendorSpecific2 != null) { diff --git a/DiscImageChef.Decoders/SCSI/MMC/Features.cs b/DiscImageChef.Decoders/SCSI/MMC/Features.cs index 828de8144..46fc99f08 100644 --- a/DiscImageChef.Decoders/SCSI/MMC/Features.cs +++ b/DiscImageChef.Decoders/SCSI/MMC/Features.cs @@ -3728,10 +3728,8 @@ namespace DiscImageChef.Decoders.SCSI.MMC decoded.ME |= (feature[4] & 0x01) == 0x01; decoded.Profiles = new ushort[feature[5]]; if(feature[5] * 2 + 6 == feature.Length) - { for(int i = 0; i < feature[5]; i++) decoded.Profiles[i] = (ushort)((feature[0 + 6 + 2 * i] << 8) + feature[1 + 6 + 2 * i]); - } } return decoded; @@ -3746,7 +3744,6 @@ namespace DiscImageChef.Decoders.SCSI.MMC sb.AppendLine("MMC Supported Profiles:"); if(ftr.Profiles != null) - { foreach(Profile prof in ftr.Profiles) { switch(prof.Number) @@ -3876,7 +3873,6 @@ namespace DiscImageChef.Decoders.SCSI.MMC if(prof.Current) sb.AppendLine(" (current)"); else sb.AppendLine(); } - } return sb.ToString(); } @@ -4454,10 +4450,8 @@ namespace DiscImageChef.Decoders.SCSI.MMC sb.AppendLine("MMC Layer Jump Recording:"); if(ftr.LinkSizes != null) - { foreach(byte link in ftr.LinkSizes) sb.AppendFormat("\tCurrent media has a {0} bytes link available", link).AppendLine(); - } return sb.ToString(); } @@ -4797,10 +4791,7 @@ namespace DiscImageChef.Decoders.SCSI.MMC Feature_010A ftr = feature.Value; StringBuilder sb = new StringBuilder(); - if(ftr.DCBs != null) - { - foreach(uint DCB in ftr.DCBs) sb.AppendFormat("Drive supports DCB {0:X8}h", DCB).AppendLine(); - } + if(ftr.DCBs != null) foreach(uint DCB in ftr.DCBs) sb.AppendFormat("Drive supports DCB {0:X8}h", DCB).AppendLine(); return sb.ToString(); } @@ -4956,10 +4947,8 @@ namespace DiscImageChef.Decoders.SCSI.MMC if(ftr.ME) sb.AppendLine("\tDrive will only record on the OSSC Disc Format"); if(ftr.Profiles != null) - { for(int i = 0; i < ftr.Profiles.Length; i++) sb.AppendFormat("\tProfile {0}: {1}", i, ftr.Profiles[i]).AppendLine(); - } return sb.ToString(); } diff --git a/DiscImageChef.Decoders/SCSI/MMC/Hybrid.cs b/DiscImageChef.Decoders/SCSI/MMC/Hybrid.cs index daa22ffd4..227001d05 100644 --- a/DiscImageChef.Decoders/SCSI/MMC/Hybrid.cs +++ b/DiscImageChef.Decoders/SCSI/MMC/Hybrid.cs @@ -122,10 +122,7 @@ namespace DiscImageChef.Decoders.SCSI.MMC decoded.FormatLayers = new ushort[(FormatLayersResponse.Length - 6) / 2]; - for(int i = 0; i < (FormatLayersResponse.Length - 6) / 2; i++) - { - decoded.FormatLayers[i] = BigEndianBitConverter.ToUInt16(FormatLayersResponse, i * 2 + 6); - } + for(int i = 0; i < (FormatLayersResponse.Length - 6) / 2; i++) decoded.FormatLayers[i] = BigEndianBitConverter.ToUInt16(FormatLayersResponse, i * 2 + 6); return decoded; } @@ -141,7 +138,6 @@ namespace DiscImageChef.Decoders.SCSI.MMC sb.AppendFormat("{0} format layers recognized", response.NumberOfLayers); for(int i = 0; i < response.FormatLayers.Length; i++) - { switch(response.FormatLayers[i]) { case (ushort)FormatLayerTypeCodes.BDLayer: @@ -181,7 +177,6 @@ namespace DiscImageChef.Decoders.SCSI.MMC break; } } - } return sb.ToString(); } diff --git a/DiscImageChef.Decoders/SCSI/ModesEncoders.cs b/DiscImageChef.Decoders/SCSI/ModesEncoders.cs index add4dde80..a14bfd3aa 100644 --- a/DiscImageChef.Decoders/SCSI/ModesEncoders.cs +++ b/DiscImageChef.Decoders/SCSI/ModesEncoders.cs @@ -89,7 +89,7 @@ namespace DiscImageChef.Decoders.SCSI public static byte[] EncodeMode6(DecodedMode mode, PeripheralDeviceTypes deviceType) { int modeSize = 0; - if(mode.Pages != null) { foreach(ModePage page in mode.Pages) modeSize += page.PageResponse.Length; } + if(mode.Pages != null) foreach(ModePage page in mode.Pages) modeSize += page.PageResponse.Length; byte[] hdr = EncodeModeHeader6(mode.Header, deviceType); modeSize += hdr.Length; @@ -113,7 +113,7 @@ namespace DiscImageChef.Decoders.SCSI public static byte[] EncodeMode10(DecodedMode mode, PeripheralDeviceTypes deviceType) { int modeSize = 0; - if(mode.Pages != null) { foreach(ModePage page in mode.Pages) modeSize += page.PageResponse.Length; } + if(mode.Pages != null) foreach(ModePage page in mode.Pages) modeSize += page.PageResponse.Length; byte[] hdr = EncodeModeHeader10(mode.Header, deviceType); modeSize += hdr.Length; @@ -144,10 +144,8 @@ namespace DiscImageChef.Decoders.SCSI byte[] hdr; if(header.BlockDescriptors != null) - { if(longLBA) hdr = new byte[8 + header.BlockDescriptors.Length * 16]; else hdr = new byte[8 + header.BlockDescriptors.Length * 8]; - } else hdr = new byte[8]; hdr[2] = (byte)header.MediumType; @@ -177,9 +175,7 @@ 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); @@ -196,9 +192,7 @@ namespace DiscImageChef.Decoders.SCSI 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) @@ -211,8 +205,6 @@ namespace DiscImageChef.Decoders.SCSI 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; } diff --git a/DiscImageChef.Decoders/SecureDigital/CSD.cs b/DiscImageChef.Decoders/SecureDigital/CSD.cs index 6874913c1..7feaadc5d 100644 --- a/DiscImageChef.Decoders/SecureDigital/CSD.cs +++ b/DiscImageChef.Decoders/SecureDigital/CSD.cs @@ -327,10 +327,7 @@ namespace DiscImageChef.Decoders.SecureDigital sb.AppendFormat("\tDevice's transfer speed: {0}{1}", result, unit).AppendLine(); unit = ""; - for(int cl = 0, mask = 1; cl <= 11; cl++, mask <<= 1) - { - if((csd.Classes & mask) == mask) unit += string.Format(" {0}", cl); - } + for(int cl = 0, mask = 1; cl <= 11; cl++, mask <<= 1) if((csd.Classes & mask) == mask) unit += string.Format(" {0}", cl); sb.AppendFormat("\tDevice support command classes {0}", unit).AppendLine(); sb.AppendFormat("\tRead block length is {0} bytes", Math.Pow(2, csd.ReadBlockLength)).AppendLine(); @@ -511,7 +508,6 @@ namespace DiscImageChef.Decoders.SecureDigital if(csd.TemporaryWriteProtect) sb.AppendLine("\tDevice is temporarily write protected"); if(!csd.FileFormatGroup) - { switch(csd.FileFormat) { case 0: @@ -527,7 +523,6 @@ namespace DiscImageChef.Decoders.SecureDigital sb.AppendFormat("\tDevice uses unknown file format code {0}", csd.FileFormat).AppendLine(); break; } - } else sb.AppendFormat("\tDevice uses unknown file format code {0} and file format group 1", csd.FileFormat) .AppendLine(); diff --git a/DiscImageChef.Decoders/Xbox/DMI.cs b/DiscImageChef.Decoders/Xbox/DMI.cs index d2d72bf7a..ba01d747e 100644 --- a/DiscImageChef.Decoders/Xbox/DMI.cs +++ b/DiscImageChef.Decoders/Xbox/DMI.cs @@ -46,8 +46,8 @@ namespace DiscImageChef.Decoders.Xbox if(BitConverter.ToUInt32(dmi, 4) != 1) return false; // Catalogue number is two letters, five numbers, one letter - for(int i = 12; i < 14; i++) { if(dmi[i] < 0x41 || dmi[i] > 0x5A) return false; } - for(int i = 14; i < 19; i++) { if(dmi[i] < 0x30 || dmi[i] > 0x39) return false; } + for(int i = 12; i < 14; i++) if(dmi[i] < 0x41 || dmi[i] > 0x5A) return false; + for(int i = 14; i < 19; i++) if(dmi[i] < 0x30 || dmi[i] > 0x39) return false; if(dmi[19] < 0x41 || dmi[19] > 0x5A) return false; diff --git a/DiscImageChef.Devices/Device/Constructor.cs b/DiscImageChef.Devices/Device/Constructor.cs index 422fe082f..0cdfe035e 100644 --- a/DiscImageChef.Devices/Device/Constructor.cs +++ b/DiscImageChef.Devices/Device/Constructor.cs @@ -377,7 +377,6 @@ namespace DiscImageChef.Devices string resolvedLink = Linux.Command.ReadLink("/sys/block/" + devPath); resolvedLink = "/sys" + resolvedLink.Substring(2); if(!string.IsNullOrEmpty(resolvedLink)) - { while(resolvedLink.Contains("usb")) { resolvedLink = System.IO.Path.GetDirectoryName(resolvedLink); @@ -435,7 +434,6 @@ namespace DiscImageChef.Devices break; } } - } } } } @@ -482,7 +480,6 @@ namespace DiscImageChef.Devices string resolvedLink = Linux.Command.ReadLink("/sys/block/" + devPath); resolvedLink = "/sys" + resolvedLink.Substring(2); if(!string.IsNullOrEmpty(resolvedLink)) - { while(resolvedLink.Contains("firewire")) { resolvedLink = System.IO.Path.GetDirectoryName(resolvedLink); @@ -530,7 +527,6 @@ namespace DiscImageChef.Devices break; } } - } } } } @@ -551,7 +547,6 @@ namespace DiscImageChef.Devices string resolvedLink = Linux.Command.ReadLink("/sys/block/" + devPath); resolvedLink = "/sys" + resolvedLink.Substring(2); if(!string.IsNullOrEmpty(resolvedLink)) - { while(resolvedLink.Contains("/sys/devices")) { resolvedLink = System.IO.Path.GetDirectoryName(resolvedLink); @@ -586,7 +581,6 @@ namespace DiscImageChef.Devices } } } - } } } } @@ -656,11 +650,9 @@ namespace DiscImageChef.Devices scsiType = Decoders.SCSI.PeripheralDeviceTypes.DirectAccess; if((ushort)ataid.Value.GeneralConfiguration != 0x848A) - { removable |= (ataid.Value.GeneralConfiguration & Identify.GeneralConfigurationBit.Removable) == Identify.GeneralConfigurationBit.Removable; - } else compactFlash = true; } } @@ -679,7 +671,7 @@ namespace DiscImageChef.Devices if(string.IsNullOrEmpty(manufacturer)) manufacturer = usbManufacturerString; if(string.IsNullOrEmpty(model)) model = usbProductString; if(string.IsNullOrEmpty(serial)) serial = usbSerialString; - else { foreach(char c in serial) { if(char.IsControl(c)) serial = usbSerialString; } } + else foreach(char c in serial) if(char.IsControl(c)) serial = usbSerialString; } if(firewire) @@ -687,10 +679,7 @@ namespace DiscImageChef.Devices if(string.IsNullOrEmpty(manufacturer)) manufacturer = firewireVendorName; if(string.IsNullOrEmpty(model)) model = firewireModelName; if(string.IsNullOrEmpty(serial)) serial = string.Format("{0:X16}", firewireGuid); - else - { - foreach(char c in serial) { if(char.IsControl(c)) serial = string.Format("{0:X16}", firewireGuid); } - } + else foreach(char c in serial) if(char.IsControl(c)) serial = string.Format("{0:X16}", firewireGuid); } } diff --git a/DiscImageChef.Devices/Device/ScsiCommands/SyQuest.cs b/DiscImageChef.Devices/Device/ScsiCommands/SyQuest.cs index 8d100d9e4..16217b498 100644 --- a/DiscImageChef.Devices/Device/ScsiCommands/SyQuest.cs +++ b/DiscImageChef.Devices/Device/ScsiCommands/SyQuest.cs @@ -97,10 +97,8 @@ namespace DiscImageChef.Devices if(readLong) cdb[5] += 0x40; if(!inhibitDma && !readLong) - { if(transferLength == 0) buffer = new byte[256 * blockSize]; else buffer = new byte[transferLength * blockSize]; - } else if(readLong) { buffer = new byte[blockSize]; @@ -182,7 +180,7 @@ namespace DiscImageChef.Devices if(inhibitDma) cdb[9] += 0x80; if(readLong) cdb[9] += 0x40; - if(!inhibitDma && !readLong) { buffer = new byte[transferLength * blockSize]; } + if(!inhibitDma && !readLong) buffer = new byte[transferLength * blockSize]; else if(readLong) { buffer = new byte[blockSize]; diff --git a/DiscImageChef.Devices/Windows/Command.cs b/DiscImageChef.Devices/Windows/Command.cs index 3eaa2959a..a01c22d81 100644 --- a/DiscImageChef.Devices/Windows/Command.cs +++ b/DiscImageChef.Devices/Windows/Command.cs @@ -496,7 +496,7 @@ namespace DiscImageChef.Devices.Windows uint k = 0; if(!Extern.DeviceIoControlGetDeviceNumber(deviceHandle, WindowsIoctl.IoctlStorageGetDeviceNumber, IntPtr.Zero, 0, ref sdn, (uint)Marshal.SizeOf(sdn), ref k, - IntPtr.Zero)) { return uint.MaxValue; } + IntPtr.Zero)) return uint.MaxValue; return (uint)sdn.deviceNumber; } diff --git a/DiscImageChef.Devices/Windows/ListDevices.cs b/DiscImageChef.Devices/Windows/ListDevices.cs index 39d647be9..44afa80a7 100644 --- a/DiscImageChef.Devices/Windows/ListDevices.cs +++ b/DiscImageChef.Devices/Windows/ListDevices.cs @@ -46,10 +46,7 @@ namespace DiscImageChef.Devices.Windows StringBuilder result = new StringBuilder(); const string hextable = "0123456789abcdef"; - for(int i = 0; i < hex.Length / 2; i++) - { - result.Append((char)(16 * hextable.IndexOf(hex[2 * i]) + hextable.IndexOf(hex[2 * i + 1]))); - } + for(int i = 0; i < hex.Length / 2; i++) result.Append((char)(16 * hextable.IndexOf(hex[2 * i]) + hextable.IndexOf(hex[2 * i + 1]))); return result.ToString(); } @@ -150,11 +147,8 @@ namespace DiscImageChef.Devices.Windows start: (int)descriptor.SerialNumberOffset); // fix any serial numbers that are returned as hex-strings - if(Array.TrueForAll(info.Serial.ToCharArray(), (char c) => "0123456789abcdef".IndexOf(c) >= 0) - && (info.Serial.Length == 40)) - { - info.Serial = HexStringToString(info.Serial).Trim(); - } + if(Array.TrueForAll(info.Serial.ToCharArray(), (char c) => "0123456789abcdef".IndexOf(c) >= 0) + && info.Serial.Length == 40) info.Serial = HexStringToString(info.Serial).Trim(); } if(string.IsNullOrEmpty(info.Vendor) || info.Vendor == "ATA") diff --git a/DiscImageChef.Devices/Windows/Usb.cs b/DiscImageChef.Devices/Windows/Usb.cs index 83e8ed215..f93155ed9 100644 --- a/DiscImageChef.Devices/Windows/Usb.cs +++ b/DiscImageChef.Devices/Windows/Usb.cs @@ -532,15 +532,9 @@ namespace DiscImageChef.Devices.Windows int regType = REG_SZ; if(SetupDiGetDeviceRegistryProperty(h, ref da, SPDRP_DEVICEDESC, ref regType, ptrBuf, - BUFFER_SIZE, ref requiredSize)) - { - host.ControllerDeviceDesc = Marshal.PtrToStringAuto(ptrBuf); - } + BUFFER_SIZE, ref requiredSize)) host.ControllerDeviceDesc = Marshal.PtrToStringAuto(ptrBuf); if(SetupDiGetDeviceRegistryProperty(h, ref da, SPDRP_DRIVER, ref regType, ptrBuf, - BUFFER_SIZE, ref requiredSize)) - { - host.ControllerDriverKeyName = Marshal.PtrToStringAuto(ptrBuf); - } + BUFFER_SIZE, ref requiredSize)) host.ControllerDriverKeyName = Marshal.PtrToStringAuto(ptrBuf); } hostList.Add(host); } @@ -855,7 +849,7 @@ namespace DiscImageChef.Devices.Windows // return a down stream external hub internal UsbDevice GetDevice() { - if(!PortIsDeviceConnected) { return null; } + if(!PortIsDeviceConnected) return null; UsbDevice device = new UsbDevice(); @@ -1011,7 +1005,7 @@ namespace DiscImageChef.Devices.Windows // return a down stream external hub internal UsbHub GetHub() { - if(!PortIsHub) { return null; } + if(!PortIsHub) return null; UsbHub hub = new UsbHub(); IntPtr h, h2; @@ -1189,19 +1183,13 @@ namespace DiscImageChef.Devices.Windows keyName = ""; if(SetupDiGetDeviceRegistryProperty(h, ref da, SPDRP_DRIVER, ref regType, ptrBuf, BUFFER_SIZE, - ref requiredSize)) - { - keyName = Marshal.PtrToStringAuto(ptrBuf); - } + ref requiredSize)) keyName = Marshal.PtrToStringAuto(ptrBuf); // is it a match? if(keyName == driverKeyName) { if(SetupDiGetDeviceRegistryProperty(h, ref da, SPDRP_DEVICEDESC, ref regType, ptrBuf, - BUFFER_SIZE, ref requiredSize)) - { - ans = Marshal.PtrToStringAuto(ptrBuf); - } + BUFFER_SIZE, ref requiredSize)) ans = Marshal.PtrToStringAuto(ptrBuf); break; } } @@ -1250,10 +1238,7 @@ namespace DiscImageChef.Devices.Windows keyName = ""; if(SetupDiGetDeviceRegistryProperty(h, ref da, SPDRP_DRIVER, ref regType, ptrBuf, BUFFER_SIZE, - ref requiredSize)) - { - keyName = Marshal.PtrToStringAuto(ptrBuf); - } + ref requiredSize)) keyName = Marshal.PtrToStringAuto(ptrBuf); // is it a match? if(keyName == driverKeyName) diff --git a/DiscImageChef.Devices/Windows/UsbFunctions.cs b/DiscImageChef.Devices/Windows/UsbFunctions.cs index c0b6f0090..87d211b35 100644 --- a/DiscImageChef.Devices/Windows/UsbFunctions.cs +++ b/DiscImageChef.Devices/Windows/UsbFunctions.cs @@ -50,7 +50,7 @@ namespace DiscImageChef.Devices.Windows { List devList = new List(); - foreach(UsbController controller in GetHostControllers()) { ListHub(controller.GetRootHub(), devList); } + foreach(UsbController controller in GetHostControllers()) ListHub(controller.GetRootHub(), devList); return devList; } @@ -59,14 +59,8 @@ namespace DiscImageChef.Devices.Windows static void ListHub(UsbHub hub, List devList) { foreach(UsbPort port in hub.GetPorts()) - { - if(port.IsHub) - { - // recursive - ListHub(port.GetHub(), devList); - } - else { if(port.IsDeviceConnected) { devList.Add(port.GetDevice()); } } - } + if(port.IsHub) ListHub(port.GetHub(), devList); + else { if(port.IsDeviceConnected) devList.Add(port.GetDevice()); } } // @@ -89,12 +83,7 @@ namespace DiscImageChef.Devices.Windows static void SearchHubDriverKeyName(UsbHub hub, ref UsbDevice foundDevice, string driverKeyName) { foreach(UsbPort port in hub.GetPorts()) - { - if(port.IsHub) - { - // recursive - SearchHubDriverKeyName(port.GetHub(), ref foundDevice, driverKeyName); - } + if(port.IsHub) SearchHubDriverKeyName(port.GetHub(), ref foundDevice, driverKeyName); else { if(port.IsDeviceConnected) @@ -107,7 +96,6 @@ namespace DiscImageChef.Devices.Windows } } } - } } // @@ -130,12 +118,7 @@ namespace DiscImageChef.Devices.Windows static void SearchHubInstanceId(UsbHub hub, ref UsbDevice foundDevice, string instanceId) { foreach(UsbPort port in hub.GetPorts()) - { - if(port.IsHub) - { - // recursive - SearchHubInstanceId(port.GetHub(), ref foundDevice, instanceId); - } + if(port.IsHub) SearchHubInstanceId(port.GetHub(), ref foundDevice, instanceId); else { if(port.IsDeviceConnected) @@ -148,7 +131,6 @@ namespace DiscImageChef.Devices.Windows } } } - } } const int IOCTL_STORAGE_GET_DEVICE_NUMBER = 0x2D1080; @@ -198,7 +180,7 @@ namespace DiscImageChef.Devices.Windows // DriveLetter. We'll use this later to find a matching // DevicePath "symbolic name" int devNum = GetDeviceNumber(@"\\.\" + driveLetter.TrimEnd('\\')); - if(devNum < 0) { return null; } + if(devNum < 0) return null; return FindDeviceNumber(devNum, deviceGuid); } @@ -212,7 +194,7 @@ namespace DiscImageChef.Devices.Windows // DriveLetter. We'll use this later to find a matching // DevicePath "symbolic name" int devNum = GetDeviceNumber(drivePath); - if(devNum < 0) { return null; } + if(devNum < 0) return null; return FindDeviceNumber(devNum, deviceGuid); } @@ -256,10 +238,6 @@ namespace DiscImageChef.Devices.Windows int nRequiredSize = 0; int nBytes = BUFFER_SIZE; if(SetupDiGetDeviceInterfaceDetail(h, ref dia, ref didd, nBytes, ref nRequiredSize, ref da)) - { - // Now that we have a DevicePath... we can use it to - // generate another DeviceNumber to see if it matches - // the one we're looking for. if(GetDeviceNumber(didd.DevicePath) == devNum) { // current InstanceID is at the "USBSTOR" level, so we @@ -276,7 +254,6 @@ namespace DiscImageChef.Devices.Windows System.Console.WriteLine("InstanceId: {0}", instanceId); //break; } - } } i++; } @@ -286,7 +263,7 @@ namespace DiscImageChef.Devices.Windows } // Did we find an InterfaceID of a USB device? - if(instanceId.StartsWith("USB\\")) { foundDevice = FindDeviceByInstanceId(instanceId); } + if(instanceId.StartsWith("USB\\")) foundDevice = FindDeviceByInstanceId(instanceId); return foundDevice; } diff --git a/DiscImageChef.DiscImages/Alcohol120.cs b/DiscImageChef.DiscImages/Alcohol120.cs index 081e5b4dd..cab796d73 100644 --- a/DiscImageChef.DiscImages/Alcohol120.cs +++ b/DiscImageChef.DiscImages/Alcohol120.cs @@ -360,7 +360,6 @@ namespace DiscImageChef.DiscImages alcTrackExtras = new Dictionary(); foreach(AlcoholTrack track in alcTracks.Values) - { if(track.extraOffset > 0 && !isDvd) { byte[] extHdr = new byte[8]; @@ -385,7 +384,6 @@ namespace DiscImageChef.DiscImages extra.sectors = track.extraOffset; alcTrackExtras.Add(track.point, extra); } - } if(footerOff > 0) { @@ -432,7 +430,6 @@ namespace DiscImageChef.DiscImages int readBytes = stream.Read(bca, 0, bca.Length); if(readBytes == bca.Length) - { switch(header.type) { case AlcoholMediumType.DVD: @@ -440,7 +437,6 @@ namespace DiscImageChef.DiscImages ImageInfo.ReadableMediaTags.Add(MediaTagType.DVD_BCA); break; } - } } ImageInfo.MediaType = AlcoholMediumTypeToMediaType(header.type); @@ -741,13 +737,10 @@ namespace DiscImageChef.DiscImages } if(ImageInfo.MediaType == MediaType.XGD2) - { - // All XGD3 all have the same number of blocks if(ImageInfo.Sectors == 25063 || // Locked (or non compatible drive) ImageInfo.Sectors == 4229664 || // Xtreme unlock ImageInfo.Sectors == 4246304) // Wxripper unlock ImageInfo.MediaType = MediaType.XGD3; - } DicConsole.VerboseWriteLine("Alcohol 120% image describes a disc of type {0}", ImageInfo.MediaType); @@ -780,25 +773,25 @@ namespace DiscImageChef.DiscImages { case MediaTagType.DVD_BCA: { - if(bca != null) { return (byte[])bca.Clone(); } + if(bca != null) return (byte[])bca.Clone(); throw new FeatureNotPresentImageException("Image does not contain BCA information."); } case MediaTagType.DVD_PFI: { - if(pfi != null) { return (byte[])pfi.Clone(); } + if(pfi != null) return (byte[])pfi.Clone(); throw new FeatureNotPresentImageException("Image does not contain PFI."); } case MediaTagType.DVD_DMI: { - if(dmi != null) { return (byte[])dmi.Clone(); } + if(dmi != null) return (byte[])dmi.Clone(); throw new FeatureNotPresentImageException("Image does not contain DMI."); } case MediaTagType.CD_FullTOC: { - if(fullToc != null) { return (byte[])fullToc.Clone(); } + if(fullToc != null) return (byte[])fullToc.Clone(); throw new FeatureNotPresentImageException("Image does not contain TOC information."); } @@ -830,21 +823,15 @@ namespace DiscImageChef.DiscImages public override byte[] ReadSectors(ulong sectorAddress, uint length) { foreach(KeyValuePair kvp in offsetmap) - { if(sectorAddress >= kvp.Value) - { foreach(AlcoholTrack track in alcTracks.Values) { AlcoholTrackExtra extra; if(track.point == kvp.Key && alcTrackExtras.TryGetValue(track.point, out extra)) - { if(sectorAddress - kvp.Value < extra.sectors) return ReadSectors(sectorAddress - kvp.Value, length, kvp.Key); - } } - } - } throw new ArgumentOutOfRangeException(nameof(sectorAddress), "Sector address not found"); } @@ -852,21 +839,15 @@ namespace DiscImageChef.DiscImages public override byte[] ReadSectorsTag(ulong sectorAddress, uint length, SectorTagType tag) { foreach(KeyValuePair kvp in offsetmap) - { if(sectorAddress >= kvp.Value) - { foreach(AlcoholTrack track in alcTracks.Values) { AlcoholTrackExtra extra; if(track.point == kvp.Key && alcTrackExtras.TryGetValue(track.point, out extra)) - { if(sectorAddress - kvp.Value < extra.sectors) return ReadSectorsTag(sectorAddress - kvp.Value, length, kvp.Key, tag); - } } - } - } throw new ArgumentOutOfRangeException(nameof(sectorAddress), "Sector address not found"); } @@ -957,7 +938,6 @@ namespace DiscImageChef.DiscImages SeekOrigin.Begin); if(sector_offset == 0 && sector_skip == 0) buffer = br.ReadBytes((int)(sector_size * length)); else - { for(int i = 0; i < length; i++) { byte[] sector; @@ -966,7 +946,6 @@ namespace DiscImageChef.DiscImages br.BaseStream.Seek(sector_skip, SeekOrigin.Current); Array.Copy(sector, 0, buffer, i * sector_size, sector_size); } - } return buffer; } @@ -1287,7 +1266,6 @@ namespace DiscImageChef.DiscImages SeekOrigin.Begin); if(sector_offset == 0 && sector_skip == 0) buffer = br.ReadBytes((int)(sector_size * length)); else - { for(int i = 0; i < length; i++) { byte[] sector; @@ -1296,7 +1274,6 @@ namespace DiscImageChef.DiscImages br.BaseStream.Seek(sector_skip, SeekOrigin.Current); Array.Copy(sector, 0, buffer, i * sector_size, sector_size); } - } return buffer; } @@ -1314,21 +1291,15 @@ namespace DiscImageChef.DiscImages public override byte[] ReadSectorsLong(ulong sectorAddress, uint length) { foreach(KeyValuePair kvp in offsetmap) - { if(sectorAddress >= kvp.Value) - { foreach(AlcoholTrack track in alcTracks.Values) { AlcoholTrackExtra extra; if(track.point == kvp.Key && alcTrackExtras.TryGetValue(track.point, out extra)) - { if(sectorAddress - kvp.Value < extra.sectors) return ReadSectorsLong(sectorAddress - kvp.Value, length, kvp.Key); - } } - } - } throw new ArgumentOutOfRangeException(nameof(sectorAddress), "Sector address not found"); } @@ -1415,13 +1386,11 @@ namespace DiscImageChef.DiscImages ushort sessionNo = 0; foreach(Session session in sessions) - { if(track.point >= session.StartTrack || track.point <= session.EndTrack) { sessionNo = session.SessionSequence; break; } - } AlcoholTrackExtra extra; if(alcTrackExtras.TryGetValue(track.point, out extra)) @@ -1465,7 +1434,7 @@ namespace DiscImageChef.DiscImages public override List GetSessionTracks(Session session) { - if(sessions.Contains(session)) { return GetSessionTracks(session.SessionSequence); } + if(sessions.Contains(session)) return GetSessionTracks(session.SessionSequence); throw new ImageNotSupportedException("Session does not exist in disc image"); } @@ -1479,13 +1448,11 @@ namespace DiscImageChef.DiscImages ushort sessionNo = 0; foreach(Session ses in sessions) - { if(track.point >= ses.StartTrack || track.point <= ses.EndTrack) { sessionNo = ses.SessionSequence; break; } - } AlcoholTrackExtra extra; if(alcTrackExtras.TryGetValue(track.point, out extra) && session == sessionNo) diff --git a/DiscImageChef.DiscImages/AppleNIB.cs b/DiscImageChef.DiscImages/AppleNIB.cs index 9931caa75..84d6a9f3c 100644 --- a/DiscImageChef.DiscImages/AppleNIB.cs +++ b/DiscImageChef.DiscImages/AppleNIB.cs @@ -123,10 +123,7 @@ namespace DiscImageChef.DiscImages int spt = 0; bool allTracksEqual = true; - for(int i = 1; i < tracks.Count; i++) - { - allTracksEqual &= tracks[i - 1].sectors.Length == tracks[i].sectors.Length; - } + for(int i = 1; i < tracks.Count; i++) allTracksEqual &= tracks[i - 1].sectors.Length == tracks[i].sectors.Length; if(allTracksEqual) spt = tracks[0].sectors.Length; @@ -185,9 +182,7 @@ namespace DiscImageChef.DiscImages } for(int i = 0; i < tracks.Count; i++) - { foreach(Apple2.RawSector sector in tracks[i].sectors) - { if(skewed && spt != 0) { ulong sectorNo = (ulong)((((sector.addressField.sector[0] & 0x55) << 1) | @@ -203,8 +198,6 @@ namespace DiscImageChef.DiscImages rawSectors.Add(ImageInfo.Sectors, sector); ImageInfo.Sectors++; } - } - } DicConsole.DebugWriteLine("Apple NIB Plugin", "Got {0} sectors", ImageInfo.Sectors); diff --git a/DiscImageChef.DiscImages/Apridisk.cs b/DiscImageChef.DiscImages/Apridisk.cs index 180d4c9bf..0301e0987 100644 --- a/DiscImageChef.DiscImages/Apridisk.cs +++ b/DiscImageChef.DiscImages/Apridisk.cs @@ -286,10 +286,7 @@ namespace DiscImageChef.DiscImages uint spt = uint.MaxValue; for(ushort cyl = 0; cyl < ImageInfo.Cylinders; cyl++) { - for(ushort head = 0; head < ImageInfo.Heads; head++) - { - if(spts[cyl][head] < spt) spt = spts[cyl][head]; - } + for(ushort head = 0; head < ImageInfo.Heads; head++) if(spts[cyl][head] < spt) spt = spts[cyl][head]; } ImageInfo.SectorsPerTrack = spt; diff --git a/DiscImageChef.DiscImages/BLU.cs b/DiscImageChef.DiscImages/BLU.cs index 6d547a15d..0f4d98cae 100644 --- a/DiscImageChef.DiscImages/BLU.cs +++ b/DiscImageChef.DiscImages/BLU.cs @@ -111,7 +111,7 @@ namespace DiscImageChef.DiscImages tmpHdr.DeviceBlocks = BigEndianBitConverter.ToUInt32(header, 0x11) & 0x00FFFFFF; tmpHdr.BytesPerBlock = BigEndianBitConverter.ToUInt16(header, 0x15); - for(int i = 0; i < 0xD; i++) { if(tmpHdr.DeviceName[i] < 0x20) return false; } + for(int i = 0; i < 0xD; i++) if(tmpHdr.DeviceName[i] < 0x20) return false; if((tmpHdr.BytesPerBlock & 0xFE00) != 0x200) return false; @@ -140,7 +140,7 @@ namespace DiscImageChef.DiscImages DicConsole.DebugWriteLine("BLU plugin", "ImageHeader.deviceBlock = {0}", imageHeader.DeviceBlocks); DicConsole.DebugWriteLine("BLU plugin", "ImageHeader.bytesPerBlock = {0}", imageHeader.BytesPerBlock); - for(int i = 0; i < 0xD; i++) { if(imageHeader.DeviceName[i] < 0x20) return false; } + for(int i = 0; i < 0xD; i++) if(imageHeader.DeviceName[i] < 0x20) return false; if((imageHeader.BytesPerBlock & 0xFE00) != 0x200) return false; diff --git a/DiscImageChef.DiscImages/BlindWrite4.cs b/DiscImageChef.DiscImages/BlindWrite4.cs index eb09bd725..135bd6362 100644 --- a/DiscImageChef.DiscImages/BlindWrite4.cs +++ b/DiscImageChef.DiscImages/BlindWrite4.cs @@ -546,7 +546,6 @@ namespace DiscImageChef.DiscImages FiltersList filtersList = new FiltersList(); if(!string.IsNullOrEmpty(header.DataFile)) - { while(true) { dataFilter = filtersList.GetFilter(Path.Combine(imageFilter.GetParentFolder(), header.DataFile)); @@ -587,7 +586,6 @@ namespace DiscImageChef.DiscImages throw new ArgumentException(string.Format("Data file {0} not found", header.DataFile)); } - } else throw new ArgumentException("Unable to find data file"); if(!string.IsNullOrEmpty(header.SubchannelFile)) @@ -644,7 +642,6 @@ namespace DiscImageChef.DiscImages ushort maxSession = 0; ulong currentPos = 0; foreach(Bw4TrackDescriptor bwTrack in bwTracks) - { if(bwTrack.point < 0xA0) { Track track = new Track(); @@ -652,7 +649,6 @@ namespace DiscImageChef.DiscImages track.TrackEndSector = bwTrack.lastSector; if(!string.IsNullOrEmpty(bwTrack.filename)) - { do { track.TrackFilter = @@ -699,7 +695,6 @@ namespace DiscImageChef.DiscImages track.TrackFilter = dataFilter; } while(true); - } else track.TrackFilter = dataFilter; track.TrackFile = dataFilter.GetFilename(); @@ -803,7 +798,6 @@ namespace DiscImageChef.DiscImages !ImageInfo.ReadableMediaTags.Contains(MediaTagType.CD_MCN)) ImageInfo.ReadableMediaTags.Add(MediaTagType.CD_MCN); } - } sessions = new List(); for(ushort i = 1; i <= maxSession; i++) @@ -814,7 +808,6 @@ namespace DiscImageChef.DiscImages session.StartSector = uint.MaxValue; foreach(Track track in tracks) - { if(track.TrackSession == i) { if(track.TrackSequence < session.StartTrack) session.StartTrack = track.TrackSequence; @@ -822,7 +815,6 @@ namespace DiscImageChef.DiscImages if(track.TrackStartSector < session.StartSector) session.StartSector = track.TrackStartSector; if(track.TrackEndSector > session.EndSector) session.EndSector = track.TrackEndSector; } - } sessions.Add(session); } @@ -907,10 +899,7 @@ namespace DiscImageChef.DiscImages { case MediaTagType.CD_MCN: { - if(ImageInfo.MediaSerialNumber != null) - { - return Encoding.ASCII.GetBytes(ImageInfo.MediaSerialNumber); - } + if(ImageInfo.MediaSerialNumber != null) return Encoding.ASCII.GetBytes(ImageInfo.MediaSerialNumber); throw new FeatureNotPresentImageException("Image does not contain MCN information."); } @@ -942,19 +931,11 @@ namespace DiscImageChef.DiscImages public override byte[] ReadSectors(ulong sectorAddress, uint length) { foreach(KeyValuePair kvp in offsetmap) - { if(sectorAddress >= kvp.Value) - { foreach(Track track in tracks) - { if(track.TrackSequence == kvp.Key) - { if(sectorAddress - kvp.Value < track.TrackEndSector - track.TrackStartSector + 1) return ReadSectors(sectorAddress - kvp.Value, length, kvp.Key); - } - } - } - } throw new ArgumentOutOfRangeException(nameof(sectorAddress), "Sector address not found"); } @@ -962,19 +943,11 @@ namespace DiscImageChef.DiscImages public override byte[] ReadSectorsTag(ulong sectorAddress, uint length, SectorTagType tag) { foreach(KeyValuePair kvp in offsetmap) - { if(sectorAddress >= kvp.Value) - { foreach(Track track in tracks) - { if(track.TrackSequence == kvp.Key) - { if(sectorAddress - kvp.Value < track.TrackEndSector - track.TrackStartSector + 1) return ReadSectorsTag(sectorAddress - kvp.Value, length, kvp.Key, tag); - } - } - } - } throw new ArgumentOutOfRangeException(nameof(sectorAddress), "Sector address not found"); } @@ -986,13 +959,11 @@ namespace DiscImageChef.DiscImages _track.TrackSequence = 0; foreach(Track bwTrack in tracks) - { if(bwTrack.TrackSequence == track) { _track = bwTrack; break; } - } if(_track.TrackSequence == 0) throw new ArgumentOutOfRangeException(nameof(track), "Track does not exist in disc image"); @@ -1051,7 +1022,6 @@ namespace DiscImageChef.DiscImages SeekOrigin.Begin); if(sectorOffset == 0 && sectorSkip == 0) buffer = br.ReadBytes((int)(sectorSize * length)); else - { for(int i = 0; i < length; i++) { byte[] sector; @@ -1060,7 +1030,6 @@ namespace DiscImageChef.DiscImages br.BaseStream.Seek(sectorSkip, SeekOrigin.Current); Array.Copy(sector, 0, buffer, i * sectorSize, sectorSize); } - } return buffer; } @@ -1072,13 +1041,11 @@ namespace DiscImageChef.DiscImages _track.TrackSequence = 0; foreach(Track bwTrack in tracks) - { if(bwTrack.TrackSequence == track) { _track = bwTrack; break; } - } if(_track.TrackSequence == 0) throw new ArgumentOutOfRangeException(nameof(track), "Track does not exist in disc image"); @@ -1223,7 +1190,6 @@ namespace DiscImageChef.DiscImages SeekOrigin.Begin); if(sectorOffset == 0 && sectorSkip == 0) buffer = br.ReadBytes((int)(sectorSize * length)); else - { for(int i = 0; i < length; i++) { byte[] sector; @@ -1232,7 +1198,6 @@ namespace DiscImageChef.DiscImages br.BaseStream.Seek(sectorSkip, SeekOrigin.Current); Array.Copy(sector, 0, buffer, i * sectorSize, sectorSize); } - } return buffer; } @@ -1250,19 +1215,11 @@ namespace DiscImageChef.DiscImages public override byte[] ReadSectorsLong(ulong sectorAddress, uint length) { foreach(KeyValuePair kvp in offsetmap) - { if(sectorAddress >= kvp.Value) - { foreach(Track track in tracks) - { if(track.TrackSequence == kvp.Key) - { if(sectorAddress - kvp.Value < track.TrackEndSector - track.TrackStartSector + 1) return ReadSectorsLong(sectorAddress - kvp.Value, length, kvp.Key); - } - } - } - } throw new ArgumentOutOfRangeException(nameof(sectorAddress), "Sector address not found"); } @@ -1274,13 +1231,11 @@ namespace DiscImageChef.DiscImages _track.TrackSequence = 0; foreach(Track bwTrack in tracks) - { if(bwTrack.TrackSequence == track) { _track = bwTrack; break; } - } if(_track.TrackSequence == 0) throw new ArgumentOutOfRangeException(nameof(track), "Track does not exist in disc image"); @@ -1356,7 +1311,7 @@ namespace DiscImageChef.DiscImages public override List GetSessionTracks(Session session) { - if(sessions.Contains(session)) { return GetSessionTracks(session.SessionSequence); } + if(sessions.Contains(session)) return GetSessionTracks(session.SessionSequence); throw new ImageNotSupportedException("Session does not exist in disc image"); } @@ -1364,7 +1319,7 @@ namespace DiscImageChef.DiscImages public override List GetSessionTracks(ushort session) { List tracks = new List(); - foreach(Track _track in this.tracks) { if(_track.TrackSession == session) tracks.Add(_track); } + foreach(Track _track in this.tracks) if(_track.TrackSession == session) tracks.Add(_track); return tracks; } diff --git a/DiscImageChef.DiscImages/BlindWrite5.cs b/DiscImageChef.DiscImages/BlindWrite5.cs index 0fefad1a3..908c6eaf3 100644 --- a/DiscImageChef.DiscImages/BlindWrite5.cs +++ b/DiscImageChef.DiscImages/BlindWrite5.cs @@ -595,12 +595,10 @@ namespace DiscImageChef.DiscImages tSeq, session.Tracks[tSeq].unknown8); if(session.Tracks[tSeq].type != Bw5TrackType.Dvd && session.Tracks[tSeq].type != Bw5TrackType.NotData) - { for(int i = 0; i < session.Tracks[tSeq].unknown9.Length; i++) DicConsole.DebugWriteLine("BlindWrite5 plugin", "session[{0}].track[{1}].unknown9[{2}] = 0x{3:X8}", ses, tSeq, i, session.Tracks[tSeq].unknown9[i]); - } } bwSessions.Add(session); @@ -737,7 +735,6 @@ namespace DiscImageChef.DiscImages long sectorSize = dataFile.Length / dataFile.Sectors; if(sectorSize > 2352) - { if(sectorSize - 2352 == 16) chars.Subchannel = TrackSubchannelType.Q16Interleaved; else if(sectorSize - 2352 == 96) chars.Subchannel = TrackSubchannelType.PackedInterleaved; else @@ -745,7 +742,6 @@ namespace DiscImageChef.DiscImages DicConsole.ErrorWriteLine("BlindWrite5 found unknown subchannel size: {0}", sectorSize - 2352); return false; } - } else chars.Subchannel = TrackSubchannelType.None; chars.SectorSize = sectorSize; @@ -866,7 +862,6 @@ namespace DiscImageChef.DiscImages track.TrackEndSector = (ulong)(trk.sectors + trk.startLba); foreach(DataFileCharacteristics chars in filePaths) - { if(trk.startLba >= chars.StartLba && trk.startLba + trk.sectors <= chars.StartLba + chars.Sectors) { @@ -884,15 +879,12 @@ namespace DiscImageChef.DiscImages track.TrackSubchannelOffset = track.TrackFileOffset; if(chars.Subchannel == TrackSubchannelType.PackedInterleaved) - { if(!ImageInfo.ReadableSectorTags.Contains(SectorTagType.CdSectorSubchannel)) ImageInfo.ReadableSectorTags.Add(SectorTagType.CdSectorSubchannel); - } } break; } - } track.TrackPregap = trk.pregap; track.TrackSequence = trk.point; @@ -963,7 +955,7 @@ namespace DiscImageChef.DiscImages DicConsole.DebugWriteLine("BlindWrite5 plugin", "TOC not correctly rebuilt"); fullToc = null; } - else { DicConsole.DebugWriteLine("BlindWrite5 plugin", "TOC correctly rebuilt"); } + else DicConsole.DebugWriteLine("BlindWrite5 plugin", "TOC correctly rebuilt"); ImageInfo.ReadableSectorTags.Add(SectorTagType.CdTrackFlags); } @@ -1090,13 +1082,11 @@ namespace DiscImageChef.DiscImages Decoders.CD.PMA.CDPMA pma0 = Decoders.CD.PMA.Decode(pma).Value; foreach(Decoders.CD.PMA.CDPMADescriptors descriptor in pma0.PMADescriptors) - { if(descriptor.ADR == 2) { uint id = (uint)((descriptor.Min << 16) + (descriptor.Sec << 8) + descriptor.Frame); ImageInfo.MediaSerialNumber = string.Format("{0:X6}", id & 0x00FFFFFF); } - } } if(atip != null) @@ -1135,22 +1125,17 @@ namespace DiscImageChef.DiscImages if(atip != null) ImageInfo.ReadableMediaTags.Add(MediaTagType.CD_ATIP); if(cdtext != null) ImageInfo.ReadableMediaTags.Add(MediaTagType.CD_TEXT); if(bca != null) - { if(isDvd) ImageInfo.ReadableMediaTags.Add(MediaTagType.DVD_BCA); else if(isBd) ImageInfo.ReadableMediaTags.Add(MediaTagType.BD_BCA); - } if(dmi != null) ImageInfo.ReadableMediaTags.Add(MediaTagType.DVD_DMI); if(pfi != null) ImageInfo.ReadableMediaTags.Add(MediaTagType.DVD_PFI); if(fullToc != null) ImageInfo.ReadableMediaTags.Add(MediaTagType.CD_FullTOC); if(ImageInfo.MediaType == MediaType.XGD2) - { - // All XGD3 all have the same number of blocks if(ImageInfo.Sectors == 25063 || // Locked (or non compatible drive) ImageInfo.Sectors == 4229664 || // Xtreme unlock ImageInfo.Sectors == 4246304) // Wxripper unlock ImageInfo.MediaType = MediaType.XGD3; - } DicConsole.VerboseWriteLine("BlindWrite image describes a disc of type {0}", ImageInfo.MediaType); @@ -1183,50 +1168,50 @@ namespace DiscImageChef.DiscImages { case MediaTagType.SCSI_MODEPAGE_2A: { - if(mode2A != null) { return (byte[])mode2A.Clone(); } + if(mode2A != null) return (byte[])mode2A.Clone(); throw new FeatureNotPresentImageException("Image does not contain SCSI MODE PAGE 2Ah."); } case MediaTagType.CD_PMA: { - if(pma != null) { return (byte[])pma.Clone(); } + if(pma != null) return (byte[])pma.Clone(); throw new FeatureNotPresentImageException("Image does not contain PMA information."); } case MediaTagType.CD_ATIP: { - if(atip != null) { return (byte[])atip.Clone(); } + if(atip != null) return (byte[])atip.Clone(); throw new FeatureNotPresentImageException("Image does not contain ATIP information."); } case MediaTagType.CD_TEXT: { - if(cdtext != null) { return (byte[])cdtext.Clone(); } + if(cdtext != null) return (byte[])cdtext.Clone(); throw new FeatureNotPresentImageException("Image does not contain CD-Text information."); } case MediaTagType.DVD_BCA: case MediaTagType.BD_BCA: { - if(bca != null) { return (byte[])bca.Clone(); } + if(bca != null) return (byte[])bca.Clone(); throw new FeatureNotPresentImageException("Image does not contain BCA information."); } case MediaTagType.DVD_PFI: { - if(pfi != null) { return (byte[])pfi.Clone(); } + if(pfi != null) return (byte[])pfi.Clone(); throw new FeatureNotPresentImageException("Image does not contain PFI."); } case MediaTagType.DVD_DMI: { - if(dmi != null) { return (byte[])dmi.Clone(); } + if(dmi != null) return (byte[])dmi.Clone(); throw new FeatureNotPresentImageException("Image does not contain DMI."); } case MediaTagType.CD_FullTOC: { - if(fullToc != null) { return (byte[])fullToc.Clone(); } + if(fullToc != null) return (byte[])fullToc.Clone(); throw new FeatureNotPresentImageException("Image does not contain TOC information."); } @@ -1258,19 +1243,11 @@ namespace DiscImageChef.DiscImages public override byte[] ReadSectors(ulong sectorAddress, uint length) { foreach(KeyValuePair kvp in offsetmap) - { if(sectorAddress >= kvp.Value) - { foreach(Track track in tracks) - { if(track.TrackSequence == kvp.Key) - { if(sectorAddress - kvp.Value < track.TrackEndSector - track.TrackStartSector) return ReadSectors(sectorAddress - kvp.Value, length, kvp.Key); - } - } - } - } throw new ArgumentOutOfRangeException(nameof(sectorAddress), "Sector address not found"); } @@ -1278,19 +1255,11 @@ namespace DiscImageChef.DiscImages public override byte[] ReadSectorsTag(ulong sectorAddress, uint length, SectorTagType tag) { foreach(KeyValuePair kvp in offsetmap) - { if(sectorAddress >= kvp.Value) - { foreach(Track track in tracks) - { if(track.TrackSequence == kvp.Key) - { if(sectorAddress - kvp.Value < track.TrackEndSector - track.TrackStartSector) return ReadSectorsTag(sectorAddress - kvp.Value, length, kvp.Key, tag); - } - } - } - } throw new ArgumentOutOfRangeException(nameof(sectorAddress), "Sector address not found"); } @@ -1304,13 +1273,11 @@ namespace DiscImageChef.DiscImages _track.TrackSequence = 0; foreach(Track bwTrack in tracks) - { if(bwTrack.TrackSequence == track) { _track = bwTrack; break; } - } if(_track.TrackSequence == 0) throw new ArgumentOutOfRangeException(nameof(track), "Track does not exist in disc image"); @@ -1322,13 +1289,11 @@ namespace DiscImageChef.DiscImages length + sectorAddress, _track.TrackEndSector)); foreach(DataFileCharacteristics _chars in filePaths) - { if((long)sectorAddress >= _chars.StartLba && length < (ulong)_chars.Sectors - sectorAddress) { chars = _chars; break; } - } if(string.IsNullOrEmpty(chars.FilePath) || chars.FileFilter == null) throw new ArgumentOutOfRangeException(nameof(chars.FileFilter), "Track does not exist in disc image"); @@ -1408,7 +1373,6 @@ namespace DiscImageChef.DiscImages if(sectorOffset == 0 && sectorSkip == 0) buffer = br.ReadBytes((int)(sectorSize * length)); else - { for(int i = 0; i < length; i++) { byte[] sector; @@ -1417,7 +1381,6 @@ namespace DiscImageChef.DiscImages br.BaseStream.Seek(sectorSkip, SeekOrigin.Current); Array.Copy(sector, 0, buffer, i * sectorSize, sectorSize); } - } return buffer; } @@ -1431,13 +1394,11 @@ namespace DiscImageChef.DiscImages _track.TrackSequence = 0; foreach(Track bwTrack in tracks) - { if(bwTrack.TrackSequence == track) { _track = bwTrack; break; } - } if(_track.TrackSequence == 0) throw new ArgumentOutOfRangeException(nameof(track), "Track does not exist in disc image"); @@ -1449,13 +1410,11 @@ namespace DiscImageChef.DiscImages length + sectorAddress, _track.TrackEndSector)); foreach(DataFileCharacteristics _chars in filePaths) - { if((long)sectorAddress >= _chars.StartLba && length < (ulong)_chars.Sectors - sectorAddress) { chars = _chars; break; } - } if(string.IsNullOrEmpty(chars.FilePath) || chars.FileFilter == null) throw new ArgumentOutOfRangeException(nameof(chars.FileFilter), "Track does not exist in disc image"); @@ -1701,7 +1660,6 @@ namespace DiscImageChef.DiscImages SeekOrigin.Begin); if(sectorOffset == 0 && sectorSkip == 0) buffer = br.ReadBytes((int)(sectorSize * length)); else - { for(int i = 0; i < length; i++) { byte[] sector; @@ -1710,7 +1668,6 @@ namespace DiscImageChef.DiscImages br.BaseStream.Seek(sectorSkip, SeekOrigin.Current); Array.Copy(sector, 0, buffer, i * sectorSize, sectorSize); } - } return buffer; } @@ -1728,19 +1685,11 @@ namespace DiscImageChef.DiscImages public override byte[] ReadSectorsLong(ulong sectorAddress, uint length) { foreach(KeyValuePair kvp in offsetmap) - { if(sectorAddress >= kvp.Value) - { foreach(Track track in tracks) - { if(track.TrackSequence == kvp.Key) - { if(sectorAddress - kvp.Value < track.TrackEndSector - track.TrackStartSector) return ReadSectorsLong(sectorAddress - kvp.Value, length, kvp.Key); - } - } - } - } throw new ArgumentOutOfRangeException(nameof(sectorAddress), "Sector address not found"); } @@ -1754,13 +1703,11 @@ namespace DiscImageChef.DiscImages _track.TrackSequence = 0; foreach(Track bwTrack in tracks) - { if(bwTrack.TrackSequence == track) { _track = bwTrack; break; } - } if(_track.TrackSequence == 0) throw new ArgumentOutOfRangeException(nameof(track), "Track does not exist in disc image"); @@ -1772,13 +1719,11 @@ namespace DiscImageChef.DiscImages length + sectorAddress, _track.TrackEndSector)); foreach(DataFileCharacteristics _chars in filePaths) - { if((long)sectorAddress >= _chars.StartLba && length < (ulong)_chars.Sectors - sectorAddress) { chars = _chars; break; } - } if(string.IsNullOrEmpty(chars.FilePath) || chars.FileFilter == null) throw new ArgumentOutOfRangeException(nameof(chars.FileFilter), "Track does not exist in disc image"); @@ -1833,7 +1778,6 @@ namespace DiscImageChef.DiscImages SeekOrigin.Begin); if(sectorOffset == 0 && sectorSkip == 0) buffer = br.ReadBytes((int)(sectorSize * length)); else - { for(int i = 0; i < length; i++) { byte[] sector; @@ -1842,7 +1786,6 @@ namespace DiscImageChef.DiscImages br.BaseStream.Seek(sectorSkip, SeekOrigin.Current); Array.Copy(sector, 0, buffer, i * sectorSize, sectorSize); } - } return buffer; } @@ -1879,7 +1822,7 @@ namespace DiscImageChef.DiscImages public override List GetSessionTracks(Session session) { - if(sessions.Contains(session)) { return GetSessionTracks(session.SessionSequence); } + if(sessions.Contains(session)) return GetSessionTracks(session.SessionSequence); throw new ImageNotSupportedException("Session does not exist in disc image"); } @@ -1887,7 +1830,7 @@ namespace DiscImageChef.DiscImages public override List GetSessionTracks(ushort session) { List tracks = new List(); - foreach(Track _track in this.tracks) { if(_track.TrackSession == session) tracks.Add(_track); } + foreach(Track _track in this.tracks) if(_track.TrackSession == session) tracks.Add(_track); return tracks; } diff --git a/DiscImageChef.DiscImages/CDRDAO.cs b/DiscImageChef.DiscImages/CDRDAO.cs index bad6ed75e..6904eac5e 100644 --- a/DiscImageChef.DiscImages/CDRDAO.cs +++ b/DiscImageChef.DiscImages/CDRDAO.cs @@ -612,17 +612,11 @@ namespace DiscImageChef.DiscImages ulong.Parse(lengthString[1]) * 75 + ulong.Parse(lengthString[2]); } else if(matchZeroData.Success) - { DicConsole.DebugWriteLine("CDRDAO plugin", "Found ZERO \"{1}\" at line {0}", line, matchZeroData.Groups["length"].Value); - // Seems can be ignored as the data is still in the image - } else if(matchZeroAudio.Success) - { DicConsole.DebugWriteLine("CDRDAO plugin", "Found SILENCE \"{1}\" at line {0}", line, matchZeroAudio.Groups["length"].Value); - // Seems can be ignored as the data is still in the image - } else if(matchAudioFile.Success) { DicConsole.DebugWriteLine("CDRDAO plugin", "Found AUDIOFILE \"{1}\" at line {0}", line, @@ -941,10 +935,8 @@ namespace DiscImageChef.DiscImages foreach(CdrdaoTrack track in discimage.Tracks) { if(track.Subchannel) - { if(!ImageInfo.ReadableSectorTags.Contains(SectorTagType.CdSectorSubchannel)) ImageInfo.ReadableSectorTags.Add(SectorTagType.CdSectorSubchannel); - } switch(track.Tracktype) { @@ -1039,7 +1031,7 @@ namespace DiscImageChef.DiscImages { case MediaTagType.CD_MCN: { - if(discimage.Mcn != null) { return Encoding.ASCII.GetBytes(discimage.Mcn); } + if(discimage.Mcn != null) return Encoding.ASCII.GetBytes(discimage.Mcn); throw new FeatureNotPresentImageException("Image does not contain MCN information."); } @@ -1071,19 +1063,11 @@ namespace DiscImageChef.DiscImages public override byte[] ReadSectors(ulong sectorAddress, uint length) { foreach(KeyValuePair kvp in offsetmap) - { if(sectorAddress >= kvp.Value) - { foreach(CdrdaoTrack cdrdaoTrack in discimage.Tracks) - { if(cdrdaoTrack.Sequence == kvp.Key) - { if(sectorAddress - kvp.Value < cdrdaoTrack.Sectors) return ReadSectors(sectorAddress - kvp.Value, length, kvp.Key); - } - } - } - } throw new ArgumentOutOfRangeException(nameof(sectorAddress), string.Format("Sector address {0} not found", sectorAddress)); @@ -1092,19 +1076,11 @@ namespace DiscImageChef.DiscImages public override byte[] ReadSectorsTag(ulong sectorAddress, uint length, SectorTagType tag) { foreach(KeyValuePair kvp in offsetmap) - { if(sectorAddress >= kvp.Value) - { foreach(CdrdaoTrack cdrdaoTrack in discimage.Tracks) - { if(cdrdaoTrack.Sequence == kvp.Key) - { if(sectorAddress - kvp.Value < cdrdaoTrack.Sectors) return ReadSectorsTag(sectorAddress - kvp.Value, length, kvp.Key, tag); - } - } - } - } throw new ArgumentOutOfRangeException(nameof(sectorAddress), string.Format("Sector address {0} not found", sectorAddress)); @@ -1117,13 +1093,11 @@ namespace DiscImageChef.DiscImages _track.Sequence = 0; foreach(CdrdaoTrack cdrdaoTrack in discimage.Tracks) - { if(cdrdaoTrack.Sequence == track) { _track = cdrdaoTrack; break; } - } if(_track.Sequence == 0) throw new ArgumentOutOfRangeException(nameof(track), "Track does not exist in disc image"); @@ -1196,7 +1170,6 @@ namespace DiscImageChef.DiscImages SeekOrigin.Begin); if(sectorOffset == 0 && sectorSkip == 0) buffer = br.ReadBytes((int)(sectorSize * length)); else - { for(int i = 0; i < length; i++) { byte[] sector; @@ -1205,7 +1178,6 @@ namespace DiscImageChef.DiscImages br.BaseStream.Seek(sectorSkip, SeekOrigin.Current); Array.Copy(sector, 0, buffer, i * sectorSize, sectorSize); } - } return buffer; } @@ -1217,13 +1189,11 @@ namespace DiscImageChef.DiscImages _track.Sequence = 0; foreach(CdrdaoTrack cdrdaoTrack in discimage.Tracks) - { if(cdrdaoTrack.Sequence == track) { _track = cdrdaoTrack; break; } - } if(_track.Sequence == 0) throw new ArgumentOutOfRangeException(nameof(track), "Track does not exist in disc image"); @@ -1378,7 +1348,6 @@ namespace DiscImageChef.DiscImages SeekOrigin.Begin); if(sectorOffset == 0 && sectorSkip == 0) buffer = br.ReadBytes((int)(sectorSize * length)); else - { for(int i = 0; i < length; i++) { byte[] sector; @@ -1387,7 +1356,6 @@ namespace DiscImageChef.DiscImages br.BaseStream.Seek(sectorSkip, SeekOrigin.Current); Array.Copy(sector, 0, buffer, i * sectorSize, sectorSize); } - } return buffer; } @@ -1405,19 +1373,11 @@ namespace DiscImageChef.DiscImages public override byte[] ReadSectorsLong(ulong sectorAddress, uint length) { foreach(KeyValuePair kvp in offsetmap) - { if(sectorAddress >= kvp.Value) - { foreach(CdrdaoTrack cdrdaoTrack in discimage.Tracks) - { if(cdrdaoTrack.Sequence == kvp.Key) - { if(sectorAddress - kvp.Value < cdrdaoTrack.Sectors) return ReadSectorsLong(sectorAddress - kvp.Value, length, kvp.Key); - } - } - } - } throw new ArgumentOutOfRangeException(nameof(sectorAddress), "Sector address not found"); } @@ -1429,13 +1389,11 @@ namespace DiscImageChef.DiscImages _track.Sequence = 0; foreach(CdrdaoTrack cdrdaoTrack in discimage.Tracks) - { if(cdrdaoTrack.Sequence == track) { _track = cdrdaoTrack; break; } - } if(_track.Sequence == 0) throw new ArgumentOutOfRangeException(nameof(track), "Track does not exist in disc image"); @@ -1498,7 +1456,6 @@ namespace DiscImageChef.DiscImages if(sectorOffset == 0 && sectorSkip == 0) buffer = br.ReadBytes((int)(sectorSize * length)); else - { for(int i = 0; i < length; i++) { byte[] sector; @@ -1508,7 +1465,6 @@ namespace DiscImageChef.DiscImages Array.Copy(sector, 0, buffer, i * sectorSize, sectorSize); } - } return buffer; } diff --git a/DiscImageChef.DiscImages/CDRWin.cs b/DiscImageChef.DiscImages/CDRWin.cs index 3fb540adc..9b82d0289 100644 --- a/DiscImageChef.DiscImages/CDRWin.cs +++ b/DiscImageChef.DiscImages/CDRWin.cs @@ -493,12 +493,10 @@ namespace DiscImageChef.DiscImages discimage.Disktypestr = matchDiskType.Groups[1].Value; } else if(matchDiskType.Success && intrack) - { throw new FeatureUnsupportedImageException(string .Format("Found REM ORIGINAL MEDIA TYPE field after a track in line {0}", line)); - } else if(matchSession.Success) { DicConsole.DebugWriteLine("CDRWin plugin", "Found REM SESSION at line {0}", line); @@ -506,16 +504,8 @@ namespace DiscImageChef.DiscImages // What happens between sessions } - else if(matchLba.Success) - { - DicConsole.DebugWriteLine("CDRWin plugin", "Found REM MSF at line {0}", line); - // Just ignored - } - else if(matchLeadOut.Success) - { - DicConsole.DebugWriteLine("CDRWin plugin", "Found REM LEAD-OUT at line {0}", line); - // Just ignored - } + else if(matchLba.Success) DicConsole.DebugWriteLine("CDRWin plugin", "Found REM MSF at line {0}", line); + else if(matchLeadOut.Success) DicConsole.DebugWriteLine("CDRWin plugin", "Found REM LEAD-OUT at line {0}", line); else if(matchComment.Success) { DicConsole.DebugWriteLine("CDRWin plugin", "Found REM at line {0}", line); @@ -609,16 +599,12 @@ namespace DiscImageChef.DiscImages currentfile.Filetype = matchFile.Groups[2].Value; // Check if file path is quoted - if(datafile[0] == '"' && datafile[datafile.Length - 1] == '"') - { - datafile = datafile.Substring(1, datafile.Length - 2); // Unquote it - } + if(datafile[0] == '"' && datafile[datafile.Length - 1] == '"') datafile = datafile.Substring(1, datafile.Length - 2); // Unquote it currentfile.Datafilter = filtersList.GetFilter(datafile); // Check if file exists if(currentfile.Datafilter == null) - { if(datafile[0] == '/' || datafile[0] == '/' && datafile[1] == '.' ) // UNIX absolute path { @@ -689,7 +675,6 @@ namespace DiscImageChef.DiscImages FeatureUnsupportedImageException(string.Format("File \"{0}\" not found.", matchFile.Groups[1].Value)); } - } // File does exist, process it DicConsole.DebugWriteLine("CDRWin plugin", "File \"{0}\" found", @@ -754,7 +739,6 @@ namespace DiscImageChef.DiscImages index)); if(index == 0 || index == 1 && !currenttrack.Indexes.ContainsKey(0)) - { if((int)(currenttrack.Sequence - 2) >= 0 && offset > 1) { cuetracks[currenttrack.Sequence - 2].Sectors = offset - currentfileoffsetsector; @@ -771,7 +755,6 @@ namespace DiscImageChef.DiscImages "cuetracks[currenttrack.sequence-2].bps = {0}", cuetracks[currenttrack.Sequence - 2].Bps); } - } if((index == 0 || index == 1 && !currenttrack.Indexes.ContainsKey(0)) && currenttrack.Sequence == 1) @@ -815,7 +798,7 @@ namespace DiscImageChef.DiscImages else if(matchPostgap.Success) { DicConsole.DebugWriteLine("CDRWin plugin", "Found POSTGAP at line {0}", line); - if(intrack) { currenttrack.Postgap = CdrWinMsftoLba(matchPostgap.Groups[1].Value); } + if(intrack) currenttrack.Postgap = CdrWinMsftoLba(matchPostgap.Groups[1].Value); else throw new FeatureUnsupportedImageException(string @@ -825,7 +808,7 @@ namespace DiscImageChef.DiscImages else if(matchPregap.Success) { DicConsole.DebugWriteLine("CDRWin plugin", "Found PREGAP at line {0}", line); - if(intrack) { currenttrack.Pregap = CdrWinMsftoLba(matchPregap.Groups[1].Value); } + if(intrack) currenttrack.Pregap = CdrWinMsftoLba(matchPregap.Groups[1].Value); else throw new FeatureUnsupportedImageException(string @@ -855,10 +838,7 @@ namespace DiscImageChef.DiscImages if(intrack) { - if(currenttrack.Indexes.ContainsKey(0) && currenttrack.Pregap == 0) - { - currenttrack.Indexes.TryGetValue(0, out currenttrack.Pregap); - } + if(currenttrack.Indexes.ContainsKey(0) && currenttrack.Pregap == 0) currenttrack.Indexes.TryGetValue(0, out currenttrack.Pregap); currentfile.Sequence = currenttrack.Sequence; currenttrack.Trackfile = currentfile; cuetracks[currenttrack.Sequence - 1] = currenttrack; @@ -877,12 +857,10 @@ namespace DiscImageChef.DiscImages else if(_line == "") // Empty line, ignore it { } else // Non-empty unknown field - { throw new FeatureUnsupportedImageException(string .Format("Found unknown field defined at line {0}: \"{1}\"", line, _line)); - } } } @@ -907,13 +885,11 @@ namespace DiscImageChef.DiscImages int lastSessionTrack = 0; for(int i = 0; i < cuetracks.Length; i++) - { if(cuetracks[i].Session == s) { sessionSectors += cuetracks[i].Sectors; if(i > lastSessionTrack) lastSessionTrack = i; } - } sessions[s - 1].EndTrack = cuetracks[lastSessionTrack].Sequence; sessions[s - 1].EndSector = sessionSectors - 1; @@ -1251,7 +1227,6 @@ namespace DiscImageChef.DiscImages ImageInfo.ReadableSectorTags.Add(SectorTagType.CdTrackFlags); foreach(CdrWinTrack track in discimage.Tracks) - { switch(track.Tracktype) { case CDRWIN_TRACK_TYPE_AUDIO: @@ -1309,7 +1284,6 @@ namespace DiscImageChef.DiscImages break; } } - } ImageInfo.XmlMediaType = XmlMediaType.OpticalDisc; @@ -1354,7 +1328,7 @@ namespace DiscImageChef.DiscImages { case MediaTagType.CD_MCN: { - if(discimage.Mcn != null) { return Encoding.ASCII.GetBytes(discimage.Mcn); } + if(discimage.Mcn != null) return Encoding.ASCII.GetBytes(discimage.Mcn); throw new FeatureNotPresentImageException("Image does not contain MCN information."); } @@ -1394,19 +1368,11 @@ namespace DiscImageChef.DiscImages public override byte[] ReadSectors(ulong sectorAddress, uint length) { foreach(KeyValuePair kvp in offsetmap) - { if(sectorAddress >= kvp.Value) - { foreach(CdrWinTrack cdrwinTrack in discimage.Tracks) - { if(cdrwinTrack.Sequence == kvp.Key) - { if(sectorAddress - kvp.Value < cdrwinTrack.Sectors) return ReadSectors(sectorAddress - kvp.Value, length, kvp.Key); - } - } - } - } throw new ArgumentOutOfRangeException(nameof(sectorAddress), "Sector address not found"); } @@ -1414,19 +1380,11 @@ namespace DiscImageChef.DiscImages public override byte[] ReadSectorsTag(ulong sectorAddress, uint length, SectorTagType tag) { foreach(KeyValuePair kvp in offsetmap) - { if(sectorAddress >= kvp.Value) - { foreach(CdrWinTrack cdrwinTrack in discimage.Tracks) - { if(cdrwinTrack.Sequence == kvp.Key) - { if(sectorAddress - kvp.Value < cdrwinTrack.Sectors) return ReadSectorsTag(sectorAddress - kvp.Value, length, kvp.Key, tag); - } - } - } - } throw new ArgumentOutOfRangeException(nameof(sectorAddress), "Sector address not found"); } @@ -1438,13 +1396,11 @@ namespace DiscImageChef.DiscImages _track.Sequence = 0; foreach(CdrWinTrack cdrwinTrack in discimage.Tracks) - { if(cdrwinTrack.Sequence == track) { _track = cdrwinTrack; break; } - } if(_track.Sequence == 0) throw new ArgumentOutOfRangeException(nameof(track), "Track does not exist in disc image"); @@ -1529,7 +1485,6 @@ namespace DiscImageChef.DiscImages SeekOrigin.Begin); if(sectorOffset == 0 && sectorSkip == 0) buffer = br.ReadBytes((int)(sectorSize * length)); else - { for(int i = 0; i < length; i++) { byte[] sector; @@ -1538,7 +1493,6 @@ namespace DiscImageChef.DiscImages br.BaseStream.Seek(sectorSkip, SeekOrigin.Current); Array.Copy(sector, 0, buffer, i * sectorSize, sectorSize); } - } return buffer; } @@ -1550,13 +1504,11 @@ namespace DiscImageChef.DiscImages _track.Sequence = 0; foreach(CdrWinTrack cdrwinTrack in discimage.Tracks) - { if(cdrwinTrack.Sequence == track) { _track = cdrwinTrack; break; } - } if(_track.Sequence == 0) throw new ArgumentOutOfRangeException(nameof(track), "Track does not exist in disc image"); @@ -1718,7 +1670,6 @@ namespace DiscImageChef.DiscImages SeekOrigin.Begin); if(sectorOffset == 0 && sectorSkip == 0) buffer = br.ReadBytes((int)(sectorSize * length)); else - { for(int i = 0; i < length; i++) { byte[] sector; @@ -1727,7 +1678,6 @@ namespace DiscImageChef.DiscImages br.BaseStream.Seek(sectorSkip, SeekOrigin.Current); Array.Copy(sector, 0, buffer, i * sectorSize, sectorSize); } - } return buffer; } @@ -1745,19 +1695,11 @@ namespace DiscImageChef.DiscImages public override byte[] ReadSectorsLong(ulong sectorAddress, uint length) { foreach(KeyValuePair kvp in offsetmap) - { if(sectorAddress >= kvp.Value) - { foreach(CdrWinTrack cdrwinTrack in discimage.Tracks) - { if(cdrwinTrack.Sequence == kvp.Key) - { if(sectorAddress - kvp.Value < cdrwinTrack.Sectors) return ReadSectorsLong(sectorAddress - kvp.Value, length, kvp.Key); - } - } - } - } throw new ArgumentOutOfRangeException(nameof(sectorAddress), "Sector address not found"); } @@ -1769,13 +1711,11 @@ namespace DiscImageChef.DiscImages _track.Sequence = 0; foreach(CdrWinTrack cdrwinTrack in discimage.Tracks) - { if(cdrwinTrack.Sequence == track) { _track = cdrwinTrack; break; } - } if(_track.Sequence == 0) throw new ArgumentOutOfRangeException(nameof(track), "Track does not exist in disc image"); @@ -1844,7 +1784,6 @@ namespace DiscImageChef.DiscImages if(sectorOffset == 0 && sectorSkip == 0) buffer = br.ReadBytes((int)(sectorSize * length)); else - { for(int i = 0; i < length; i++) { byte[] sector; @@ -1854,7 +1793,6 @@ namespace DiscImageChef.DiscImages Array.Copy(sector, 0, buffer, i * sectorSize, sectorSize); } - } return buffer; } @@ -1958,7 +1896,7 @@ namespace DiscImageChef.DiscImages public override List GetSessionTracks(Session session) { - if(discimage.Sessions.Contains(session)) { return GetSessionTracks(session.SessionSequence); } + if(discimage.Sessions.Contains(session)) return GetSessionTracks(session.SessionSequence); throw new ImageNotSupportedException("Session does not exist in disc image"); } @@ -1968,7 +1906,6 @@ namespace DiscImageChef.DiscImages List tracks = new List(); foreach(CdrWinTrack cdrTrack in discimage.Tracks) - { if(cdrTrack.Session == session) { Track _track = new Track(); @@ -1999,7 +1936,6 @@ namespace DiscImageChef.DiscImages tracks.Add(_track); } - } return tracks; } diff --git a/DiscImageChef.DiscImages/CHD.cs b/DiscImageChef.DiscImages/CHD.cs index 70838c833..5dc471dd9 100644 --- a/DiscImageChef.DiscImages/CHD.cs +++ b/DiscImageChef.DiscImages/CHD.cs @@ -1554,10 +1554,8 @@ namespace DiscImageChef.DiscImages offsetmap.Add(_track.TrackStartSector, _track.TrackSequence); if(_track.TrackSubchannelType != TrackSubchannelType.None) - { if(!ImageInfo.ReadableSectorTags.Contains(SectorTagType.CdSectorSubchannel)) ImageInfo.ReadableSectorTags.Add(SectorTagType.CdSectorSubchannel); - } switch(_track.TrackType) { @@ -1633,10 +1631,7 @@ namespace DiscImageChef.DiscImages Track GetTrack(ulong sector) { Track track = new Track(); - foreach(KeyValuePair kvp in offsetmap) - { - if(sector >= kvp.Key) tracks.TryGetValue(kvp.Value, out track); - } + foreach(KeyValuePair kvp in offsetmap) if(sector >= kvp.Key) tracks.TryGetValue(kvp.Value, out track); return track; } @@ -1664,7 +1659,7 @@ namespace DiscImageChef.DiscImages imageStream.Seek((long)offset, SeekOrigin.Begin); imageStream.Read(compHunk, 0, compHunk.Length); - if(length == sectorsPerHunk * ImageInfo.SectorSize) { hunk = compHunk; } + if(length == sectorsPerHunk * ImageInfo.SectorSize) hunk = compHunk; else if((ChdCompression)hdrCompression > ChdCompression.Zlib) throw new ImageNotSupportedException(string.Format("Unsupported compression {0}", (ChdCompression)hdrCompression)); @@ -1996,13 +1991,11 @@ namespace DiscImageChef.DiscImages byte[] buffer = new byte[sector_size]; if(track.TrackType == TrackType.Audio && swapAudio) - { for(int i = 0; i < 2352; i += 2) { buffer[i + 1] = sector[i]; buffer[i] = sector[i + 1]; } - } else Array.Copy(sector, sector_offset, buffer, 0, sector_size); return buffer; @@ -2045,7 +2038,6 @@ namespace DiscImageChef.DiscImages uint sector_size; if(tag == SectorTagType.CdSectorSubchannel) - { if(track.TrackSubchannelType == TrackSubchannelType.None) throw new FeatureNotPresentImageException("Requested sector does not contain subchannel"); else if(track.TrackSubchannelType == TrackSubchannelType.RawInterleaved) @@ -2057,16 +2049,13 @@ namespace DiscImageChef.DiscImages throw new FeatureSupportedButNotImplementedImageException(string.Format("Unsupported subchannel type {0}", track.TrackSubchannelType)); - } else - { switch(track.TrackType) { case TrackType.CdMode1: case TrackType.CdMode2Form1: { if(track.TrackRawBytesPerSector == 2352) - { switch(tag) { case SectorTagType.CdSectorSync: @@ -2110,7 +2099,6 @@ namespace DiscImageChef.DiscImages } default: throw new ArgumentException("Unsupported tag requested", nameof(tag)); } - } else throw new FeatureNotPresentImageException("Requested sector does not contain tags"); break; @@ -2118,7 +2106,6 @@ namespace DiscImageChef.DiscImages case TrackType.CdMode2Form2: { if(track.TrackRawBytesPerSector == 2352) - { switch(tag) { case SectorTagType.CdSectorSync: @@ -2147,9 +2134,7 @@ namespace DiscImageChef.DiscImages } default: throw new ArgumentException("Unsupported tag requested", nameof(tag)); } - } else - { switch(tag) { case SectorTagType.CdSectorSync: @@ -2174,14 +2159,12 @@ namespace DiscImageChef.DiscImages } default: throw new ArgumentException("Unsupported tag requested", nameof(tag)); } - } break; } case TrackType.CdMode2Formless: { if(track.TrackRawBytesPerSector == 2352) - { switch(tag) { case SectorTagType.CdSectorSync: @@ -2205,7 +2188,6 @@ namespace DiscImageChef.DiscImages } default: throw new ArgumentException("Unsupported tag requested", nameof(tag)); } - } else throw new FeatureNotPresentImageException("Requested sector does not contain tags"); break; @@ -2214,28 +2196,23 @@ namespace DiscImageChef.DiscImages throw new FeatureNotPresentImageException("Requested sector does not contain tags"); default: throw new FeatureSupportedButNotImplementedImageException("Unsupported track type"); } - } byte[] buffer = new byte[sector_size]; if(track.TrackType == TrackType.Audio && swapAudio) - { for(int i = 0; i < 2352; i += 2) { buffer[i + 1] = sector[i]; buffer[i] = sector[i + 1]; } - } else Array.Copy(sector, sector_offset, buffer, 0, sector_size); if(track.TrackType == TrackType.Audio && swapAudio) - { for(int i = 0; i < 2352; i += 2) { buffer[i + 1] = sector[i]; buffer[i] = sector[i + 1]; } - } else Array.Copy(sector, sector_offset, buffer, 0, sector_size); return buffer; @@ -2319,13 +2296,11 @@ namespace DiscImageChef.DiscImages byte[] buffer = new byte[track.TrackRawBytesPerSector]; if(track.TrackType == TrackType.Audio && swapAudio) - { for(int i = 0; i < 2352; i += 2) { buffer[i + 1] = sector[i]; buffer[i] = sector[i + 1]; } - } else Array.Copy(sector, 0, buffer, 0, track.TrackRawBytesPerSector); return buffer; @@ -2496,7 +2471,7 @@ namespace DiscImageChef.DiscImages throw new FeaturedNotSupportedByDiscImageException("Cannot access optical tracks on a hard disk image"); List trks = new List(); - foreach(Track track in tracks.Values) { if(track.TrackSession == session) trks.Add(track); } + foreach(Track track in tracks.Values) if(track.TrackSession == session) trks.Add(track); return trks; } diff --git a/DiscImageChef.DiscImages/CloneCD.cs b/DiscImageChef.DiscImages/CloneCD.cs index 2ab183ab5..4061225f3 100644 --- a/DiscImageChef.DiscImages/CloneCD.cs +++ b/DiscImageChef.DiscImages/CloneCD.cs @@ -323,24 +323,15 @@ namespace DiscImageChef.DiscImages cdtLenMatch = cdtLenRegex.Match(_line); discCatMatch = discCatRegex.Match(_line); - if(discEntMatch.Success) - { - DicConsole.DebugWriteLine("CloneCD plugin", "Found TocEntries at line {0}", line); - } - else if(discSessMatch.Success) - { - DicConsole.DebugWriteLine("CloneCD plugin", "Found Sessions at line {0}", line); - } + if(discEntMatch.Success) DicConsole.DebugWriteLine("CloneCD plugin", "Found TocEntries at line {0}", line); + else if(discSessMatch.Success) DicConsole.DebugWriteLine("CloneCD plugin", "Found Sessions at line {0}", line); else if(discScrMatch.Success) { DicConsole.DebugWriteLine("CloneCD plugin", "Found DataTracksScrambled at line {0}", line); scrambled |= discScrMatch.Groups["value"].Value == "1"; } - else if(cdtLenMatch.Success) - { - DicConsole.DebugWriteLine("CloneCD plugin", "Found CDTextLength at line {0}", line); - } + else if(cdtLenMatch.Success) DicConsole.DebugWriteLine("CloneCD plugin", "Found CDTextLength at line {0}", line); else if(discCatMatch.Success) { DicConsole.DebugWriteLine("CloneCD plugin", "Found Catalog at line {0}", line); @@ -353,10 +344,7 @@ namespace DiscImageChef.DiscImages cdtEntsMatch = cdtEntsRegex.Match(_line); cdtEntMatch = cdtEntRegex.Match(_line); - if(cdtEntsMatch.Success) - { - DicConsole.DebugWriteLine("CloneCD plugin", "Found CD-Text Entries at line {0}", line); - } + if(cdtEntsMatch.Success) DicConsole.DebugWriteLine("CloneCD plugin", "Found CD-Text Entries at line {0}", line); else if(cdtEntMatch.Success) { DicConsole.DebugWriteLine("CloneCD plugin", "Found CD-Text Entry at line {0}", line); @@ -372,14 +360,8 @@ namespace DiscImageChef.DiscImages sessPregMatch = sessPregRegex.Match(_line); sessSubcMatch = sessSubcRegex.Match(_line); - if(sessPregMatch.Success) - { - DicConsole.DebugWriteLine("CloneCD plugin", "Found PreGapMode at line {0}", line); - } - else if(sessSubcMatch.Success) - { - DicConsole.DebugWriteLine("CloneCD plugin", "Found PreGapSubC at line {0}", line); - } + if(sessPregMatch.Success) DicConsole.DebugWriteLine("CloneCD plugin", "Found PreGapMode at line {0}", line); + else if(sessSubcMatch.Success) DicConsole.DebugWriteLine("CloneCD plugin", "Found PreGapSubC at line {0}", line); } else if(inEntry) { @@ -440,10 +422,7 @@ namespace DiscImageChef.DiscImages DicConsole.DebugWriteLine("CloneCD plugin", "Found AFrame at line {0}", line); currentEntry.Frame = Convert.ToByte(entAFrameMatch.Groups["value"].Value, 10); } - else if(entAlbaMatch.Success) - { - DicConsole.DebugWriteLine("CloneCD plugin", "Found ALBA at line {0}", line); - } + else if(entAlbaMatch.Success) DicConsole.DebugWriteLine("CloneCD plugin", "Found ALBA at line {0}", line); else if(entZeroMatch.Success) { DicConsole.DebugWriteLine("CloneCD plugin", "Found Zero at line {0}", line); @@ -466,10 +445,7 @@ namespace DiscImageChef.DiscImages DicConsole.DebugWriteLine("CloneCD plugin", "Found PFrame at line {0}", line); currentEntry.PFRAME = Convert.ToByte(entPFrameMatch.Groups["value"].Value, 10); } - else if(entPlbaMatch.Success) - { - DicConsole.DebugWriteLine("CloneCD plugin", "Found PLBA at line {0}", line); - } + else if(entPlbaMatch.Success) DicConsole.DebugWriteLine("CloneCD plugin", "Found PLBA at line {0}", line); } } } @@ -639,7 +615,6 @@ namespace DiscImageChef.DiscImages Array.Copy(sectTest, 20, subHdr2, 0, 4); if(subHdr1.SequenceEqual(subHdr2) && !empHdr.SequenceEqual(subHdr1)) - { if((subHdr1[2] & 0x20) == 0x20) { currentTrack.TrackBytesPerSector = 2324; @@ -704,7 +679,6 @@ namespace DiscImageChef.DiscImages .CdSectorEdc); if(ImageInfo.SectorSize < 2048) ImageInfo.SectorSize = 2048; } - } else { currentTrack.TrackBytesPerSector = 2336; @@ -936,19 +910,11 @@ namespace DiscImageChef.DiscImages public override byte[] ReadSectors(ulong sectorAddress, uint length) { foreach(KeyValuePair kvp in offsetmap) - { if(sectorAddress >= kvp.Value) - { foreach(Track _track in tracks) - { if(_track.TrackSequence == kvp.Key) - { if(sectorAddress <= _track.TrackEndSector) return ReadSectors(sectorAddress - kvp.Value, length, kvp.Key); - } - } - } - } throw new ArgumentOutOfRangeException(nameof(sectorAddress), string.Format("Sector address {0} not found", sectorAddress)); @@ -957,19 +923,11 @@ namespace DiscImageChef.DiscImages public override byte[] ReadSectorsTag(ulong sectorAddress, uint length, SectorTagType tag) { foreach(KeyValuePair kvp in offsetmap) - { if(sectorAddress >= kvp.Value) - { foreach(Track _track in tracks) - { if(_track.TrackSequence == kvp.Key) - { if(sectorAddress <= _track.TrackEndSector) return ReadSectorsTag(sectorAddress - kvp.Value, length, kvp.Key, tag); - } - } - } - } throw new ArgumentOutOfRangeException(nameof(sectorAddress), string.Format("Sector address {0} not found", sectorAddress)); @@ -982,13 +940,11 @@ namespace DiscImageChef.DiscImages _track.TrackSequence = 0; foreach(Track __track in tracks) - { if(__track.TrackSequence == track) { _track = __track; break; } - } if(_track.TrackSequence == 0) throw new ArgumentOutOfRangeException(nameof(track), "Track does not exist in disc image"); @@ -1049,7 +1005,6 @@ namespace DiscImageChef.DiscImages dataStream.Seek((long)(_track.TrackFileOffset + sectorAddress * 2352), SeekOrigin.Begin); if(sectorOffset == 0 && sectorSkip == 0) dataStream.Read(buffer, 0, buffer.Length); else - { for(int i = 0; i < length; i++) { byte[] sector = new byte[sectorSize]; @@ -1058,7 +1013,6 @@ namespace DiscImageChef.DiscImages dataStream.Seek(sectorSkip, SeekOrigin.Current); Array.Copy(sector, 0, buffer, i * sectorSize, sectorSize); } - } return buffer; } @@ -1071,13 +1025,11 @@ namespace DiscImageChef.DiscImages _track.TrackSequence = 0; foreach(Track __track in tracks) - { if(__track.TrackSequence == track) { _track = __track; break; } - } if(_track.TrackSequence == 0) throw new ArgumentOutOfRangeException(nameof(track), "Track does not exist in disc image"); @@ -1299,7 +1251,6 @@ namespace DiscImageChef.DiscImages dataStream.Seek((long)(_track.TrackFileOffset + sectorAddress * 2352), SeekOrigin.Begin); if(sectorOffset == 0 && sectorSkip == 0) dataStream.Read(buffer, 0, buffer.Length); else - { for(int i = 0; i < length; i++) { byte[] sector = new byte[sectorSize]; @@ -1308,7 +1259,6 @@ namespace DiscImageChef.DiscImages dataStream.Seek(sectorSkip, SeekOrigin.Current); Array.Copy(sector, 0, buffer, i * sectorSize, sectorSize); } - } return buffer; } @@ -1326,19 +1276,11 @@ namespace DiscImageChef.DiscImages public override byte[] ReadSectorsLong(ulong sectorAddress, uint length) { foreach(KeyValuePair kvp in offsetmap) - { if(sectorAddress >= kvp.Value) - { foreach(Track track in tracks) - { if(track.TrackSequence == kvp.Key) - { if(sectorAddress - kvp.Value < track.TrackEndSector - track.TrackStartSector + 1) return ReadSectorsLong(sectorAddress - kvp.Value, length, kvp.Key); - } - } - } - } throw new ArgumentOutOfRangeException(nameof(sectorAddress), string.Format("Sector address {0} not found", sectorAddress)); @@ -1351,13 +1293,11 @@ namespace DiscImageChef.DiscImages _track.TrackSequence = 0; foreach(Track __track in tracks) - { if(__track.TrackSequence == track) { _track = __track; break; } - } if(_track.TrackSequence == 0) throw new ArgumentOutOfRangeException(nameof(track), "Track does not exist in disc image"); @@ -1488,7 +1428,7 @@ namespace DiscImageChef.DiscImages public override List GetSessionTracks(DiscImages.Session session) { - if(sessions.Contains(session)) { return GetSessionTracks(session.SessionSequence); } + if(sessions.Contains(session)) return GetSessionTracks(session.SessionSequence); throw new ImageNotSupportedException("Session does not exist in disc image"); } @@ -1496,7 +1436,7 @@ namespace DiscImageChef.DiscImages public override List GetSessionTracks(ushort session) { List tracks = new List(); - foreach(Track _track in this.tracks) { if(_track.TrackSession == session) tracks.Add(_track); } + foreach(Track _track in this.tracks) if(_track.TrackSession == session) tracks.Add(_track); return tracks; } diff --git a/DiscImageChef.DiscImages/DiscJuggler.cs b/DiscImageChef.DiscImages/DiscJuggler.cs index 9e8462078..5d04a45c2 100644 --- a/DiscImageChef.DiscImages/DiscJuggler.cs +++ b/DiscImageChef.DiscImages/DiscJuggler.cs @@ -704,19 +704,11 @@ namespace DiscImageChef.DiscImages public override byte[] ReadSectors(ulong sectorAddress, uint length) { foreach(KeyValuePair kvp in offsetmap) - { if(sectorAddress >= kvp.Value) - { foreach(Track _track in tracks) - { if(_track.TrackSequence == kvp.Key) - { if(sectorAddress < _track.TrackEndSector) return ReadSectors(sectorAddress - kvp.Value, length, kvp.Key); - } - } - } - } throw new ArgumentOutOfRangeException(nameof(sectorAddress), string.Format("Sector address {0} not found", sectorAddress)); @@ -725,19 +717,11 @@ namespace DiscImageChef.DiscImages public override byte[] ReadSectorsTag(ulong sectorAddress, uint length, SectorTagType tag) { foreach(KeyValuePair kvp in offsetmap) - { if(sectorAddress >= kvp.Value) - { foreach(Track _track in tracks) - { if(_track.TrackSequence == kvp.Key) - { if(sectorAddress < _track.TrackEndSector) return ReadSectorsTag(sectorAddress - kvp.Value, length, kvp.Key, tag); - } - } - } - } throw new ArgumentOutOfRangeException(nameof(sectorAddress), string.Format("Sector address {0} not found", sectorAddress)); @@ -750,13 +734,11 @@ namespace DiscImageChef.DiscImages _track.TrackSequence = 0; foreach(Track __track in tracks) - { if(__track.TrackSequence == track) { _track = __track; break; } - } if(_track.TrackSequence == 0) throw new ArgumentOutOfRangeException(nameof(track), "Track does not exist in disc image"); @@ -831,7 +813,6 @@ namespace DiscImageChef.DiscImages SeekOrigin.Begin); if(sectorOffset == 0 && sectorSkip == 0) imageStream.Read(buffer, 0, buffer.Length); else - { for(int i = 0; i < length; i++) { byte[] sector = new byte[sectorSize]; @@ -840,7 +821,6 @@ namespace DiscImageChef.DiscImages imageStream.Seek(sectorSkip, SeekOrigin.Current); Array.Copy(sector, 0, buffer, i * sectorSize, sectorSize); } - } return buffer; } @@ -852,13 +832,11 @@ namespace DiscImageChef.DiscImages _track.TrackSequence = 0; foreach(Track __track in tracks) - { if(__track.TrackSequence == track) { _track = __track; break; } - } if(_track.TrackSequence == 0) throw new ArgumentOutOfRangeException(nameof(track), "Track does not exist in disc image"); @@ -1046,7 +1024,6 @@ namespace DiscImageChef.DiscImages SeekOrigin.Begin); if(sectorOffset == 0 && sectorSkip == 0) imageStream.Read(buffer, 0, buffer.Length); else - { for(int i = 0; i < length; i++) { byte[] sector = new byte[sectorSize]; @@ -1055,7 +1032,6 @@ namespace DiscImageChef.DiscImages imageStream.Seek(sectorSkip, SeekOrigin.Current); Array.Copy(sector, 0, buffer, i * sectorSize, sectorSize); } - } return buffer; } @@ -1073,19 +1049,11 @@ namespace DiscImageChef.DiscImages public override byte[] ReadSectorsLong(ulong sectorAddress, uint length) { foreach(KeyValuePair kvp in offsetmap) - { if(sectorAddress >= kvp.Value) - { foreach(Track track in tracks) - { if(track.TrackSequence == kvp.Key) - { if(sectorAddress - kvp.Value < track.TrackEndSector - track.TrackStartSector) return ReadSectorsLong(sectorAddress - kvp.Value, length, kvp.Key); - } - } - } - } throw new ArgumentOutOfRangeException(nameof(sectorAddress), string.Format("Sector address {0} not found", sectorAddress)); @@ -1098,13 +1066,11 @@ namespace DiscImageChef.DiscImages _track.TrackSequence = 0; foreach(Track __track in tracks) - { if(__track.TrackSequence == track) { _track = __track; break; } - } if(_track.TrackSequence == 0) throw new ArgumentOutOfRangeException(nameof(track), "Track does not exist in disc image"); @@ -1139,7 +1105,6 @@ namespace DiscImageChef.DiscImages SeekOrigin.Begin); if(sectorOffset == 0 && sectorSkip == 0) imageStream.Read(buffer, 0, buffer.Length); else - { for(int i = 0; i < length; i++) { byte[] sector = new byte[sectorSize]; @@ -1148,7 +1113,6 @@ namespace DiscImageChef.DiscImages imageStream.Seek(sectorSkip, SeekOrigin.Current); Array.Copy(sector, 0, buffer, i * sectorSize, sectorSize); } - } return buffer; } @@ -1265,7 +1229,7 @@ namespace DiscImageChef.DiscImages public override List GetSessionTracks(Session session) { - if(sessions.Contains(session)) { return GetSessionTracks(session.SessionSequence); } + if(sessions.Contains(session)) return GetSessionTracks(session.SessionSequence); throw new ImageNotSupportedException("Session does not exist in disc image"); } @@ -1273,7 +1237,7 @@ namespace DiscImageChef.DiscImages public override List GetSessionTracks(ushort session) { List _tracks = new List(); - foreach(Track _track in tracks) { if(_track.TrackSession == session) _tracks.Add(_track); } + foreach(Track _track in tracks) if(_track.TrackSession == session) _tracks.Add(_track); return _tracks; } diff --git a/DiscImageChef.DiscImages/DiskCopy42.cs b/DiscImageChef.DiscImages/DiskCopy42.cs index 3f98f9944..7d197fe8b 100644 --- a/DiscImageChef.DiscImages/DiskCopy42.cs +++ b/DiscImageChef.DiscImages/DiskCopy42.cs @@ -703,10 +703,8 @@ namespace DiscImageChef.DiscImages byte[] buffer = new byte[length * ImageInfo.SectorSize]; if(twiggy) - { Array.Copy(twiggyCache, (int)sectorAddress * ImageInfo.SectorSize, buffer, 0, length * ImageInfo.SectorSize); - } else { Stream stream = dc42ImageFilter.GetDataForkStream(); @@ -732,7 +730,7 @@ namespace DiscImageChef.DiscImages byte[] buffer = new byte[length * bptag]; - if(twiggy) { Array.Copy(twiggyCacheTags, (int)sectorAddress * bptag, buffer, 0, length * bptag); } + if(twiggy) Array.Copy(twiggyCacheTags, (int)sectorAddress * bptag, buffer, 0, length * bptag); else { Stream stream = dc42ImageFilter.GetDataForkStream(); diff --git a/DiscImageChef.DiscImages/GDI.cs b/DiscImageChef.DiscImages/GDI.cs index 2d7716ab2..dd80a2121 100644 --- a/DiscImageChef.DiscImages/GDI.cs +++ b/DiscImageChef.DiscImages/GDI.cs @@ -258,7 +258,6 @@ namespace DiscImageChef.DiscImages currentTrack.Trackfile = currentTrack.Trackfilter.GetFilename(); if(currentTrack.StartSector - currentStart > 0) - { if(currentTrack.StartSector == 45000) { highDensity = true; @@ -271,7 +270,6 @@ namespace DiscImageChef.DiscImages currentTrack.Pregap = currentTrack.StartSector - currentStart; currentTrack.StartSector -= currentTrack.StartSector - currentStart; } - } if((currentTrack.Trackfilter.GetDataForkLength() - currentTrack.Offset) % currentTrack.Bps != 0) throw new ImageNotSupportedException("Track size not a multiple of sector size"); @@ -292,13 +290,11 @@ namespace DiscImageChef.DiscImages Session[] _sessions = new Session[2]; for(int s = 0; s < _sessions.Length; s++) - { if(s == 0) { _sessions[s].SessionSequence = 1; foreach(GdiTrack trk in discimage.Tracks) - { if(!trk.HighDensity) { if(_sessions[s].StartTrack == 0) _sessions[s].StartTrack = trk.Sequence; @@ -312,14 +308,12 @@ namespace DiscImageChef.DiscImages if(_sessions[s].EndSector < trk.Sectors + trk.StartSector - 1) _sessions[s].EndSector = trk.Sectors + trk.StartSector - 1; } - } } else { _sessions[s].SessionSequence = 2; foreach(GdiTrack trk in discimage.Tracks) - { if(trk.HighDensity) { if(_sessions[s].StartTrack == 0) _sessions[s].StartTrack = trk.Sequence; @@ -333,9 +327,7 @@ namespace DiscImageChef.DiscImages if(_sessions[s].EndSector < trk.Sectors + trk.StartSector - 1) _sessions[s].EndSector = trk.Sectors + trk.StartSector - 1; } - } } - } discimage.Sessions.Add(_sessions[0]); discimage.Sessions.Add(_sessions[1]); @@ -416,7 +408,6 @@ namespace DiscImageChef.DiscImages ImageInfo.SectorSize = 2352; // All others foreach(GdiTrack track in discimage.Tracks) - { if((track.Flags & 0x40) == 0x40 && track.Bps == 2352) { ImageInfo.ReadableSectorTags.Add(SectorTagType.CdSectorSync); @@ -427,7 +418,6 @@ namespace DiscImageChef.DiscImages ImageInfo.ReadableSectorTags.Add(SectorTagType.CdSectorEccQ); ImageInfo.ReadableSectorTags.Add(SectorTagType.CdSectorEdc); } - } ImageInfo.ImageCreationTime = imageFilter.GetCreationTime(); ImageInfo.ImageLastModificationTime = imageFilter.GetLastWriteTime(); @@ -499,19 +489,11 @@ namespace DiscImageChef.DiscImages public override byte[] ReadSectors(ulong sectorAddress, uint length) { foreach(KeyValuePair kvp in offsetmap) - { if(sectorAddress >= kvp.Value) - { foreach(GdiTrack gdiTrack in discimage.Tracks) - { if(gdiTrack.Sequence == kvp.Key) - { if(sectorAddress - kvp.Value < gdiTrack.Sectors) return ReadSectors(sectorAddress - kvp.Value, length, kvp.Key); - } - } - } - } ulong transitionStart; offsetmap.TryGetValue(0, out transitionStart); @@ -524,19 +506,11 @@ namespace DiscImageChef.DiscImages public override byte[] ReadSectorsTag(ulong sectorAddress, uint length, SectorTagType tag) { foreach(KeyValuePair kvp in offsetmap) - { if(sectorAddress >= kvp.Value) - { foreach(GdiTrack gdiTrack in discimage.Tracks) - { if(gdiTrack.Sequence == kvp.Key) - { if(sectorAddress - kvp.Value < gdiTrack.Sectors) return ReadSectorsTag(sectorAddress - kvp.Value, length, kvp.Key, tag); - } - } - } - } ulong transitionStart; offsetmap.TryGetValue(0, out transitionStart); @@ -562,13 +536,11 @@ namespace DiscImageChef.DiscImages _track.Sequence = 0; foreach(GdiTrack gdiTrack in discimage.Tracks) - { if(gdiTrack.Sequence == track) { _track = gdiTrack; break; } - } if(_track.Sequence == 0) throw new ArgumentOutOfRangeException(nameof(track), "Track does not exist in disc image"); @@ -640,7 +612,6 @@ namespace DiscImageChef.DiscImages SeekOrigin.Begin); if(sectorOffset == 0 && sectorSkip == 0) buffer = br.ReadBytes((int)(sectorSize * remainingSectors)); else - { for(ulong i = 0; i < remainingSectors; i++) { byte[] sector; @@ -649,7 +620,6 @@ namespace DiscImageChef.DiscImages br.BaseStream.Seek(sectorSkip, SeekOrigin.Current); Array.Copy(sector, 0, buffer, (int)(i * sectorSize), sectorSize); } - } return buffer; } @@ -672,13 +642,11 @@ namespace DiscImageChef.DiscImages _track.Sequence = 0; foreach(GdiTrack gdiTrack in discimage.Tracks) - { if(gdiTrack.Sequence == track) { _track = gdiTrack; break; } - } if(_track.Sequence == 0) throw new ArgumentOutOfRangeException(nameof(track), "Track does not exist in disc image"); @@ -804,7 +772,6 @@ namespace DiscImageChef.DiscImages SeekOrigin.Begin); if(sectorOffset == 0 && sectorSkip == 0) buffer = br.ReadBytes((int)(sectorSize * remainingSectors)); else - { for(ulong i = 0; i < remainingSectors; i++) { byte[] sector; @@ -813,7 +780,6 @@ namespace DiscImageChef.DiscImages br.BaseStream.Seek(sectorSkip, SeekOrigin.Current); Array.Copy(sector, 0, buffer, (int)(i * sectorSize), sectorSize); } - } return buffer; } @@ -831,19 +797,11 @@ namespace DiscImageChef.DiscImages public override byte[] ReadSectorsLong(ulong sectorAddress, uint length) { foreach(KeyValuePair kvp in offsetmap) - { if(sectorAddress >= kvp.Value) - { foreach(GdiTrack gdiTrack in discimage.Tracks) - { if(gdiTrack.Sequence == kvp.Key) - { if(sectorAddress - kvp.Value < gdiTrack.Sectors) return ReadSectorsLong(sectorAddress - kvp.Value, length, kvp.Key); - } - } - } - } throw new ArgumentOutOfRangeException(nameof(sectorAddress), "Sector address not found"); } @@ -864,13 +822,11 @@ namespace DiscImageChef.DiscImages _track.Sequence = 0; foreach(GdiTrack gdiTrack in discimage.Tracks) - { if(gdiTrack.Sequence == track) { _track = gdiTrack; break; } - } if(_track.Sequence == 0) throw new ArgumentOutOfRangeException(nameof(track), "Track does not exist in disc image"); @@ -942,7 +898,6 @@ namespace DiscImageChef.DiscImages SeekOrigin.Begin); if(sectorOffset == 0 && sectorSkip == 0) buffer = br.ReadBytes((int)(sectorSize * remainingSectors)); else - { for(ulong i = 0; i < remainingSectors; i++) { byte[] sector; @@ -951,7 +906,6 @@ namespace DiscImageChef.DiscImages br.BaseStream.Seek(sectorSkip, SeekOrigin.Current); Array.Copy(sector, 0, buffer, (int)(i * sectorSize), sectorSize); } - } return buffer; } @@ -1045,7 +999,7 @@ namespace DiscImageChef.DiscImages public override List GetSessionTracks(Session session) { - if(discimage.Sessions.Contains(session)) { return GetSessionTracks(session.SessionSequence); } + if(discimage.Sessions.Contains(session)) return GetSessionTracks(session.SessionSequence); throw new ImageNotSupportedException("Session does not exist in disc image"); } @@ -1067,7 +1021,6 @@ namespace DiscImageChef.DiscImages } foreach(GdiTrack gdiTrack in discimage.Tracks) - { if(gdiTrack.HighDensity == expectedDensity) { Track _track = new Track(); @@ -1092,7 +1045,6 @@ namespace DiscImageChef.DiscImages tracks.Add(_track); } - } return tracks; } diff --git a/DiscImageChef.DiscImages/HDCopy.cs b/DiscImageChef.DiscImages/HDCopy.cs index 96d9033b3..94a307178 100644 --- a/DiscImageChef.DiscImages/HDCopy.cs +++ b/DiscImageChef.DiscImages/HDCopy.cs @@ -223,7 +223,7 @@ namespace DiscImageChef.DiscImages if(fheader.trackMap[0] != 1 || fheader.trackMap[1] != 1) return false; // all other tracks must be either present (=1) or absent (=0) - for(int i = 0; i < 2 * 82; i++) { if(fheader.trackMap[i] > 1) return false; } + for(int i = 0; i < 2 * 82; i++) if(fheader.trackMap[i] > 1) return false; // TODO: validate the tracks // For now, having a valid header should be sufficient. @@ -268,12 +268,7 @@ namespace DiscImageChef.DiscImages // build table of track offsets for(int i = 0; i < ImageInfo.Cylinders * 2; i++) - { - if(fheader.trackMap[i] == 0) - { - // track is not present in image - trackOffset[i] = -1; - } + if(fheader.trackMap[i] == 0) trackOffset[i] = -1; else { // track is present, read the block header @@ -295,7 +290,6 @@ namespace DiscImageChef.DiscImages // skip the block data stream.Seek(blkLength, SeekOrigin.Current); } - } // ensure that the last track is present completely if(currentOffset > stream.Length) return false; @@ -374,10 +368,8 @@ namespace DiscImageChef.DiscImages public override MediaType GetMediaType() { foreach(MediaTypeTableEntry ent in mediaTypes) - { if(ent.Tracks == ImageInfo.Cylinders && ent.SectorsPerTrack == ImageInfo.SectorsPerTrack) return ent.MediaType; - } return MediaType.Unknown; } @@ -410,17 +402,15 @@ namespace DiscImageChef.DiscImages int sIndex = 0; // source buffer position int dIndex = 0; // destination buffer position while(sIndex < compressedLength) - { if(cBuffer[sIndex] == escapeByte) { sIndex++; // skip over escape byte fillByte = cBuffer[sIndex++]; // read fill byte fillCount = cBuffer[sIndex++]; // read fill count // fill destination buffer - for(int i = 0; i < fillCount; i++) { trackData[dIndex++] = fillByte; } + for(int i = 0; i < fillCount; i++) trackData[dIndex++] = fillByte; } - else { trackData[dIndex++] = cBuffer[sIndex++]; } - } + else trackData[dIndex++] = cBuffer[sIndex++]; // check that the number of bytes decompressed matches a whole track if(dIndex != ImageInfo.SectorSize * ImageInfo.SectorsPerTrack) @@ -443,11 +433,7 @@ namespace DiscImageChef.DiscImages throw new ArgumentOutOfRangeException(nameof(sectorAddress), "Sector address not found"); result = new byte[ImageInfo.SectorSize]; - if(trackOffset[trackNum] == -1) - { - // track is not present. Fill with zeroes. - Array.Clear(result, 0, (int)ImageInfo.SectorSize); - } + if(trackOffset[trackNum] == -1) Array.Clear(result, 0, (int)ImageInfo.SectorSize); else { // track is present in file, make sure it has been loaded @@ -466,10 +452,7 @@ namespace DiscImageChef.DiscImages if(sectorAddress + length > ImageInfo.Sectors) throw new ArgumentOutOfRangeException(nameof(length), "Requested more sectors than available"); - for(int i = 0; i < length; i++) - { - ReadSector(sectorAddress + (ulong)i).CopyTo(result, i * ImageInfo.SectorSize); - } + for(int i = 0; i < length; i++) ReadSector(sectorAddress + (ulong)i).CopyTo(result, i * ImageInfo.SectorSize); return result; } diff --git a/DiscImageChef.DiscImages/IMD.cs b/DiscImageChef.DiscImages/IMD.cs index 645a132d3..ddae570ed 100644 --- a/DiscImageChef.DiscImages/IMD.cs +++ b/DiscImageChef.DiscImages/IMD.cs @@ -184,7 +184,7 @@ namespace DiscImageChef.DiscImages stream.Read(bpsbytes, 0, bpsbytes.Length); for(int i = 0; i < spt; i++) bps[i] = BitConverter.ToUInt16(bpsbytes, i * 2); } - else { for(int i = 0; i < spt; i++) bps[i] = (ushort)(128 << n); } + else for(int i = 0; i < spt; i++) bps[i] = (ushort)(128 << n); if(spt > ImageInfo.SectorsPerTrack) ImageInfo.SectorsPerTrack = spt; diff --git a/DiscImageChef.DiscImages/NDIF.cs b/DiscImageChef.DiscImages/NDIF.cs index 300b244f5..8f5044230 100644 --- a/DiscImageChef.DiscImages/NDIF.cs +++ b/DiscImageChef.DiscImages/NDIF.cs @@ -482,14 +482,12 @@ namespace DiscImageChef.DiscImages ulong chunkStartSector = 0; foreach(KeyValuePair kvp in chunks) - { if(sectorAddress >= kvp.Key) { currentChunk = kvp.Value; chunkFound = true; chunkStartSector = kvp.Key; } - } long relOff = ((long)sectorAddress - (long)chunkStartSector) * SECTOR_SIZE; diff --git a/DiscImageChef.DiscImages/Nero.cs b/DiscImageChef.DiscImages/Nero.cs index 6f23dccc9..97b20af4e 100644 --- a/DiscImageChef.DiscImages/Nero.cs +++ b/DiscImageChef.DiscImages/Nero.cs @@ -900,14 +900,8 @@ namespace DiscImageChef.DiscImages DicConsole.DebugWriteLine("Nero plugin", "footerV2.ChunkID = 0x{0:X8}", footerV2.ChunkId); DicConsole.DebugWriteLine("Nero plugin", "footerV2.FirstChunkOffset = {0}", footerV2.FirstChunkOffset); - if(footerV2.ChunkId == NeroV2FooterId && footerV2.FirstChunkOffset < (ulong)imageStream.Length) - { - return true; - } - if(footerV1.ChunkId == NeroV1FooterId && footerV1.FirstChunkOffset < (ulong)imageStream.Length) - { - return true; - } + if(footerV2.ChunkId == NeroV2FooterId && footerV2.FirstChunkOffset < (ulong)imageStream.Length) return true; + if(footerV1.ChunkId == NeroV1FooterId && footerV1.FirstChunkOffset < (ulong)imageStream.Length) return true; return false; } @@ -1842,19 +1836,11 @@ namespace DiscImageChef.DiscImages public override byte[] ReadSectors(ulong sectorAddress, uint length) { foreach(KeyValuePair kvp in offsetmap) - { if(sectorAddress >= kvp.Value) - { foreach(Track _track in imageTracks) - { if(_track.TrackSequence == kvp.Key) - { if(sectorAddress - kvp.Value < _track.TrackEndSector - _track.TrackStartSector) return ReadSectors(sectorAddress - kvp.Value, length, kvp.Key); - } - } - } - } throw new ArgumentOutOfRangeException(nameof(sectorAddress), string.Format("Sector address {0} not found", sectorAddress)); @@ -1863,19 +1849,11 @@ namespace DiscImageChef.DiscImages public override byte[] ReadSectorsTag(ulong sectorAddress, uint length, SectorTagType tag) { foreach(KeyValuePair kvp in offsetmap) - { if(sectorAddress >= kvp.Value) - { foreach(Track _track in imageTracks) - { if(_track.TrackSequence == kvp.Key) - { if(sectorAddress - kvp.Value < _track.TrackEndSector - _track.TrackStartSector) return ReadSectorsTag(sectorAddress - kvp.Value, length, kvp.Key, tag); - } - } - } - } throw new ArgumentOutOfRangeException(nameof(sectorAddress), string.Format("Sector address {0} not found", sectorAddress)); @@ -1970,7 +1948,6 @@ namespace DiscImageChef.DiscImages SeekOrigin.Begin); if(sectorOffset == 0 && sectorSkip == 0) buffer = br.ReadBytes((int)(sectorSize * length)); else - { for(int i = 0; i < length; i++) { byte[] sector; @@ -1979,7 +1956,6 @@ namespace DiscImageChef.DiscImages br.BaseStream.Seek(sectorSkip, SeekOrigin.Current); Array.Copy(sector, 0, buffer, i * sectorSize, sectorSize); } - } return buffer; } @@ -2201,7 +2177,6 @@ namespace DiscImageChef.DiscImages SeekOrigin.Begin); if(sectorOffset == 0 && sectorSkip == 0) buffer = br.ReadBytes((int)(sectorSize * length)); else - { for(int i = 0; i < length; i++) { byte[] sector; @@ -2210,7 +2185,6 @@ namespace DiscImageChef.DiscImages br.BaseStream.Seek(sectorSkip, SeekOrigin.Current); Array.Copy(sector, 0, buffer, i * sectorSize, sectorSize); } - } return buffer; } @@ -2228,19 +2202,11 @@ namespace DiscImageChef.DiscImages public override byte[] ReadSectorsLong(ulong sectorAddress, uint length) { foreach(KeyValuePair kvp in offsetmap) - { if(sectorAddress >= kvp.Value) - { foreach(Track _track in imageTracks) - { if(_track.TrackSequence == kvp.Key) - { if(sectorAddress - kvp.Value < _track.TrackEndSector - _track.TrackStartSector) return ReadSectorsLong(sectorAddress - kvp.Value, length, kvp.Key); - } - } - } - } throw new ArgumentOutOfRangeException(nameof(sectorAddress), string.Format("Sector address {0} not found", sectorAddress)); @@ -2312,7 +2278,6 @@ namespace DiscImageChef.DiscImages if(sectorOffset == 0 && sectorSkip == 0) buffer = br.ReadBytes((int)(sectorSize * length)); else - { for(int i = 0; i < length; i++) { byte[] sector; @@ -2322,7 +2287,6 @@ namespace DiscImageChef.DiscImages Array.Copy(sector, 0, buffer, i * sectorSize, sectorSize); } - } return buffer; } diff --git a/DiscImageChef.DiscImages/PartClone.cs b/DiscImageChef.DiscImages/PartClone.cs index 42a9108cb..8f58e507d 100644 --- a/DiscImageChef.DiscImages/PartClone.cs +++ b/DiscImageChef.DiscImages/PartClone.cs @@ -217,8 +217,6 @@ namespace DiscImageChef.DiscImages // Flux if(next != current) - { - // Next is used if(next) { extentStart = i; @@ -229,7 +227,6 @@ namespace DiscImageChef.DiscImages extents.Add(extentStart, i); extentsOff.TryGetValue(extentStart, out ulong foo); } - } if(next && current) blockOff++; @@ -300,13 +297,11 @@ namespace DiscImageChef.DiscImages bool allEmpty = true; for(uint i = 0; i < length; i++) - { if(byteMap[sectorAddress + i] != 0) { allEmpty = false; break; } - } if(allEmpty) return new byte[pHdr.blockSize * length]; diff --git a/DiscImageChef.DiscImages/Partimage.cs b/DiscImageChef.DiscImages/Partimage.cs index 2430e1d76..b7de32775 100644 --- a/DiscImageChef.DiscImages/Partimage.cs +++ b/DiscImageChef.DiscImages/Partimage.cs @@ -518,8 +518,6 @@ namespace DiscImageChef.DiscImages // Flux if(next != current) - { - // Next is used if(next) { extentStart = i; @@ -530,7 +528,6 @@ namespace DiscImageChef.DiscImages extents.Add(extentStart, i); extentsOff.TryGetValue(extentStart, out ulong foo); } - } if(next && current) blockOff++; @@ -617,13 +614,11 @@ namespace DiscImageChef.DiscImages bool allEmpty = true; for(uint i = 0; i < length; i++) - { if((bitmap[sectorAddress / 8] & (1 << (int)(sectorAddress % 8))) != 0) { allEmpty = false; break; } - } if(allEmpty) return new byte[ImageInfo.SectorSize * length]; diff --git a/DiscImageChef.DiscImages/QED.cs b/DiscImageChef.DiscImages/QED.cs index 51ca4a7a0..82aeca90f 100644 --- a/DiscImageChef.DiscImages/QED.cs +++ b/DiscImageChef.DiscImages/QED.cs @@ -501,7 +501,7 @@ namespace DiscImageChef.DiscImages cnt++; val >>= 1; } - if((val & 0x1) == 0) { cnt++; } + if((val & 0x1) == 0) cnt++; return cnt; } diff --git a/DiscImageChef.DiscImages/T98.cs b/DiscImageChef.DiscImages/T98.cs index 8002d6bfe..f4efad0d4 100644 --- a/DiscImageChef.DiscImages/T98.cs +++ b/DiscImageChef.DiscImages/T98.cs @@ -82,7 +82,7 @@ namespace DiscImageChef.DiscImages byte[] hdr_b = new byte[256]; stream.Read(hdr_b, 0, hdr_b.Length); - for(int i = 4; i < 256; i++) { if(hdr_b[i] != 0) return false; } + for(int i = 4; i < 256; i++) if(hdr_b[i] != 0) return false; int cylinders = BitConverter.ToInt32(hdr_b, 0); @@ -103,7 +103,7 @@ namespace DiscImageChef.DiscImages byte[] hdr_b = new byte[256]; stream.Read(hdr_b, 0, hdr_b.Length); - for(int i = 4; i < 256; i++) { if(hdr_b[i] != 0) return false; } + for(int i = 4; i < 256; i++) if(hdr_b[i] != 0) return false; int cylinders = BitConverter.ToInt32(hdr_b, 0); diff --git a/DiscImageChef.DiscImages/TeleDisk.cs b/DiscImageChef.DiscImages/TeleDisk.cs index fbba4e6cd..955e346e6 100644 --- a/DiscImageChef.DiscImages/TeleDisk.cs +++ b/DiscImageChef.DiscImages/TeleDisk.cs @@ -357,7 +357,7 @@ namespace DiscImageChef.DiscImages inStream.Seek(12, SeekOrigin.Begin); stream.Seek(12, SeekOrigin.Begin); init_Decode(); - do { if((rd = Decode(out obuf, BUFSZ)) > 0) stream.Write(obuf, 0, rd); } + do if((rd = Decode(out obuf, BUFSZ)) > 0) stream.Write(obuf, 0, rd); while(rd == BUFSZ); } else @@ -416,10 +416,8 @@ namespace DiscImageChef.DiscImages aDiskCrcHasFailed |= cmtcrc != commentHeader.Crc; for(int i = 0; i < commentBlock.Length; i++) - { - // Replace NULLs, used by TeleDisk as newline markers, with UNIX newline marker + // Replace NULLs, used by TeleDisk as newline markers, with UNIX newline marker if(commentBlock[i] == 0x00) commentBlock[i] = 0x0A; - } ImageInfo.ImageComments = System.Text.Encoding.ASCII.GetString(commentBlock); @@ -527,7 +525,6 @@ namespace DiscImageChef.DiscImages break; if(teleDiskTrack.Sectors < ImageInfo.SectorsPerTrack) - { if(teleDiskTrack.Cylinder + 1 == totalCylinders) { hasLeadOutOnHead0 |= teleDiskTrack.Head == 0; @@ -535,7 +532,6 @@ namespace DiscImageChef.DiscImages if(ImageInfo.Cylinders == totalCylinders) ImageInfo.Cylinders--; } else ImageInfo.SectorsPerTrack = teleDiskTrack.Sectors; - } for(byte processedSectors = 0; processedSectors < teleDiskTrack.Sectors; processedSectors++) { TeleDiskSectorHeader teleDiskSector = new TeleDiskSectorHeader(); @@ -676,50 +672,34 @@ namespace DiscImageChef.DiscImages DicConsole.DebugWriteLine("TeleDisk plugin", "\t\tLBA: {0}", lba); if((teleDiskSector.Flags & FLAGS_SECTOR_NO_ID) != FLAGS_SECTOR_NO_ID) - { if(sectorsData[teleDiskTrack.Cylinder][teleDiskTrack.Head][teleDiskSector.SectorNumber] != null) - { if((teleDiskSector.Flags & FLAGS_SECTOR_DUPLICATE) == FLAGS_SECTOR_DUPLICATE) - { DicConsole.DebugWriteLine("TeleDisk plugin", "\t\tSector {0} on cylinder {1} head {2} is duplicate, and marked so", teleDiskSector.SectorNumber, teleDiskSector.Cylinder, teleDiskSector.Head); - } else - { DicConsole.DebugWriteLine("TeleDisk plugin", "\t\tSector {0} on cylinder {1} head {2} is duplicate, but is not marked so", teleDiskSector.SectorNumber, teleDiskSector.Cylinder, teleDiskSector.Head); - } - } else { sectorsData[teleDiskTrack.Cylinder][teleDiskTrack.Head][teleDiskSector.SectorNumber] = decodedData; totalDiskSize += (uint)decodedData.Length; } - } } } MemoryStream leadOutMs = new MemoryStream(); if(hasLeadOutOnHead0) - { for(int i = 0; i < sectorsData[totalCylinders - 1][0].Length; i++) - { if(sectorsData[totalCylinders - 1][0][i] != null) leadOutMs.Write(sectorsData[totalCylinders - 1][0][i], 0, sectorsData[totalCylinders - 1][0][i].Length); - } - } if(hasLeadOutOnHead1) - { for(int i = 0; i < sectorsData[totalCylinders - 1][1].Length; i++) - { if(sectorsData[totalCylinders - 1][1][i] != null) leadOutMs.Write(sectorsData[totalCylinders - 1][1][i], 0, sectorsData[totalCylinders - 1][1][i].Length); - } - } if(leadOutMs.Length != 0) { @@ -911,10 +891,8 @@ namespace DiscImageChef.DiscImages crc ^= (ushort)((buffer[counter] & 0xFF) << 8); for(int i = 0; i < 8; i++) - { if((crc & 0x8000) > 0) crc = (ushort)((crc << 1) ^ TELE_DISK_CRC_POLY); else crc = (ushort)(crc << 1); - } counter++; } @@ -1517,14 +1495,12 @@ namespace DiscImageChef.DiscImages /* halven cumulative freq for leaf nodes */ j = 0; for(i = 0; i < T; i++) - { if(son[i] >= T) { freq[j] = (ushort)((freq[i] + 1) / 2); son[j] = son[i]; j++; } - } /* make a tree : first, connect children nodes */ for(i = 0, j = N_CHAR; j < T; i += 2, j++) { @@ -1543,10 +1519,8 @@ namespace DiscImageChef.DiscImages } /* connect parent nodes */ for(i = 0; i < T; i++) - { - if((k = son[i]) >= T) { prnt[k] = i; } - else { prnt[k] = prnt[k + 1] = i; } - } + if((k = son[i]) >= T) prnt[k] = i; + else prnt[k] = prnt[k + 1] = i; } /* update freq tree */ @@ -1555,7 +1529,7 @@ namespace DiscImageChef.DiscImages { int i, j, k, l; - if(freq[R] == MAX_FREQ) { Reconst(); } + if(freq[R] == MAX_FREQ) Reconst(); c = prnt[c + T]; do { @@ -1663,7 +1637,6 @@ namespace DiscImageChef.DiscImages buf = new byte[len]; int count; // was an unsigned long, seems unnecessary for(count = 0; count < len;) - { if(tdctl.Bufcnt == 0) { if((c = DecodeChar()) < 0) return count; // fatal error @@ -1699,7 +1672,6 @@ namespace DiscImageChef.DiscImages // reset bufcnt after copy string from text_buf[] if(tdctl.Bufndx >= tdctl.Bufcnt) tdctl.Bufndx = tdctl.Bufcnt = 0; } - } return count; // count == len, success } diff --git a/DiscImageChef.DiscImages/VHD.cs b/DiscImageChef.DiscImages/VHD.cs index a767f5dc9..8299e8be8 100644 --- a/DiscImageChef.DiscImages/VHD.cs +++ b/DiscImageChef.DiscImages/VHD.cs @@ -839,7 +839,6 @@ namespace DiscImageChef.DiscImages { locatorEntriesData = new byte[8][]; for(int i = 0; i < 8; i++) - { if(thisDynamic.LocatorEntries[i].PlatformCode != 0x00000000) { locatorEntriesData[i] = new byte[thisDynamic.LocatorEntries[i].PlatformDataLength]; @@ -873,7 +872,6 @@ namespace DiscImageChef.DiscImages break; } } - } int currentLocator = 0; bool locatorFound = false; diff --git a/DiscImageChef.DiscImages/VHDX.cs b/DiscImageChef.DiscImages/VHDX.cs index a9bd71761..7c4e5c331 100644 --- a/DiscImageChef.DiscImages/VHDX.cs +++ b/DiscImageChef.DiscImages/VHDX.cs @@ -674,7 +674,6 @@ namespace DiscImageChef.DiscImages ulong skipSize = 0; for(ulong i = 0; i < dataBlocks; i++) - { if(readChunks == chunkRatio) { if(hasParent) @@ -688,7 +687,6 @@ namespace DiscImageChef.DiscImages blockAllocationTable[i] = BitConverter.ToUInt64(batB, (int)(i * 8 + skipSize)); readChunks++; } - } if(hasParent) { @@ -696,11 +694,7 @@ namespace DiscImageChef.DiscImages MemoryStream sectorBmpMs = new MemoryStream(); foreach(ulong pt in sectorBitmapPointers) - { - if((pt & BAT_FLAGS_MASK) == SECTOR_BITMAP_NOT_PRESENT) - { - sectorBmpMs.Write(new byte[1048576], 0, 1048576); - } + if((pt & BAT_FLAGS_MASK) == SECTOR_BITMAP_NOT_PRESENT) sectorBmpMs.Write(new byte[1048576], 0, 1048576); else if((pt & BAT_FLAGS_MASK) == SECTOR_BITMAP_PRESENT) { stream.Seek((long)((pt & BAT_FILE_OFFSET_MASK) * 1048576), SeekOrigin.Begin); @@ -713,7 +707,6 @@ namespace DiscImageChef.DiscImages ImageNotSupportedException(string .Format("Unsupported sector bitmap block flags (0x{0:X16}) found, not proceeding.", pt & BAT_FLAGS_MASK)); - } sectorBitmap = sectorBmpMs.ToArray(); sectorBmpMs.Close(); diff --git a/DiscImageChef.DiscImages/ZZZRawImage.cs b/DiscImageChef.DiscImages/ZZZRawImage.cs index 7fe3951db..980e9978f 100644 --- a/DiscImageChef.DiscImages/ZZZRawImage.cs +++ b/DiscImageChef.DiscImages/ZZZRawImage.cs @@ -131,7 +131,6 @@ namespace DiscImageChef.DiscImages else if((extension == ".adf" || extension == ".adl") && imageFilter.GetDataForkLength() == 819200) ImageInfo.SectorSize = 1024; else - { switch(imageFilter.GetDataForkLength()) { case 242944: @@ -188,7 +187,6 @@ namespace DiscImageChef.DiscImages ImageInfo.SectorSize = 512; break; } - } ImageInfo.ImageSize = (ulong)imageFilter.GetDataForkLength(); ImageInfo.ImageCreationTime = imageFilter.GetCreationTime(); @@ -308,14 +306,12 @@ namespace DiscImageChef.DiscImages // Sharp X68000 SASI hard disks if(extension == ".hdf") - { if(ImageInfo.ImageSize % 256 == 0) { ImageInfo.SectorSize = 256; ImageInfo.Sectors = ImageInfo.ImageSize / ImageInfo.SectorSize; ImageInfo.MediaType = MediaType.GENERIC_HDD; } - } if(ImageInfo.XmlMediaType == XmlMediaType.OpticalDisc) { @@ -675,7 +671,7 @@ namespace DiscImageChef.DiscImages public override byte[] ReadSectors(ulong sectorAddress, uint length) { - if(differentTrackZeroSize) { throw new NotImplementedException("Not yet implemented"); } + if(differentTrackZeroSize) throw new NotImplementedException("Not yet implemented"); else { if(sectorAddress > ImageInfo.Sectors - 1) @@ -920,7 +916,6 @@ namespace DiscImageChef.DiscImages return MediaType.Unknown; } else - { switch(ImageInfo.ImageSize) { case 80384: return MediaType.ECMA_66; @@ -1018,7 +1013,6 @@ namespace DiscImageChef.DiscImages default: return MediaType.GENERIC_HDD; } - } } #endregion diff --git a/DiscImageChef.Filesystems/Acorn.cs b/DiscImageChef.Filesystems/Acorn.cs index e49e8fb05..dac8fa771 100644 --- a/DiscImageChef.Filesystems/Acorn.cs +++ b/DiscImageChef.Filesystems/Acorn.cs @@ -511,10 +511,7 @@ namespace DiscImageChef.Filesystems ptr = GCHandle.Alloc(sector, GCHandleType.Pinned); oldRoot = (OldDirectory)Marshal.PtrToStructure(ptr.AddrOfPinnedObject(), typeof(OldDirectory)); - if(oldRoot.header.magic == oldDirMagic && oldRoot.tail.magic == oldDirMagic) - { - namebytes = oldRoot.tail.name; - } + if(oldRoot.header.magic == oldDirMagic && oldRoot.tail.magic == oldDirMagic) namebytes = oldRoot.tail.name; else { // RISC OS says the old directory can't be in the new location, hard disks created by RISC OS 3.10 do that... @@ -534,10 +531,7 @@ namespace DiscImageChef.Filesystems oldRoot = (OldDirectory)Marshal.PtrToStructure(ptr.AddrOfPinnedObject(), typeof(OldDirectory)); - if(oldRoot.header.magic == oldDirMagic && oldRoot.tail.magic == oldDirMagic) - { - namebytes = oldRoot.tail.name; - } + if(oldRoot.header.magic == oldDirMagic && oldRoot.tail.magic == oldDirMagic) namebytes = oldRoot.tail.name; else { sector = imagePlugin.ReadSectors(sbSector, sectorsToRead); @@ -551,10 +545,7 @@ namespace DiscImageChef.Filesystems ptr = GCHandle.Alloc(sector, GCHandleType.Pinned); newRoot = (NewDirectory)Marshal.PtrToStructure(ptr.AddrOfPinnedObject(), typeof(NewDirectory)); - if(newRoot.header.magic == newDirMagic && newRoot.tail.magic == newDirMagic) - { - namebytes = newRoot.tail.title; - } + if(newRoot.header.magic == newDirMagic && newRoot.tail.magic == newDirMagic) namebytes = newRoot.tail.title; } } } diff --git a/DiscImageChef.Filesystems/AppleDOS/File.cs b/DiscImageChef.Filesystems/AppleDOS/File.cs index 4cfee1c93..521ca4134 100644 --- a/DiscImageChef.Filesystems/AppleDOS/File.cs +++ b/DiscImageChef.Filesystems/AppleDOS/File.cs @@ -57,10 +57,7 @@ namespace DiscImageChef.Filesystems.AppleDOS if(debug && (string.Compare(path, "$", StringComparison.InvariantCulture) == 0 || string.Compare(path, "$Boot", StringComparison.InvariantCulture) == 0 || - string.Compare(path, "$Vtoc", StringComparison.InvariantCulture) == 0)) - { - attributes |= FileAttributes.System; - } + string.Compare(path, "$Vtoc", StringComparison.InvariantCulture) == 0)) attributes |= FileAttributes.System; return Errno.NoError; } diff --git a/DiscImageChef.Filesystems/AppleDOS/Xattr.cs b/DiscImageChef.Filesystems/AppleDOS/Xattr.cs index 522db20c3..3e79f914c 100644 --- a/DiscImageChef.Filesystems/AppleDOS/Xattr.cs +++ b/DiscImageChef.Filesystems/AppleDOS/Xattr.cs @@ -89,10 +89,7 @@ namespace DiscImageChef.Filesystems.AppleDOS if(debug && (string.Compare(path, "$", StringComparison.InvariantCulture) == 0 || string.Compare(path, "$Boot", StringComparison.InvariantCulture) == 0 || - string.Compare(path, "$Vtoc", StringComparison.InvariantCulture) == 0)) - { - return Errno.NoSuchExtendedAttribute; - } + string.Compare(path, "$Vtoc", StringComparison.InvariantCulture) == 0)) return Errno.NoSuchExtendedAttribute; if(!catalogCache.ContainsKey(filename)) return Errno.NoSuchFile; diff --git a/DiscImageChef.Filesystems/AppleHFS.cs b/DiscImageChef.Filesystems/AppleHFS.cs index 83e837abd..418f929e4 100644 --- a/DiscImageChef.Filesystems/AppleHFS.cs +++ b/DiscImageChef.Filesystems/AppleHFS.cs @@ -243,7 +243,7 @@ namespace DiscImageChef.Filesystems sb.AppendLine(); sb.AppendLine("Boot Block:"); if((BB.boot_flags & 0x40) == 0x40) sb.AppendLine("Boot block should be executed."); - if((BB.boot_flags & 0x80) == 0x80) { sb.AppendLine("Boot block is in new unknown format."); } + if((BB.boot_flags & 0x80) == 0x80) sb.AppendLine("Boot block is in new unknown format."); else { if(BB.boot_flags > 0) sb.AppendLine("Allocate secondary sound buffer at boot."); diff --git a/DiscImageChef.Filesystems/AppleHFSPlus.cs b/DiscImageChef.Filesystems/AppleHFSPlus.cs index d32cdb437..c3d0d73d1 100644 --- a/DiscImageChef.Filesystems/AppleHFSPlus.cs +++ b/DiscImageChef.Filesystems/AppleHFSPlus.cs @@ -111,9 +111,9 @@ namespace DiscImageChef.Filesystems hfsp_offset = (ulong)((drAlBlSt * 512 + xdrStABNt * drAlBlkSiz) / imagePlugin.GetSectorSize()); } - else { hfsp_offset = 0; } + else hfsp_offset = 0; } - else { hfsp_offset = 0; } + else hfsp_offset = 0; vh_sector = imagePlugin.ReadSectors(partition.Start + hfsp_offset, sectorsToRead); // Read volume header diff --git a/DiscImageChef.Filesystems/AppleMFS/Info.cs b/DiscImageChef.Filesystems/AppleMFS/Info.cs index 39c9a9562..a51a46892 100644 --- a/DiscImageChef.Filesystems/AppleMFS/Info.cs +++ b/DiscImageChef.Filesystems/AppleMFS/Info.cs @@ -149,7 +149,7 @@ namespace DiscImageChef.Filesystems.AppleMFS sb.AppendLine(); sb.AppendLine("Boot Block:"); if((BB.boot_flags & 0x40) == 0x40) sb.AppendLine("Boot block should be executed."); - if((BB.boot_flags & 0x80) == 0x80) { sb.AppendLine("Boot block is in new unknown format."); } + if((BB.boot_flags & 0x80) == 0x80) sb.AppendLine("Boot block is in new unknown format."); else { if(BB.sec_sv_pages > 0) sb.AppendLine("Allocate secondary sound buffer at boot."); diff --git a/DiscImageChef.Filesystems/BFS.cs b/DiscImageChef.Filesystems/BFS.cs index 7ed65c119..c9f1de70f 100644 --- a/DiscImageChef.Filesystems/BFS.cs +++ b/DiscImageChef.Filesystems/BFS.cs @@ -124,18 +124,14 @@ namespace DiscImageChef.Filesystems besb.magic1 = BigEndianBitConverter.ToUInt32(sb_sector, 0x20); if(besb.magic1 == BEFS_MAGIC1 || besb.magic1 == BEFS_CIGAM1) // Magic is at offset - { littleEndian = besb.magic1 == BEFS_CIGAM1; - } else { sb_sector = imagePlugin.ReadSector(1 + partition.Start); besb.magic1 = BigEndianBitConverter.ToUInt32(sb_sector, 0x20); if(besb.magic1 == BEFS_MAGIC1 || besb.magic1 == BEFS_CIGAM1) // There is a boot sector - { littleEndian = besb.magic1 == BEFS_CIGAM1; - } else if(sb_sector.Length >= 0x400) { byte[] temp = imagePlugin.ReadSector(0 + partition.Start); @@ -181,10 +177,8 @@ namespace DiscImageChef.Filesystems } if(besb.flags == BEFS_CLEAN) - { if(besb.log_start == besb.log_end) sb.AppendLine("Filesystem is clean"); else sb.AppendLine("Filesystem is dirty"); - } else if(besb.flags == BEFS_DIRTY) sb.AppendLine("Filesystem is dirty"); else sb.AppendFormat("Unknown flags: {0:X8}", besb.flags).AppendLine(); diff --git a/DiscImageChef.Filesystems/CPM/Dir.cs b/DiscImageChef.Filesystems/CPM/Dir.cs index bf41b5c41..9d95ee2a2 100644 --- a/DiscImageChef.Filesystems/CPM/Dir.cs +++ b/DiscImageChef.Filesystems/CPM/Dir.cs @@ -77,29 +77,17 @@ namespace DiscImageChef.Filesystems.CPM if((entry.statusUser & 0x7F) < 0x20) { - for(int f = 0; f < 8; f++) - { - if(entry.filename[f] < 0x20 && entry.filename[f] != 0x00) return false; - } + for(int f = 0; f < 8; f++) if(entry.filename[f] < 0x20 && entry.filename[f] != 0x00) return false; - for(int e = 0; e < 3; e++) - { - if(entry.extension[e] < 0x20 && entry.extension[e] != 0x00) return false; - } + for(int e = 0; e < 3; e++) if(entry.extension[e] < 0x20 && entry.extension[e] != 0x00) return false; if(!ArrayHelpers.ArrayIsNullOrWhiteSpace(entry.filename)) fileCount++; } else if(entry.statusUser == 0x20) { - for(int f = 0; f < 8; f++) - { - if(entry.filename[f] < 0x20 && entry.filename[f] != 0x00) return false; - } + for(int f = 0; f < 8; f++) if(entry.filename[f] < 0x20 && entry.filename[f] != 0x00) return false; - for(int e = 0; e < 3; e++) - { - if(entry.extension[e] < 0x20 && entry.extension[e] != 0x00) return false; - } + for(int e = 0; e < 3; e++) if(entry.extension[e] < 0x20 && entry.extension[e] != 0x00) return false; label = Encoding.ASCII.GetString(directory, off + 1, 11).Trim(); labelCreationDate = new byte[4]; @@ -108,10 +96,8 @@ namespace DiscImageChef.Filesystems.CPM Array.Copy(directory, off + 28, labelUpdateDate, 0, 4); } else if(entry.statusUser == 0x21) - { - if(directory[off + 1] == 0x00) { thirdPartyTimestamps = true; } + if(directory[off + 1] == 0x00) thirdPartyTimestamps = true; else standardTimestamps |= directory[off + 21] == 0x00 && directory[off + 31] == 0x00; - } } return fileCount > 0; diff --git a/DiscImageChef.Filesystems/CPM/Super.cs b/DiscImageChef.Filesystems/CPM/Super.cs index 6a98d6f57..8c6bce2a2 100644 --- a/DiscImageChef.Filesystems/CPM/Super.cs +++ b/DiscImageChef.Filesystems/CPM/Super.cs @@ -130,10 +130,7 @@ namespace DiscImageChef.Filesystems.CPM byte[] readSector = device.ReadSector((ulong)((int)partition.Start + p / sectorMask.Length * sectorMask.Length + sectorMask[p % sectorMask.Length])); - if(workingDefinition.complement) - { - for(int b = 0; b < readSector.Length; b++) readSector[b] = (byte)(~readSector[b] & 0xFF); - } + if(workingDefinition.complement) for(int b = 0; b < readSector.Length; b++) readSector[b] = (byte)(~readSector[b] & 0xFF); deinterleavedSectors.Add((ulong)p, readSector); } @@ -155,14 +152,12 @@ namespace DiscImageChef.Filesystems.CPM // May it happen? Just in case, CP/M blocks are smaller than physical sectors if(sector.Length > blockSize) - { for(int i = 0; i < sector.Length / blockSize; i++) { byte[] tmp = new byte[blockSize]; Array.Copy(sector, blockSize * i, tmp, 0, blockSize); allocationBlocks.Add(blockNo++, tmp); } - } // CP/M blocks are larger than physical sectors else if(sector.Length < blockSize) { @@ -218,11 +213,8 @@ namespace DiscImageChef.Filesystems.CPM // For each directory entry for(int dOff = 0; dOff < directory.Length; dOff += 32) - { - // Describes a file (does not support PDOS entries with user >= 16, because they're identical to password entries + // Describes a file (does not support PDOS entries with user >= 16, because they're identical to password entries if((directory[dOff] & 0x7F) < 0x10) - { - // If there are more than 256 allocation blocks, the allocation block becomes a 16-bit value if(allocationBlocks.Count > 256) { DirectoryEntry16 entry = new DirectoryEntry16(); @@ -290,10 +282,7 @@ namespace DiscImageChef.Filesystems.CPM // because that's where the directory resides. // There is also a field telling how many bytes are used in the last block, but its meaning is non-standard so // we must ignore it. - foreach(ushort blk in entry.allocations) - { - if(!blocks.Contains(blk) && blk != 0) blocks.Add(blk); - } + foreach(ushort blk in entry.allocations) if(!blocks.Contains(blk) && blk != 0) blocks.Add(blk); // Save the file fInfo.UID = (ulong)user; @@ -387,10 +376,7 @@ namespace DiscImageChef.Filesystems.CPM // because that's where the directory resides. // There is also a field telling how many bytes are used in the last block, but its meaning is non-standard so // we must ignore it. - foreach(ushort blk in entry.allocations) - { - if(!blocks.Contains(blk) && blk != 0) blocks.Add(blk); - } + foreach(ushort blk in entry.allocations) if(!blocks.Contains(blk) && blk != 0) blocks.Add(blk); // Save the file fInfo.UID = (ulong)user; @@ -417,7 +403,6 @@ namespace DiscImageChef.Filesystems.CPM dirCnt++; } - } // A password entry (or a file entry in PDOS, but this does not handle that case) else if((directory[dOff] & 0x7F) >= 0x10 && (directory[dOff] & 0x7F) < 0x20) { @@ -499,8 +484,6 @@ namespace DiscImageChef.Filesystems.CPM } // Timestamp entry else if((directory[dOff] & 0x7F) == 0x21) - { - // These places must be zero on CP/M 3 timestamp if(directory[dOff + 10] == 0x00 && directory[dOff + 20] == 0x00 && directory[dOff + 30] == 0x00 && directory[dOff + 31] == 0x00) { @@ -622,8 +605,6 @@ namespace DiscImageChef.Filesystems.CPM file3 = null; dirCnt = 0; } - } - } // Cache all files. As CP/M maximum volume size is 8 Mib // this should not be a problem @@ -641,13 +622,11 @@ namespace DiscImageChef.Filesystems.CPM Dictionary> extents; if(fileExtents.TryGetValue(filename, out extents)) - { for(int ex = 0; ex < extents.Count; ex++) { List alBlks; if(extents.TryGetValue(ex, out alBlks)) - { foreach(ushort alBlk in alBlks) { byte[] blk = new byte[blockSize]; @@ -655,9 +634,7 @@ namespace DiscImageChef.Filesystems.CPM fileMs.Write(blk, 0, blk.Length); fInfo.Blocks++; } - } } - } // If you insist to call CP/M "extent based" fInfo.Attributes |= FileAttributes.Extents; @@ -673,7 +650,6 @@ namespace DiscImageChef.Filesystems.CPM decodedPasswordCache = new Dictionary(); // For each stored password, store a decoded version of it if(passwordCache.Count > 0) - { foreach(KeyValuePair kvp in passwordCache) { byte[] tmp = new byte[8]; @@ -682,7 +658,6 @@ namespace DiscImageChef.Filesystems.CPM decodedPasswordCache.Add(kvp.Key, tmp); } - } // Generate statfs. cpmStat.Blocks = dpb.dsm + 1; diff --git a/DiscImageChef.Filesystems/CPM/Xattr.cs b/DiscImageChef.Filesystems/CPM/Xattr.cs index 9ecd57c66..0d8f3dc60 100644 --- a/DiscImageChef.Filesystems/CPM/Xattr.cs +++ b/DiscImageChef.Filesystems/CPM/Xattr.cs @@ -53,15 +53,9 @@ namespace DiscImageChef.Filesystems.CPM if(!fileCache.ContainsKey(pathElements[0].ToUpperInvariant())) return Errno.NoSuchFile; - if(string.Compare(xattr, "com.caldera.cpm.password", StringComparison.InvariantCulture) == 0) - { - if(!passwordCache.TryGetValue(pathElements[0].ToUpperInvariant(), out buf)) return Errno.NoError; - } + if(string.Compare(xattr, "com.caldera.cpm.password", StringComparison.InvariantCulture) == 0) if(!passwordCache.TryGetValue(pathElements[0].ToUpperInvariant(), out buf)) return Errno.NoError; - if(string.Compare(xattr, "com.caldera.cpm.password.text", StringComparison.InvariantCulture) == 0) - { - if(!passwordCache.TryGetValue(pathElements[0].ToUpperInvariant(), out buf)) return Errno.NoError; - } + if(string.Compare(xattr, "com.caldera.cpm.password.text", StringComparison.InvariantCulture) == 0) if(!passwordCache.TryGetValue(pathElements[0].ToUpperInvariant(), out buf)) return Errno.NoError; return Errno.NoSuchExtendedAttribute; } diff --git a/DiscImageChef.Filesystems/FFS.cs b/DiscImageChef.Filesystems/FFS.cs index 02afe9d5b..d907d12b4 100644 --- a/DiscImageChef.Filesystems/FFS.cs +++ b/DiscImageChef.Filesystems/FFS.cs @@ -87,7 +87,6 @@ namespace DiscImageChef.Filesystems }; foreach(ulong loc in locations) - { if(partition.End > partition.Start + loc + sb_size_in_sectors) { ufs_sb_sectors = imagePlugin.ReadSectors(partition.Start + loc, sb_size_in_sectors); @@ -97,7 +96,6 @@ namespace DiscImageChef.Filesystems magic == UFS2_MAGIC || magic == UFS2_CIGAM || magic == UFS_BAD_MAGIC || magic == UFS_BAD_CIGAM) return true; } - } return false; } @@ -132,7 +130,6 @@ namespace DiscImageChef.Filesystems }; foreach(ulong loc in locations) - { if(partition.End > partition.Start + loc + sb_size_in_sectors) { ufs_sb_sectors = imagePlugin.ReadSectors(partition.Start + loc, sb_size_in_sectors); @@ -147,7 +144,6 @@ namespace DiscImageChef.Filesystems magic = 0; } - } if(magic == 0) { @@ -264,7 +260,7 @@ namespace DiscImageChef.Filesystems DicConsole.DebugWriteLine("FFS plugin", "fs_flags: 0x{0:X2}", ufs_sb.fs_flags); DicConsole.DebugWriteLine("FFS plugin", "fs_magic: 0x{0:X8}", ufs_sb.fs_magic); - if(ufs_sb.fs_magic == UFS2_MAGIC) { fs_type_ufs2 = true; } + if(ufs_sb.fs_magic == UFS2_MAGIC) fs_type_ufs2 = true; else { const uint @@ -372,12 +368,7 @@ namespace DiscImageChef.Filesystems .AppendLine(); sbInformation.AppendFormat("Hardware sector interleave: {0}", ufs_sb.fs_old_interleave).AppendLine(); sbInformation.AppendFormat("Sector 0 skew: {0}/track", ufs_sb.fs_old_trackskew).AppendLine(); - if(!fs_type_43bsd && ufs_sb.fs_id_1 > 0 && ufs_sb.fs_id_2 > 0) - { - sbInformation.AppendFormat("Volume ID: 0x{0:X8}{1:X8}", ufs_sb.fs_id_1, ufs_sb.fs_id_2).AppendLine(); - // TODO: Check this, it's getting the same on several volumes. - //xmlFSType.VolumeSerial = string.Format("{0:X8}{1:x8}", ufs_sb.fs_id_1, ufs_sb.fs_id_2); - } + if(!fs_type_43bsd && ufs_sb.fs_id_1 > 0 && ufs_sb.fs_id_2 > 0) sbInformation.AppendFormat("Volume ID: 0x{0:X8}{1:X8}", ufs_sb.fs_id_1, ufs_sb.fs_id_2).AppendLine(); else if(fs_type_43bsd && ufs_sb.fs_id_1 > 0 && ufs_sb.fs_id_2 > 0) { sbInformation.AppendFormat("{0} µsec for head switch", ufs_sb.fs_id_1).AppendLine(); @@ -446,11 +437,9 @@ namespace DiscImageChef.Filesystems sbInformation.AppendFormat("{0} inodes pending of being freed", ufs_sb.fs_pendinginodes).AppendLine(); } if(fs_type_sun) - { sbInformation.AppendFormat("Volume state on {0}", DateHandlers.UNIXToDateTime(ufs_sb.fs_old_npsect)) .AppendLine(); - } - else if(fs_type_sun86) { sbInformation.AppendFormat("{0} sectors/track", ufs_sb.fs_state).AppendLine(); } + else if(fs_type_sun86) sbInformation.AppendFormat("{0} sectors/track", ufs_sb.fs_state).AppendLine(); else if(fs_type_44bsd) { sbInformation.AppendFormat("{0} blocks on cluster summary array", ufs_sb.fs_contigsumsize).AppendLine(); diff --git a/DiscImageChef.Filesystems/HAMMER.cs b/DiscImageChef.Filesystems/HAMMER.cs index ee6562a62..170466426 100644 --- a/DiscImageChef.Filesystems/HAMMER.cs +++ b/DiscImageChef.Filesystems/HAMMER.cs @@ -114,7 +114,7 @@ namespace DiscImageChef.Filesystems typeof(HammerSuperBlock)); handle.Free(); } - else { hammer_sb = BigEndianMarshal.ByteArrayToStructureBigEndian(sb_sector); } + else hammer_sb = BigEndianMarshal.ByteArrayToStructureBigEndian(sb_sector); sb.AppendLine("HAMMER filesystem"); diff --git a/DiscImageChef.Filesystems/ISO9660/Info.cs b/DiscImageChef.Filesystems/ISO9660/Info.cs index 6d4f4e62c..71b314219 100644 --- a/DiscImageChef.Filesystems/ISO9660/Info.cs +++ b/DiscImageChef.Filesystems/ISO9660/Info.cs @@ -206,11 +206,9 @@ namespace DiscImageChef.Filesystems.ISO9660 // Check if this is Joliet if(svd.escape_sequences[0] == '%' && svd.escape_sequences[1] == '/') - { if(svd.escape_sequences[2] == '@' || svd.escape_sequences[2] == 'C' || - svd.escape_sequences[2] == 'E') { jolietvd = svd; } - else { break; } - } + svd.escape_sequences[2] == 'E') jolietvd = svd; + else break; else DicConsole.WriteLine("ISO9660 plugin", "Found unknown supplementary volume descriptor"); break; @@ -358,11 +356,8 @@ namespace DiscImageChef.Filesystems.ISO9660 nextSignature = BigEndianBitConverter.ToUInt16(sa, sa_off); if(nextSignature == AppleMagic) - { - // Can collide with AAIP if(sa[sa_off + 3] == 1 && sa[sa_off + 2] == 7) Apple = true; else Apple |= sa[sa_off + 3] != 1; - } if(nextSignature == SUSP_Continuation && sa_off + sa[sa_off + 2] <= sa_len) { @@ -424,11 +419,8 @@ namespace DiscImageChef.Filesystems.ISO9660 // Apple never said to include its extensions inside a continuation area, but just in case if(nextSignature == AppleMagic) - { - // Can collide with AAIP if(ca_data[ca_off + 3] == 1 && ca_data[ca_off + 2] == 7) Apple = true; else Apple |= ca_data[ca_off + 3] != 1; - } if(nextSignature == SUSP_Reference && ca_off + ca_data[ca_off + 2] <= ca.ca_length_be) { @@ -718,7 +710,6 @@ namespace DiscImageChef.Filesystems.ISO9660 if(flags.HasFlag(ElToritoFlags.SCSI)) ISOMetadata.AppendLine("\t\tImage contains SCSI drivers"); if(flags.HasFlag(ElToritoFlags.Continued)) - { while(true && torito_off < vd_sector.Length) { ElToritoSectionEntryExtension section_extension = new ElToritoSectionEntryExtension(); @@ -732,7 +723,6 @@ namespace DiscImageChef.Filesystems.ISO9660 if(!section_extension.extension_flags.HasFlag(ElToritoFlags.Continued)) break; } - } } if(section_header.header_id == ElToritoIndicator.LastHeader) break; diff --git a/DiscImageChef.Filesystems/ISO9660/Structs/CDi.cs b/DiscImageChef.Filesystems/ISO9660/Structs/CDi.cs index 5f41c2d60..3a0092dc7 100644 --- a/DiscImageChef.Filesystems/ISO9660/Structs/CDi.cs +++ b/DiscImageChef.Filesystems/ISO9660/Structs/CDi.cs @@ -130,24 +130,21 @@ namespace DiscImageChef.Filesystems.ISO9660 decodedVD.CreationTime = System.DateTime.MinValue; else decodedVD.CreationTime = DateHandlers.HighSierraToDateTime(pvd.creation_date); - if(pvd.modification_date[0] == '0' || pvd.modification_date[0] == 0x00) - { - decodedVD.HasModificationTime = false; - } + if(pvd.modification_date[0] == '0' || pvd.modification_date[0] == 0x00) decodedVD.HasModificationTime = false; else { decodedVD.HasModificationTime = true; decodedVD.ModificationTime = DateHandlers.HighSierraToDateTime(pvd.modification_date); } - if(pvd.expiration_date[0] == '0' || pvd.expiration_date[0] == 0x00) { decodedVD.HasExpirationTime = false; } + if(pvd.expiration_date[0] == '0' || pvd.expiration_date[0] == 0x00) decodedVD.HasExpirationTime = false; else { decodedVD.HasExpirationTime = true; decodedVD.ExpirationTime = DateHandlers.HighSierraToDateTime(pvd.expiration_date); } - if(pvd.effective_date[0] == '0' || pvd.effective_date[0] == 0x00) { decodedVD.HasEffectiveTime = false; } + if(pvd.effective_date[0] == '0' || pvd.effective_date[0] == 0x00) decodedVD.HasEffectiveTime = false; else { decodedVD.HasEffectiveTime = true; diff --git a/DiscImageChef.Filesystems/ISO9660/Structs/HighSierra.cs b/DiscImageChef.Filesystems/ISO9660/Structs/HighSierra.cs index 7502deee0..31535a7d1 100644 --- a/DiscImageChef.Filesystems/ISO9660/Structs/HighSierra.cs +++ b/DiscImageChef.Filesystems/ISO9660/Structs/HighSierra.cs @@ -122,24 +122,21 @@ namespace DiscImageChef.Filesystems.ISO9660 decodedVD.CreationTime = System.DateTime.MinValue; else decodedVD.CreationTime = DateHandlers.HighSierraToDateTime(pvd.creation_date); - if(pvd.modification_date[0] == '0' || pvd.modification_date[0] == 0x00) - { - decodedVD.HasModificationTime = false; - } + if(pvd.modification_date[0] == '0' || pvd.modification_date[0] == 0x00) decodedVD.HasModificationTime = false; else { decodedVD.HasModificationTime = true; decodedVD.ModificationTime = DateHandlers.HighSierraToDateTime(pvd.modification_date); } - if(pvd.expiration_date[0] == '0' || pvd.expiration_date[0] == 0x00) { decodedVD.HasExpirationTime = false; } + if(pvd.expiration_date[0] == '0' || pvd.expiration_date[0] == 0x00) decodedVD.HasExpirationTime = false; else { decodedVD.HasExpirationTime = true; decodedVD.ExpirationTime = DateHandlers.HighSierraToDateTime(pvd.expiration_date); } - if(pvd.effective_date[0] == '0' || pvd.effective_date[0] == 0x00) { decodedVD.HasEffectiveTime = false; } + if(pvd.effective_date[0] == '0' || pvd.effective_date[0] == 0x00) decodedVD.HasEffectiveTime = false; else { decodedVD.HasEffectiveTime = true; diff --git a/DiscImageChef.Filesystems/ISO9660/Structs/ISO.cs b/DiscImageChef.Filesystems/ISO9660/Structs/ISO.cs index 0c4696340..8a3b213d7 100644 --- a/DiscImageChef.Filesystems/ISO9660/Structs/ISO.cs +++ b/DiscImageChef.Filesystems/ISO9660/Structs/ISO.cs @@ -180,24 +180,21 @@ namespace DiscImageChef.Filesystems.ISO9660 decodedVD.CreationTime = System.DateTime.MinValue; else decodedVD.CreationTime = DateHandlers.ISO9660ToDateTime(pvd.creation_date); - if(pvd.modification_date[0] == '0' || pvd.modification_date[0] == 0x00) - { - decodedVD.HasModificationTime = false; - } + if(pvd.modification_date[0] == '0' || pvd.modification_date[0] == 0x00) decodedVD.HasModificationTime = false; else { decodedVD.HasModificationTime = true; decodedVD.ModificationTime = DateHandlers.ISO9660ToDateTime(pvd.modification_date); } - if(pvd.expiration_date[0] == '0' || pvd.expiration_date[0] == 0x00) { decodedVD.HasExpirationTime = false; } + if(pvd.expiration_date[0] == '0' || pvd.expiration_date[0] == 0x00) decodedVD.HasExpirationTime = false; else { decodedVD.HasExpirationTime = true; decodedVD.ExpirationTime = DateHandlers.ISO9660ToDateTime(pvd.expiration_date); } - if(pvd.effective_date[0] == '0' || pvd.effective_date[0] == 0x00) { decodedVD.HasEffectiveTime = false; } + if(pvd.effective_date[0] == '0' || pvd.effective_date[0] == 0x00) decodedVD.HasEffectiveTime = false; else { decodedVD.HasEffectiveTime = true; diff --git a/DiscImageChef.Filesystems/ISO9660/Structs/Joliet.cs b/DiscImageChef.Filesystems/ISO9660/Structs/Joliet.cs index 8eacb4afe..7efe9d1dd 100644 --- a/DiscImageChef.Filesystems/ISO9660/Structs/Joliet.cs +++ b/DiscImageChef.Filesystems/ISO9660/Structs/Joliet.cs @@ -56,30 +56,21 @@ namespace DiscImageChef.Filesystems.ISO9660 decodedVD.CreationTime = System.DateTime.MinValue; else decodedVD.CreationTime = DateHandlers.ISO9660ToDateTime(jolietvd.creation_date); - if(jolietvd.modification_date[0] < 0x31 || jolietvd.modification_date[0] > 0x39) - { - decodedVD.HasModificationTime = false; - } + if(jolietvd.modification_date[0] < 0x31 || jolietvd.modification_date[0] > 0x39) decodedVD.HasModificationTime = false; else { decodedVD.HasModificationTime = true; decodedVD.ModificationTime = DateHandlers.ISO9660ToDateTime(jolietvd.modification_date); } - if(jolietvd.expiration_date[0] < 0x31 || jolietvd.expiration_date[0] > 0x39) - { - decodedVD.HasExpirationTime = false; - } + if(jolietvd.expiration_date[0] < 0x31 || jolietvd.expiration_date[0] > 0x39) decodedVD.HasExpirationTime = false; else { decodedVD.HasExpirationTime = true; decodedVD.ExpirationTime = DateHandlers.ISO9660ToDateTime(jolietvd.expiration_date); } - if(jolietvd.effective_date[0] < 0x31 || jolietvd.effective_date[0] > 0x39) - { - decodedVD.HasEffectiveTime = false; - } + if(jolietvd.effective_date[0] < 0x31 || jolietvd.effective_date[0] > 0x39) decodedVD.HasEffectiveTime = false; else { decodedVD.HasEffectiveTime = true; diff --git a/DiscImageChef.Filesystems/LisaFS/File.cs b/DiscImageChef.Filesystems/LisaFS/File.cs index 459a31d2a..62b522a79 100644 --- a/DiscImageChef.Filesystems/LisaFS/File.cs +++ b/DiscImageChef.Filesystems/LisaFS/File.cs @@ -71,7 +71,6 @@ namespace DiscImageChef.Filesystems.LisaFS byte[] tmp; if(debug) - { switch(fileId) { case FILEID_BOOT_SIGNED: @@ -86,7 +85,6 @@ namespace DiscImageChef.Filesystems.LisaFS error = ReadFile(fileId, out tmp); break; } - } else error = ReadFile(fileId, out tmp); if(error != Errno.NoError) return error; @@ -170,17 +168,13 @@ namespace DiscImageChef.Filesystems.LisaFS buf = null; if(!mounted || !debug) return Errno.AccessDenied; - if(fileId > 4 || fileId <= 0) - { - if(fileId != FILEID_BOOT_SIGNED && fileId != FILEID_LOADER_SIGNED) return Errno.InvalidArgument; - } + if(fileId > 4 || fileId <= 0) if(fileId != FILEID_BOOT_SIGNED && fileId != FILEID_LOADER_SIGNED) return Errno.InvalidArgument; if(systemFileCache.TryGetValue(fileId, out buf) && !tags) return Errno.NoError; int count = 0; if(fileId == FILEID_SRECORD) - { if(!tags) { buf = device.ReadSectors(mddf.mddf_block + volumePrefix + mddf.srec_ptr, mddf.srec_len); @@ -193,7 +187,6 @@ namespace DiscImageChef.Filesystems.LisaFS SectorTagType.AppleSectorTag); return Errno.NoError; } - } LisaTag.PriamTag sysTag; @@ -244,7 +237,6 @@ namespace DiscImageChef.Filesystems.LisaFS ExtentFile file; if(fileId <= 4) - { if(!debug || fileId == 0) return Errno.NoSuchFile; else { @@ -298,23 +290,14 @@ namespace DiscImageChef.Filesystems.LisaFS return Errno.NoError; } - } stat = new FileEntryInfo(); stat.Attributes = new FileAttributes(); error = GetAttributes(fileId, ref stat.Attributes); - if(error != Errno.NoError) - { - //DicConsole.ErrorWriteLine("Error {0} reading attributes for file {1}", error, fileId); - return error; - } + if(error != Errno.NoError) return error; error = ReadExtentsFile(fileId, out file); - if(error != Errno.NoError) - { - //DicConsole.ErrorWriteLine("Error {0} reading extents for file {1}", error, fileId); - return error; - } + if(error != Errno.NoError) return error; stat.CreationTime = DateHandlers.LisaToDateTime(file.dtc); stat.AccessTime = DateHandlers.LisaToDateTime(file.dta); @@ -384,10 +367,7 @@ namespace DiscImageChef.Filesystems.LisaFS if(!tags) { int realSize; - if(fileSizeCache.TryGetValue(fileId, out realSize)) - { - if(realSize > temp.Length) DicConsole.ErrorWriteLine("File {0} gets truncated.", fileId); - } + if(fileSizeCache.TryGetValue(fileId, out realSize)) if(realSize > temp.Length) DicConsole.ErrorWriteLine("File {0} gets truncated.", fileId); buf = temp; fileCache.Add(fileId, buf); diff --git a/DiscImageChef.Filesystems/LisaFS/Super.cs b/DiscImageChef.Filesystems/LisaFS/Super.cs index c5b97ff12..26e70524d 100644 --- a/DiscImageChef.Filesystems/LisaFS/Super.cs +++ b/DiscImageChef.Filesystems/LisaFS/Super.cs @@ -218,7 +218,7 @@ namespace DiscImageChef.Filesystems.LisaFS mounted = true; this.debug = debug; - if(debug) { printedExtents = new List(); } + if(debug) printedExtents = new List(); // Read the S-Records file error = ReadSRecords(); diff --git a/DiscImageChef.Filters/Filters.cs b/DiscImageChef.Filters/Filters.cs index 95391ca12..7b3b3d34f 100644 --- a/DiscImageChef.Filters/Filters.cs +++ b/DiscImageChef.Filters/Filters.cs @@ -47,20 +47,15 @@ namespace DiscImageChef.Filters filtersList = new SortedDictionary(); foreach(Type type in assembly.GetTypes()) - { try { if(type.IsSubclassOf(typeof(Filter))) { Filter filter = (Filter)type.GetConstructor(Type.EmptyTypes).Invoke(new object[] { }); - if(!filtersList.ContainsKey(filter.Name.ToLower())) - { - filtersList.Add(filter.Name.ToLower(), filter); - } + if(!filtersList.ContainsKey(filter.Name.ToLower())) filtersList.Add(filter.Name.ToLower(), filter); } } catch(Exception exception) { DicConsole.ErrorWriteLine("Exception {0}", exception); } - } } public Filter GetFilter(string path) @@ -68,7 +63,6 @@ namespace DiscImageChef.Filters Filter noFilter = null; foreach(Filter filter in filtersList.Values) - { if(filter.UUID != new Guid("12345678-AAAA-BBBB-CCCC-123456789000")) { if(filter.Identify(path)) @@ -81,7 +75,6 @@ namespace DiscImageChef.Filters } } else noFilter = filter; - } if(noFilter.Identify(path)) { diff --git a/DiscImageChef.Helpers/ArrayFill.cs b/DiscImageChef.Helpers/ArrayFill.cs index 733a35136..e443f7bf9 100644 --- a/DiscImageChef.Helpers/ArrayFill.cs +++ b/DiscImageChef.Helpers/ArrayFill.cs @@ -39,12 +39,9 @@ namespace DiscImageChef public static void ArrayFill(T[] destinationArray, T[] value) { - if(destinationArray == null) { throw new ArgumentNullException(nameof(destinationArray)); } + if(destinationArray == null) throw new ArgumentNullException(nameof(destinationArray)); - if(value.Length > destinationArray.Length) - { - throw new ArgumentException("Length of value array must not be more than length of destination"); - } + if(value.Length > destinationArray.Length) throw new ArgumentException("Length of value array must not be more than length of destination"); // set the initial array value Array.Copy(value, destinationArray, value.Length); @@ -52,10 +49,7 @@ namespace DiscImageChef int arrayToFillHalfLength = destinationArray.Length / 2; int copyLength; - for(copyLength = value.Length; copyLength < arrayToFillHalfLength; copyLength <<= 1) - { - Array.Copy(destinationArray, 0, destinationArray, copyLength, copyLength); - } + for(copyLength = value.Length; copyLength < arrayToFillHalfLength; copyLength <<= 1) Array.Copy(destinationArray, 0, destinationArray, copyLength, copyLength); Array.Copy(destinationArray, 0, destinationArray, copyLength, destinationArray.Length - copyLength); } diff --git a/DiscImageChef.Helpers/DateHandlers.cs b/DiscImageChef.Helpers/DateHandlers.cs index a13c5ffd1..9d394fb0c 100644 --- a/DiscImageChef.Helpers/DateHandlers.cs +++ b/DiscImageChef.Helpers/DateHandlers.cs @@ -233,7 +233,7 @@ namespace DiscImageChef ushort preOffset = (ushort)(typeAndTimeZone & 0xFFF); short offset; - if((preOffset & 0x800) == 0x800) { offset = (short)(preOffset | 0xF000); } + if((preOffset & 0x800) == 0x800) offset = (short)(preOffset | 0xF000); else offset = (short)(preOffset & 0x7FF); if(offset == -2047) diff --git a/DiscImageChef.Helpers/EndianAwareBinaryReader.cs b/DiscImageChef.Helpers/EndianAwareBinaryReader.cs index b0d6366ff..496f667a6 100644 --- a/DiscImageChef.Helpers/EndianAwareBinaryReader.cs +++ b/DiscImageChef.Helpers/EndianAwareBinaryReader.cs @@ -122,21 +122,19 @@ namespace DiscImageChef if(numBytes == 1) { num2 = BaseStream.ReadByte(); - if(num2 == -1) { throw new EndOfStreamException("Attempted to read past the end of the stream."); } + if(num2 == -1) throw new EndOfStreamException("Attempted to read past the end of the stream."); buffer[0] = (byte)num2; } else - { do { num2 = BaseStream.Read(buffer, offset, numBytes - offset); - if(num2 == 0) { throw new EndOfStreamException("Attempted to read past the end of the stream."); } + if(num2 == 0) throw new EndOfStreamException("Attempted to read past the end of the stream."); offset += num2; } while(offset < numBytes); - } } } } \ No newline at end of file diff --git a/DiscImageChef.Interop/DetectOS.cs b/DiscImageChef.Interop/DetectOS.cs index d8137a4cb..0c4a5d712 100644 --- a/DiscImageChef.Interop/DetectOS.cs +++ b/DiscImageChef.Interop/DetectOS.cs @@ -81,10 +81,7 @@ namespace DiscImageChef.Interop public static PlatformID GetRealPlatformID() { - if((int)Environment.OSVersion.Platform < 4 || (int)Environment.OSVersion.Platform == 5) - { - return (PlatformID)(int)Environment.OSVersion.Platform; - } + if((int)Environment.OSVersion.Platform < 4 || (int)Environment.OSVersion.Platform == 5) return (PlatformID)(int)Environment.OSVersion.Platform; utsname unixname; int error = uname(out unixname); diff --git a/DiscImageChef.Server/App_Start/Ata.cs b/DiscImageChef.Server/App_Start/Ata.cs index fcbe4ba8c..fbc7af16f 100644 --- a/DiscImageChef.Server/App_Start/Ata.cs +++ b/DiscImageChef.Server/App_Start/Ata.cs @@ -467,10 +467,8 @@ namespace DiscImageChef.Server.App_Start else if(!cfa && ataReport.GeneralConfigurationSpecified) { if(minatalevel >= 5) - { if(ataReport.GeneralConfiguration.HasFlag(GeneralConfigurationBit.IncompleteResponse)) ataOneValue.Add("Incomplete identify response"); - } if(ataReport.GeneralConfiguration.HasFlag(GeneralConfigurationBit.NonMagnetic)) ataOneValue.Add("Device uses non-magnetic media"); @@ -478,10 +476,8 @@ namespace DiscImageChef.Server.App_Start ataOneValue.Add("Device is removable"); if(minatalevel <= 5) - { if(ataReport.GeneralConfiguration.HasFlag(GeneralConfigurationBit.Fixed)) ataOneValue.Add("Device is fixed"); - } if(ata1) { @@ -514,7 +510,6 @@ namespace DiscImageChef.Server.App_Start if(ataReport.SpecificConfigurationSpecified && (ushort)ataReport.SpecificConfiguration != 0x0000 && (ushort)ataReport.SpecificConfiguration != 0xFFFF) - { switch(ataReport.SpecificConfiguration) { case SpecificConfigurationEnum.RequiresSetIncompleteResponse: @@ -538,12 +533,10 @@ namespace DiscImageChef.Server.App_Start (ushort)ataReport.SpecificConfiguration)); break; } - } // Obsolete since ATA-2, however, it is yet used in ATA-8 devices if(ataReport.BufferSizeSpecified && ataReport.BufferTypeSpecified && ataReport.BufferSize != 0x0000 && ataReport.BufferSize != 0xFFFF && ataReport.BufferType != 0x0000 && ataReport.BufferType != 0xFFFF) - { switch(ataReport.BufferType) { case 1: @@ -564,7 +557,6 @@ namespace DiscImageChef.Server.App_Start ataReport.BufferType)); break; } - } if(ataReport.CapabilitiesSpecified) { @@ -572,18 +564,14 @@ namespace DiscImageChef.Server.App_Start if(ataReport.Capabilities.HasFlag(CapabilitiesBit.StandardStanbyTimer)) ataOneValue.Add("Standby time values are standard"); if(ataReport.Capabilities.HasFlag(CapabilitiesBit.IORDY)) - { if(ataReport.Capabilities.HasFlag(CapabilitiesBit.CanDisableIORDY)) ataOneValue.Add("IORDY is supported and can be disabled"); else ataOneValue.Add("IORDY is supported"); - } if(ataReport.Capabilities.HasFlag(CapabilitiesBit.DMASupport)) ataOneValue.Add("DMA is supported"); if(ataReport.Capabilities.HasFlag(CapabilitiesBit.PhysicalAlignment1) || ataReport.Capabilities.HasFlag(CapabilitiesBit.PhysicalAlignment0)) - { ataOneValue.Add(string.Format("Long Physical Alignment setting is {0}", (ushort)ataReport.Capabilities & 0x03)); - } if(atapi) { if(ataReport.Capabilities.HasFlag(CapabilitiesBit.InterleavedDMA)) @@ -598,17 +586,12 @@ namespace DiscImageChef.Server.App_Start } if(ataReport.Capabilities2Specified) - { if(ataReport.Capabilities2.HasFlag(CapabilitiesBit2.MustBeSet) && !ataReport.Capabilities2.HasFlag(CapabilitiesBit2.MustBeClear)) - { if(ataReport.Capabilities2.HasFlag(CapabilitiesBit2.SpecificStandbyTimer)) ataOneValue.Add("Device indicates a specific minimum standby timer value"); - } - } if(ataReport.Capabilities3Specified) - { if(ataReport.Capabilities3.HasFlag(CapabilitiesBit3.MultipleValid)) { ataOneValue @@ -617,13 +600,10 @@ namespace DiscImageChef.Server.App_Start ataOneValue.Add(string.Format("Device supports setting a maximum of {0} sectors", ataReport.MultipleMaxSectors)); } - } if(ata1 && ataReport.TrustedComputingSpecified) - { if(ataReport.TrustedComputing.HasFlag(TrustedComputingBit.TrustedComputing)) ataOneValue.Add("Device supports doubleword I/O"); - } if(minatalevel <= 3) { @@ -637,14 +617,14 @@ namespace DiscImageChef.Server.App_Start { tmpString = ""; - if(ataReport.APIOSupported.HasFlag(TransferMode.Mode0)) { tmpString += "PIO0 "; } - if(ataReport.APIOSupported.HasFlag(TransferMode.Mode1)) { tmpString += "PIO1 "; } - if(ataReport.APIOSupported.HasFlag(TransferMode.Mode2)) { tmpString += "PIO2 "; } - if(ataReport.APIOSupported.HasFlag(TransferMode.Mode3)) { tmpString += "PIO3 "; } - if(ataReport.APIOSupported.HasFlag(TransferMode.Mode4)) { tmpString += "PIO4 "; } - if(ataReport.APIOSupported.HasFlag(TransferMode.Mode5)) { tmpString += "PIO5 "; } - if(ataReport.APIOSupported.HasFlag(TransferMode.Mode6)) { tmpString += "PIO6 "; } - if(ataReport.APIOSupported.HasFlag(TransferMode.Mode7)) { tmpString += "PIO7 "; } + if(ataReport.APIOSupported.HasFlag(TransferMode.Mode0)) tmpString += "PIO0 "; + if(ataReport.APIOSupported.HasFlag(TransferMode.Mode1)) tmpString += "PIO1 "; + if(ataReport.APIOSupported.HasFlag(TransferMode.Mode2)) tmpString += "PIO2 "; + if(ataReport.APIOSupported.HasFlag(TransferMode.Mode3)) tmpString += "PIO3 "; + if(ataReport.APIOSupported.HasFlag(TransferMode.Mode4)) tmpString += "PIO4 "; + if(ataReport.APIOSupported.HasFlag(TransferMode.Mode5)) tmpString += "PIO5 "; + if(ataReport.APIOSupported.HasFlag(TransferMode.Mode6)) tmpString += "PIO6 "; + if(ataReport.APIOSupported.HasFlag(TransferMode.Mode7)) tmpString += "PIO7 "; ataTwoValue.Add("Advanced PIO", tmpString); } @@ -812,25 +792,16 @@ namespace DiscImageChef.Server.App_Start } if(ataReport.MinMDMACycleTime != 0 && ataReport.RecommendedMDMACycleTime != 0) - { ataOneValue.Add(string.Format("At minimum {0} ns. transfer cycle time per word in MDMA, " + "{1} ns. recommended", ataReport.MinMDMACycleTime, ataReport.RecommendedMDMACycleTime)); - } if(ataReport.MinPIOCycleTimeNoFlow != 0) - { ataOneValue.Add(string.Format("At minimum {0} ns. transfer cycle time per word in PIO, " + "without flow control", ataReport.MinPIOCycleTimeNoFlow)); - } if(ataReport.MinPIOCycleTimeFlow != 0) - { ataOneValue.Add(string.Format("At minimum {0} ns. transfer cycle time per word in PIO, " + "with IORDY flow control", ataReport.MinPIOCycleTimeFlow)); - } - if(ataReport.MaxQueueDepth != 0) - { - ataOneValue.Add(string.Format("{0} depth of queue maximum", ataReport.MaxQueueDepth + 1)); - } + if(ataReport.MaxQueueDepth != 0) ataOneValue.Add(string.Format("{0} depth of queue maximum", ataReport.MaxQueueDepth + 1)); if(atapi) { @@ -847,49 +818,25 @@ namespace DiscImageChef.Server.App_Start { if(!ataReport.SATACapabilities.HasFlag(SATACapabilitiesBit.Clear)) { - if(ataReport.SATACapabilities.HasFlag(SATACapabilitiesBit.Gen1Speed)) - { - ataOneValue.Add(string.Format("SATA 1.5Gb/s is supported")); - } - if(ataReport.SATACapabilities.HasFlag(SATACapabilitiesBit.Gen2Speed)) - { - ataOneValue.Add(string.Format("SATA 3.0Gb/s is supported")); - } - if(ataReport.SATACapabilities.HasFlag(SATACapabilitiesBit.Gen3Speed)) - { - ataOneValue.Add(string.Format("SATA 6.0Gb/s is supported")); - } + if(ataReport.SATACapabilities.HasFlag(SATACapabilitiesBit.Gen1Speed)) ataOneValue.Add(string.Format("SATA 1.5Gb/s is supported")); + if(ataReport.SATACapabilities.HasFlag(SATACapabilitiesBit.Gen2Speed)) ataOneValue.Add(string.Format("SATA 3.0Gb/s is supported")); + if(ataReport.SATACapabilities.HasFlag(SATACapabilitiesBit.Gen3Speed)) ataOneValue.Add(string.Format("SATA 6.0Gb/s is supported")); if(ataReport.SATACapabilities.HasFlag(SATACapabilitiesBit.PowerReceipt)) - { ataOneValue .Add(string.Format("Receipt of host initiated power management requests is supported")); - } - if(ataReport.SATACapabilities.HasFlag(SATACapabilitiesBit.PHYEventCounter)) - { - ataOneValue.Add(string.Format("PHY Event counters are supported")); - } + if(ataReport.SATACapabilities.HasFlag(SATACapabilitiesBit.PHYEventCounter)) ataOneValue.Add(string.Format("PHY Event counters are supported")); if(ataReport.SATACapabilities.HasFlag(SATACapabilitiesBit.HostSlumbTrans)) - { ataOneValue .Add(string.Format("Supports host automatic partial to slumber transitions is supported")); - } if(ataReport.SATACapabilities.HasFlag(SATACapabilitiesBit.DevSlumbTrans)) - { ataOneValue .Add(string.Format("Supports device automatic partial to slumber transitions is supported")); - } if(ataReport.SATACapabilities.HasFlag(SATACapabilitiesBit.NCQ)) { ataOneValue.Add(string.Format("NCQ is supported")); - if(ataReport.SATACapabilities.HasFlag(SATACapabilitiesBit.NCQPriority)) - { - ataOneValue.Add(string.Format("NCQ priority is supported")); - } - if(ataReport.SATACapabilities.HasFlag(SATACapabilitiesBit.UnloadNCQ)) - { - ataOneValue.Add(string.Format("Unload is supported with outstanding NCQ commands")); - } + if(ataReport.SATACapabilities.HasFlag(SATACapabilitiesBit.NCQPriority)) ataOneValue.Add(string.Format("NCQ priority is supported")); + if(ataReport.SATACapabilities.HasFlag(SATACapabilitiesBit.UnloadNCQ)) ataOneValue.Add(string.Format("Unload is supported with outstanding NCQ commands")); } } @@ -900,39 +847,25 @@ namespace DiscImageChef.Server.App_Start !ataReport.SATACapabilities.HasFlag(SATACapabilitiesBit.Clear) && ataReport.SATACapabilities.HasFlag(SATACapabilitiesBit.NCQ)) { - if(ataReport.SATACapabilities2.HasFlag(SATACapabilitiesBit2.NCQMgmt)) - { - ataOneValue.Add(string.Format("NCQ queue management is supported")); - } - if(ataReport.SATACapabilities2.HasFlag(SATACapabilitiesBit2.NCQStream)) - { - ataOneValue.Add(string.Format("NCQ streaming is supported")); - } + if(ataReport.SATACapabilities2.HasFlag(SATACapabilitiesBit2.NCQMgmt)) ataOneValue.Add(string.Format("NCQ queue management is supported")); + if(ataReport.SATACapabilities2.HasFlag(SATACapabilitiesBit2.NCQStream)) ataOneValue.Add(string.Format("NCQ streaming is supported")); } if(ataReport.SATACapabilities2Specified && atapi) { - if(ataReport.SATACapabilities2.HasFlag(SATACapabilitiesBit2.HostEnvDetect)) - { - ataOneValue.Add(string.Format("ATAPI device supports host environment detection")); - } + if(ataReport.SATACapabilities2.HasFlag(SATACapabilitiesBit2.HostEnvDetect)) ataOneValue.Add(string.Format("ATAPI device supports host environment detection")); if(ataReport.SATACapabilities2.HasFlag(SATACapabilitiesBit2.DevAttSlimline)) - { ataOneValue .Add(string.Format("ATAPI device supports attention on slimline connected devices")); - } } } } if(ataReport.InterseekDelay != 0x0000 && ataReport.InterseekDelay != 0xFFFF) - { ataOneValue.Add(string.Format("{0} microseconds of interseek delay for ISO-7779 accoustic testing", ataReport.InterseekDelay)); - } if((ushort)ataReport.DeviceFormFactor != 0x0000 && (ushort)ataReport.DeviceFormFactor != 0xFFFF) - { switch(ataReport.DeviceFormFactor) { case DeviceFormFactorEnum.FiveAndQuarter: @@ -955,16 +888,12 @@ namespace DiscImageChef.Server.App_Start ataReport.DeviceFormFactor)); break; } - } if(atapi) - { if(ataReport.ATAPIByteCount > 0) ataOneValue.Add(string.Format("{0} bytes count limit for ATAPI", ataReport.ATAPIByteCount)); - } if(cfa) - { if((ataReport.CFAPowerMode & 0x8000) == 0x8000) { ataOneValue.Add("CompactFlash device supports power mode 1"); @@ -976,7 +905,6 @@ namespace DiscImageChef.Server.App_Start ataOneValue.Add(string.Format("CompactFlash device uses a maximum of {0} mA", ataReport.CFAPowerMode & 0x0FFF)); } - } if(ataReport.CommandSetSpecified || ataReport.CommandSet2Specified || ataReport.CommandSet3Specified || ataReport.CommandSet4Specified || @@ -984,87 +912,61 @@ namespace DiscImageChef.Server.App_Start if(ataReport.CommandSetSpecified) { if(ataReport.CommandSet.HasFlag(CommandSetBit.Nop)) - { if(ataReport.EnabledCommandSet.HasFlag(CommandSetBit.Nop) && ataReport.EnabledCommandSetSpecified) ataOneValue.Add("NOP is supported and enabled"); else ataOneValue.Add("NOP is supported"); - } if(ataReport.CommandSet.HasFlag(CommandSetBit.ReadBuffer)) - { if(ataReport.EnabledCommandSet.HasFlag(CommandSetBit.ReadBuffer) && ataReport.EnabledCommandSetSpecified) ataOneValue.Add("READ BUFFER is supported and enabled"); else ataOneValue.Add("READ BUFFER is supported"); - } if(ataReport.CommandSet.HasFlag(CommandSetBit.WriteBuffer)) - { if(ataReport.EnabledCommandSet.HasFlag(CommandSetBit.WriteBuffer) && ataReport.EnabledCommandSetSpecified) ataOneValue.Add("WRITE BUFFER is supported and enabled"); else ataOneValue.Add("WRITE BUFFER is supported"); - } if(ataReport.CommandSet.HasFlag(CommandSetBit.HPA)) - { if(ataReport.EnabledCommandSet.HasFlag(CommandSetBit.HPA) && ataReport.EnabledCommandSetSpecified) ataOneValue.Add("Host Protected Area is supported and enabled"); else ataOneValue.Add("Host Protected Area is supported"); - } if(ataReport.CommandSet.HasFlag(CommandSetBit.DeviceReset)) - { if(ataReport.EnabledCommandSet.HasFlag(CommandSetBit.DeviceReset) && ataReport.EnabledCommandSetSpecified) ataOneValue.Add("DEVICE RESET is supported and enabled"); else ataOneValue.Add("DEVICE RESET is supported"); - } if(ataReport.CommandSet.HasFlag(CommandSetBit.Service)) - { if(ataReport.EnabledCommandSet.HasFlag(CommandSetBit.Service) && ataReport.EnabledCommandSetSpecified) ataOneValue.Add("SERVICE interrupt is supported and enabled"); else ataOneValue.Add("SERVICE interrupt is supported"); - } if(ataReport.CommandSet.HasFlag(CommandSetBit.Release)) - { if(ataReport.EnabledCommandSet.HasFlag(CommandSetBit.Release) && ataReport.EnabledCommandSetSpecified) ataOneValue.Add("Release is supported and enabled"); else ataOneValue.Add("Release is supported"); - } if(ataReport.CommandSet.HasFlag(CommandSetBit.LookAhead)) - { if(ataReport.EnabledCommandSet.HasFlag(CommandSetBit.LookAhead) && ataReport.EnabledCommandSetSpecified) ataOneValue.Add("Look-ahead read is supported and enabled"); else ataOneValue.Add("Look-ahead read is supported"); - } if(ataReport.CommandSet.HasFlag(CommandSetBit.WriteCache)) - { if(ataReport.EnabledCommandSet.HasFlag(CommandSetBit.WriteCache) && ataReport.EnabledCommandSetSpecified) ataOneValue.Add("Write cache is supported and enabled"); else ataOneValue.Add("Write cache is supported"); - } if(ataReport.CommandSet.HasFlag(CommandSetBit.Packet)) - { if(ataReport.EnabledCommandSet.HasFlag(CommandSetBit.Packet) && ataReport.EnabledCommandSetSpecified ) ataOneValue.Add("PACKET is supported and enabled"); else ataOneValue.Add("PACKET is supported"); - } if(ataReport.CommandSet.HasFlag(CommandSetBit.PowerManagement)) - { if(ataReport.EnabledCommandSet.HasFlag(CommandSetBit.PowerManagement) && ataReport.EnabledCommandSetSpecified) ataOneValue.Add("Power management is supported and enabled"); else ataOneValue.Add("Power management is supported"); - } if(ataReport.CommandSet.HasFlag(CommandSetBit.RemovableMedia)) - { if(ataReport.EnabledCommandSet.HasFlag(CommandSetBit.RemovableMedia) && ataReport.EnabledCommandSetSpecified) ataOneValue.Add("Removable media feature set is supported and enabled"); else ataOneValue.Add("Removable media feature set is supported"); - } if(ataReport.CommandSet.HasFlag(CommandSetBit.SecurityMode)) - { if(ataReport.EnabledCommandSet.HasFlag(CommandSetBit.SecurityMode) && ataReport.EnabledCommandSetSpecified) ataOneValue.Add("Security mode is supported and enabled"); else ataOneValue.Add("Security mode is supported"); - } if(ataReport.Capabilities.HasFlag(CapabilitiesBit.LBASupport)) ataOneValue.Add("28-bit LBA is supported"); } @@ -1073,111 +975,78 @@ namespace DiscImageChef.Server.App_Start !ataReport.CommandSet2.HasFlag(CommandSetBit2.MustBeClear)) { if(ataReport.CommandSet2.HasFlag(CommandSetBit2.LBA48)) - { if(ataReport.EnabledCommandSet2.HasFlag(CommandSetBit2.LBA48) && ataReport.EnabledCommandSet2Specified) ataOneValue.Add("48-bit LBA is supported and enabled"); else ataOneValue.Add("48-bit LBA is supported"); - } if(ataReport.CommandSet2.HasFlag(CommandSetBit2.FlushCache)) - { if(ataReport.EnabledCommandSet2.HasFlag(CommandSetBit2.FlushCache) && ataReport.EnabledCommandSet2Specified) ataOneValue.Add("FLUSH CACHE is supported and enabled"); else ataOneValue.Add("FLUSH CACHE is supported"); - } if(ataReport.CommandSet2.HasFlag(CommandSetBit2.FlushCacheExt)) - { if(ataReport.EnabledCommandSet2.HasFlag(CommandSetBit2.FlushCacheExt) && ataReport.EnabledCommandSet2Specified) ataOneValue.Add("FLUSH CACHE EXT is supported and enabled"); else ataOneValue.Add("FLUSH CACHE EXT is supported"); - } if(ataReport.CommandSet2.HasFlag(CommandSetBit2.DCO)) - { if(ataReport.EnabledCommandSet2.HasFlag(CommandSetBit2.DCO) && ataReport.EnabledCommandSet2Specified ) ataOneValue.Add("Device Configuration Overlay feature set is supported and enabled"); else ataOneValue.Add("Device Configuration Overlay feature set is supported"); - } if(ataReport.CommandSet2.HasFlag(CommandSetBit2.AAM)) - { if(ataReport.EnabledCommandSet2.HasFlag(CommandSetBit2.AAM) && ataReport.EnabledCommandSet2Specified ) - { ataOneValue .Add(string.Format("Automatic Acoustic Management is supported and enabled with value {0} (vendor recommends {1}", ataReport.CurrentAAM, ataReport.RecommendedAAM)); - } else ataOneValue.Add("Automatic Acoustic Management is supported"); - } if(ataReport.CommandSet2.HasFlag(CommandSetBit2.SetMax)) - { if(ataReport.EnabledCommandSet2.HasFlag(CommandSetBit2.SetMax) && ataReport.EnabledCommandSet2Specified) ataOneValue.Add("SET MAX security extension is supported and enabled"); else ataOneValue.Add("SET MAX security extension is supported"); - } if(ataReport.CommandSet2.HasFlag(CommandSetBit2.AddressOffsetReservedAreaBoot)) - { if(ataReport.EnabledCommandSet2.HasFlag(CommandSetBit2.AddressOffsetReservedAreaBoot) && ataReport.EnabledCommandSet2Specified) ataOneValue.Add("Address Offset Reserved Area Boot is supported and enabled"); else ataOneValue.Add("Address Offset Reserved Area Boot is supported"); - } - if(ataReport.CommandSet2.HasFlag(CommandSetBit2.SetFeaturesRequired)) - { - ataOneValue.Add("SET FEATURES is required before spin-up"); - } + if(ataReport.CommandSet2.HasFlag(CommandSetBit2.SetFeaturesRequired)) ataOneValue.Add("SET FEATURES is required before spin-up"); if(ataReport.CommandSet2.HasFlag(CommandSetBit2.PowerUpInStandby)) - { if(ataReport.EnabledCommandSet2.HasFlag(CommandSetBit2.PowerUpInStandby) && ataReport.EnabledCommandSet2Specified) ataOneValue.Add("Power-up in standby is supported and enabled"); else ataOneValue.Add("Power-up in standby is supported"); - } if(ataReport.CommandSet2.HasFlag(CommandSetBit2.RemovableNotification)) - { if(ataReport.EnabledCommandSet2.HasFlag(CommandSetBit2.RemovableNotification) && ataReport.EnabledCommandSet2Specified) ataOneValue.Add("Removable Media Status Notification is supported and enabled"); else ataOneValue.Add("Removable Media Status Notification is supported"); - } if(ataReport.CommandSet2.HasFlag(CommandSetBit2.APM)) - { if(ataReport.EnabledCommandSet2.HasFlag(CommandSetBit2.APM) && ataReport.EnabledCommandSet2Specified ) ataOneValue .Add(string.Format("Advanced Power Management is supported and enabled with value {0}", ataReport.CurrentAPM)); else ataOneValue.Add("Advanced Power Management is supported"); - } if(ataReport.CommandSet2.HasFlag(CommandSetBit2.CompactFlash)) - { if(ataReport.EnabledCommandSet2.HasFlag(CommandSetBit2.CompactFlash) && ataReport.EnabledCommandSet2Specified) ataOneValue.Add("CompactFlash feature set is supported and enabled"); else ataOneValue.Add("CompactFlash feature set is supported"); - } if(ataReport.CommandSet2.HasFlag(CommandSetBit2.RWQueuedDMA)) - { if(ataReport.EnabledCommandSet2.HasFlag(CommandSetBit2.RWQueuedDMA) && ataReport.EnabledCommandSet2Specified) ataOneValue.Add("READ DMA QUEUED and WRITE DMA QUEUED are supported and enabled"); else ataOneValue.Add("READ DMA QUEUED and WRITE DMA QUEUED are supported"); - } if(ataReport.CommandSet2.HasFlag(CommandSetBit2.DownloadMicrocode)) - { if(ataReport.EnabledCommandSet2.HasFlag(CommandSetBit2.DownloadMicrocode) && ataReport.EnabledCommandSet2Specified) ataOneValue.Add("DOWNLOAD MICROCODE is supported and enabled"); else ataOneValue.Add("DOWNLOAD MICROCODE is supported"); - } } if(ataReport.CommandSet.HasFlag(CommandSetBit.SMART) && ataReport.CommandSetSpecified) - { if(ataReport.EnabledCommandSet.HasFlag(CommandSetBit.SMART) && ataReport.EnabledCommandSetSpecified) ataOneValue.Add("S.M.A.R.T. is supported and enabled"); else ataOneValue.Add("S.M.A.R.T. is supported"); - } if(ataReport.SCTCommandTransport.HasFlag(SCTCommandTransportBit.Supported) && ataReport.SCTCommandTransportSpecified) ataOneValue.Add("S.M.A.R.T. Command Transport is supported"); @@ -1186,137 +1055,94 @@ namespace DiscImageChef.Server.App_Start !ataReport.CommandSet3.HasFlag(CommandSetBit3.MustBeClear)) { if(ataReport.CommandSet3.HasFlag(CommandSetBit3.SMARTSelfTest)) - { if(ataReport.EnabledCommandSet3.HasFlag(CommandSetBit3.SMARTSelfTest) && ataReport.EnabledCommandSet3Specified) ataOneValue.Add("S.M.A.R.T. self-testing is supported and enabled"); else ataOneValue.Add("S.M.A.R.T. self-testing is supported"); - } if(ataReport.CommandSet3.HasFlag(CommandSetBit3.SMARTLog)) - { if(ataReport.EnabledCommandSet3.HasFlag(CommandSetBit3.SMARTLog) && ataReport.EnabledCommandSet3Specified) ataOneValue.Add("S.M.A.R.T. error logging is supported and enabled"); else ataOneValue.Add("S.M.A.R.T. error logging is supported"); - } if(ataReport.CommandSet3.HasFlag(CommandSetBit3.IdleImmediate)) - { if(ataReport.EnabledCommandSet3.HasFlag(CommandSetBit3.IdleImmediate) && ataReport.EnabledCommandSet3Specified) ataOneValue.Add("IDLE IMMEDIATE with UNLOAD FEATURE is supported and enabled"); else ataOneValue.Add("IDLE IMMEDIATE with UNLOAD FEATURE is supported"); - } - if(ataReport.CommandSet3.HasFlag(CommandSetBit3.WriteURG)) - { - ataOneValue.Add("URG bit is supported in WRITE STREAM DMA EXT and WRITE STREAM EXT"); - } - if(ataReport.CommandSet3.HasFlag(CommandSetBit3.ReadURG)) - { - ataOneValue.Add("URG bit is supported in READ STREAM DMA EXT and READ STREAM EXT"); - } - if(ataReport.CommandSet3.HasFlag(CommandSetBit3.WWN)) - { - ataOneValue.Add("Device has a World Wide Name"); - } + if(ataReport.CommandSet3.HasFlag(CommandSetBit3.WriteURG)) ataOneValue.Add("URG bit is supported in WRITE STREAM DMA EXT and WRITE STREAM EXT"); + if(ataReport.CommandSet3.HasFlag(CommandSetBit3.ReadURG)) ataOneValue.Add("URG bit is supported in READ STREAM DMA EXT and READ STREAM EXT"); + if(ataReport.CommandSet3.HasFlag(CommandSetBit3.WWN)) ataOneValue.Add("Device has a World Wide Name"); if(ataReport.CommandSet3.HasFlag(CommandSetBit3.FUAWriteQ)) - { if(ataReport.EnabledCommandSet3.HasFlag(CommandSetBit3.FUAWriteQ) && ataReport.EnabledCommandSet3Specified) ataOneValue.Add("WRITE DMA QUEUED FUA EXT is supported and enabled"); else ataOneValue.Add("WRITE DMA QUEUED FUA EXT is supported"); - } if(ataReport.CommandSet3.HasFlag(CommandSetBit3.FUAWrite)) - { if(ataReport.EnabledCommandSet3.HasFlag(CommandSetBit3.FUAWrite) && ataReport.EnabledCommandSet3Specified) ataOneValue.Add("WRITE DMA FUA EXT and WRITE MULTIPLE FUA EXT are supported and enabled"); else ataOneValue.Add("WRITE DMA FUA EXT and WRITE MULTIPLE FUA EXT are supported"); - } if(ataReport.CommandSet3.HasFlag(CommandSetBit3.GPL)) - { if(ataReport.EnabledCommandSet3.HasFlag(CommandSetBit3.GPL) && ataReport.EnabledCommandSet3Specified ) ataOneValue.Add("General Purpose Logging is supported and enabled"); else ataOneValue.Add("General Purpose Logging is supported"); - } if(ataReport.CommandSet3.HasFlag(CommandSetBit3.Streaming)) - { if(ataReport.EnabledCommandSet3.HasFlag(CommandSetBit3.Streaming) && ataReport.EnabledCommandSet3Specified) ataOneValue.Add("Streaming feature set is supported and enabled"); else ataOneValue.Add("Streaming feature set is supported"); - } if(ataReport.CommandSet3.HasFlag(CommandSetBit3.MCPT) && ataReport.EnabledCommandSet3Specified) - { if(ataReport.EnabledCommandSet3.HasFlag(CommandSetBit3.MCPT)) ataOneValue.Add("Media Card Pass Through command set is supported and enabled"); else ataOneValue.Add("Media Card Pass Through command set is supported"); - } if(ataReport.CommandSet3.HasFlag(CommandSetBit3.MediaSerial) && ataReport.EnabledCommandSet3Specified) - { if(ataReport.EnabledCommandSet3.HasFlag(CommandSetBit3.MediaSerial)) ataOneValue.Add("Media Serial is supported and valid"); else ataOneValue.Add("Media Serial is supported"); - } } if(ataReport.CommandSet4Specified && ataReport.CommandSet4.HasFlag(CommandSetBit4.MustBeSet) && !ataReport.CommandSet4.HasFlag(CommandSetBit4.MustBeClear)) { if(ataReport.CommandSet4.HasFlag(CommandSetBit4.DSN)) - { if(ataReport.EnabledCommandSet4.HasFlag(CommandSetBit4.DSN) && ataReport.EnabledCommandSet4Specified ) ataOneValue.Add("DSN feature set is supported and enabled"); else ataOneValue.Add("DSN feature set is supported"); - } if(ataReport.CommandSet4.HasFlag(CommandSetBit4.AMAC)) - { if(ataReport.EnabledCommandSet4.HasFlag(CommandSetBit4.AMAC) && ataReport.EnabledCommandSet4Specified) ataOneValue.Add("Accessible Max Address Configuration is supported and enabled"); else ataOneValue.Add("Accessible Max Address Configuration is supported"); - } if(ataReport.CommandSet4.HasFlag(CommandSetBit4.ExtPowerCond)) - { if(ataReport.EnabledCommandSet4.HasFlag(CommandSetBit4.ExtPowerCond) && ataReport.EnabledCommandSet4Specified) ataOneValue.Add("Extended Power Conditions are supported and enabled"); else ataOneValue.Add("Extended Power Conditions are supported"); - } if(ataReport.CommandSet4.HasFlag(CommandSetBit4.ExtStatusReport)) - { if(ataReport.EnabledCommandSet4.HasFlag(CommandSetBit4.ExtStatusReport) && ataReport.EnabledCommandSet4Specified) ataOneValue.Add("Extended Status Reporting is supported and enabled"); else ataOneValue.Add("Extended Status Reporting is supported"); - } if(ataReport.CommandSet4.HasFlag(CommandSetBit4.FreeFallControl)) - { if(ataReport.EnabledCommandSet4.HasFlag(CommandSetBit4.FreeFallControl) && ataReport.EnabledCommandSet4Specified) ataOneValue.Add("Free-fall control feature set is supported and enabled"); else ataOneValue.Add("Free-fall control feature set is supported"); - } if(ataReport.CommandSet4.HasFlag(CommandSetBit4.SegmentedDownloadMicrocode)) - { if(ataReport.EnabledCommandSet4.HasFlag(CommandSetBit4.SegmentedDownloadMicrocode) && ataReport.EnabledCommandSet4Specified) ataOneValue.Add("Segmented feature in DOWNLOAD MICROCODE is supported and enabled"); else ataOneValue.Add("Segmented feature in DOWNLOAD MICROCODE is supported"); - } if(ataReport.CommandSet4.HasFlag(CommandSetBit4.RWDMAExtGpl)) - { if(ataReport.EnabledCommandSet4.HasFlag(CommandSetBit4.RWDMAExtGpl) && ataReport.EnabledCommandSet4Specified) ataOneValue.Add("READ/WRITE DMA EXT GPL are supported and enabled"); else ataOneValue.Add("READ/WRITE DMA EXT GPL are supported"); - } if(ataReport.CommandSet4.HasFlag(CommandSetBit4.WriteUnc)) - { if(ataReport.EnabledCommandSet4.HasFlag(CommandSetBit4.WriteUnc) && ataReport.EnabledCommandSet4Specified) ataOneValue.Add("WRITE UNCORRECTABLE is supported and enabled"); else ataOneValue.Add("WRITE UNCORRECTABLE is supported"); - } if(ataReport.CommandSet4.HasFlag(CommandSetBit4.WRV)) { if(ataReport.EnabledCommandSet4.HasFlag(CommandSetBit4.WRV) && ataReport.EnabledCommandSet4Specified @@ -1330,11 +1156,9 @@ namespace DiscImageChef.Server.App_Start ) ataOneValue.Add(string.Format("Current Write/Read/Verify mode: {0}", ataReport.WRVMode)); } if(ataReport.CommandSet4.HasFlag(CommandSetBit4.DT1825)) - { if(ataReport.EnabledCommandSet4.HasFlag(CommandSetBit4.DT1825) && ataReport.EnabledCommandSet4Specified) ataOneValue.Add("DT1825 is supported and enabled"); else ataOneValue.Add("DT1825 is supported"); - } } if(ataReport.Capabilities3Specified) @@ -1349,66 +1173,29 @@ namespace DiscImageChef.Server.App_Start if(ataReport.CommandSet5Specified) { - if(ataReport.CommandSet5.HasFlag(CommandSetBit5.DeviceConfDMA)) - { - ataOneValue.Add("DEVICE CONFIGURATION IDENTIFY DMA and DEVICE CONFIGURATION SET DMA are supported"); - } - if(ataReport.CommandSet5.HasFlag(CommandSetBit5.ReadBufferDMA)) - { - ataOneValue.Add("READ BUFFER DMA is supported"); - } - if(ataReport.CommandSet5.HasFlag(CommandSetBit5.WriteBufferDMA)) - { - ataOneValue.Add("WRITE BUFFER DMA is supported"); - } - if(ataReport.CommandSet5.HasFlag(CommandSetBit5.DownloadMicroCodeDMA)) - { - ataOneValue.Add("DOWNLOAD MICROCODE DMA is supported"); - } - if(ataReport.CommandSet5.HasFlag(CommandSetBit5.SetMaxDMA)) - { - ataOneValue.Add("SET PASSWORD DMA and SET UNLOCK DMA are supported"); - } - if(ataReport.CommandSet5.HasFlag(CommandSetBit5.Ata28)) - { - ataOneValue.Add("Not all 28-bit commands are supported"); - } + if(ataReport.CommandSet5.HasFlag(CommandSetBit5.DeviceConfDMA)) ataOneValue.Add("DEVICE CONFIGURATION IDENTIFY DMA and DEVICE CONFIGURATION SET DMA are supported"); + if(ataReport.CommandSet5.HasFlag(CommandSetBit5.ReadBufferDMA)) ataOneValue.Add("READ BUFFER DMA is supported"); + if(ataReport.CommandSet5.HasFlag(CommandSetBit5.WriteBufferDMA)) ataOneValue.Add("WRITE BUFFER DMA is supported"); + if(ataReport.CommandSet5.HasFlag(CommandSetBit5.DownloadMicroCodeDMA)) ataOneValue.Add("DOWNLOAD MICROCODE DMA is supported"); + if(ataReport.CommandSet5.HasFlag(CommandSetBit5.SetMaxDMA)) ataOneValue.Add("SET PASSWORD DMA and SET UNLOCK DMA are supported"); + if(ataReport.CommandSet5.HasFlag(CommandSetBit5.Ata28)) ataOneValue.Add("Not all 28-bit commands are supported"); - if(ataReport.CommandSet5.HasFlag(CommandSetBit5.CFast)) - { - ataOneValue.Add("Device follows CFast specification"); - } - if(ataReport.CommandSet5.HasFlag(CommandSetBit5.IEEE1667)) - { - ataOneValue.Add("Device follows IEEE-1667"); - } + if(ataReport.CommandSet5.HasFlag(CommandSetBit5.CFast)) ataOneValue.Add("Device follows CFast specification"); + if(ataReport.CommandSet5.HasFlag(CommandSetBit5.IEEE1667)) ataOneValue.Add("Device follows IEEE-1667"); if(ataReport.CommandSet5.HasFlag(CommandSetBit5.DeterministicTrim)) { ataOneValue.Add("Read after TRIM is deterministic"); - if(ataReport.CommandSet5.HasFlag(CommandSetBit5.ReadZeroTrim)) - { - ataOneValue.Add("Read after TRIM returns empty data"); - } - } - if(ataReport.CommandSet5.HasFlag(CommandSetBit5.LongPhysSectorAligError)) - { - ataOneValue.Add("Device supports Long Physical Sector Alignment Error Reporting Control"); - } - if(ataReport.CommandSet5.HasFlag(CommandSetBit5.Encrypted)) - { - ataOneValue.Add("Device encrypts all user data"); - } - if(ataReport.CommandSet5.HasFlag(CommandSetBit5.AllCacheNV)) - { - ataOneValue.Add("Device's write cache is non-volatile"); + if(ataReport.CommandSet5.HasFlag(CommandSetBit5.ReadZeroTrim)) ataOneValue.Add("Read after TRIM returns empty data"); } + if(ataReport.CommandSet5.HasFlag(CommandSetBit5.LongPhysSectorAligError)) ataOneValue.Add("Device supports Long Physical Sector Alignment Error Reporting Control"); + if(ataReport.CommandSet5.HasFlag(CommandSetBit5.Encrypted)) ataOneValue.Add("Device encrypts all user data"); + if(ataReport.CommandSet5.HasFlag(CommandSetBit5.AllCacheNV)) ataOneValue.Add("Device's write cache is non-volatile"); if(ataReport.CommandSet5.HasFlag(CommandSetBit5.ZonedBit0) || - ataReport.CommandSet5.HasFlag(CommandSetBit5.ZonedBit1)) { ataOneValue.Add("Device is zoned"); } + ataReport.CommandSet5.HasFlag(CommandSetBit5.ZonedBit1)) ataOneValue.Add("Device is zoned"); } if(ataReport.Capabilities3Specified) - { if(ataReport.Capabilities3.HasFlag(CapabilitiesBit3.Sanitize)) { ataOneValue.Add("Sanitize feature set is supported"); @@ -1419,125 +1206,80 @@ namespace DiscImageChef.Server.App_Start if(ataReport.Capabilities3.HasFlag(CapabilitiesBit3.SanitizeAntifreeze)) ataOneValue.Add("SANITIZE ANTIFREEZE LOCK EXT is supported"); } - } if(!ata1 && maxatalevel >= 8 && ataReport.TrustedComputingSpecified) - { if(ataReport.TrustedComputing.HasFlag(TrustedComputingBit.Set) && !ataReport.TrustedComputing.HasFlag(TrustedComputingBit.Clear) && ataReport.TrustedComputing.HasFlag(TrustedComputingBit.TrustedComputing)) ataOneValue.Add("Trusted Computing feature set is supported"); - } if(ataReport.TransportMajorVersionSpecified && ((ataReport.TransportMajorVersion & 0xF000) >> 12 == 0x1 || (ataReport.TransportMajorVersion & 0xF000) >> 12 == 0xE)) { if(ataReport.SATACapabilitiesSpecified) - { if(!ataReport.SATACapabilities.HasFlag(SATACapabilitiesBit.Clear)) - { if(ataReport.SATACapabilities.HasFlag(SATACapabilitiesBit.ReadLogDMAExt)) ataOneValue.Add("READ LOG DMA EXT is supported"); - } - } if(ataReport.SATACapabilities2Specified) - { if(!ataReport.SATACapabilities2.HasFlag(SATACapabilitiesBit2.Clear)) - { if(ataReport.SATACapabilities2.HasFlag(SATACapabilitiesBit2.FPDMAQ)) ataOneValue.Add("RECEIVE FPDMA QUEUED and SEND FPDMA QUEUED are supported"); - } - } if(ataReport.SATAFeaturesSpecified) - { if(!ataReport.SATAFeatures.HasFlag(SATAFeaturesBit.Clear)) { if(ataReport.SATAFeatures.HasFlag(SATAFeaturesBit.NonZeroBufferOffset)) - { if(ataReport.EnabledSATAFeatures.HasFlag(SATAFeaturesBit.NonZeroBufferOffset) && ataReport.EnabledSATAFeaturesSpecified) ataOneValue.Add("Non-zero buffer offsets are supported and enabled"); else ataOneValue.Add("Non-zero buffer offsets are supported"); - } if(ataReport.SATAFeatures.HasFlag(SATAFeaturesBit.DMASetup)) - { if(ataReport.EnabledSATAFeatures.HasFlag(SATAFeaturesBit.DMASetup) && ataReport.EnabledSATAFeaturesSpecified) ataOneValue.Add("DMA Setup auto-activation is supported and enabled"); else ataOneValue.Add("DMA Setup auto-activation is supported"); - } if(ataReport.SATAFeatures.HasFlag(SATAFeaturesBit.InitPowerMgmt)) - { if(ataReport.EnabledSATAFeatures.HasFlag(SATAFeaturesBit.InitPowerMgmt) && ataReport.EnabledSATAFeaturesSpecified) ataOneValue.Add("Device-initiated power management is supported and enabled"); else ataOneValue.Add("Device-initiated power management is supported"); - } if(ataReport.SATAFeatures.HasFlag(SATAFeaturesBit.InOrderData)) - { if(ataReport.EnabledSATAFeatures.HasFlag(SATAFeaturesBit.InOrderData) && ataReport.EnabledSATAFeaturesSpecified) ataOneValue.Add("In-order data delivery is supported and enabled"); else ataOneValue.Add("In-order data delivery is supported"); - } if(!atapi) - { if(ataReport.SATAFeatures.HasFlag(SATAFeaturesBit.HardwareFeatureControl)) - { if(ataReport.EnabledSATAFeatures.HasFlag(SATAFeaturesBit.HardwareFeatureControl) && ataReport.EnabledSATAFeaturesSpecified) ataOneValue.Add("Hardware Feature Control is supported and enabled"); else ataOneValue.Add("Hardware Feature Control is supported"); - } - } if(atapi) - { if(ataReport.SATAFeatures.HasFlag(SATAFeaturesBit.AsyncNotification) && ataReport.EnabledSATAFeaturesSpecified) - { if(ataReport.EnabledSATAFeatures.HasFlag(SATAFeaturesBit.AsyncNotification) && ataReport.EnabledSATAFeaturesSpecified) ataOneValue.Add("Asynchronous notification is supported"); else ataOneValue.Add("Asynchronous notification is supported"); - } - } if(ataReport.SATAFeatures.HasFlag(SATAFeaturesBit.SettingsPreserve)) - { if(ataReport.EnabledSATAFeatures.HasFlag(SATAFeaturesBit.SettingsPreserve) && ataReport.EnabledSATAFeaturesSpecified) ataOneValue.Add("Software Settings Preservation is supported"); else ataOneValue.Add("Software Settings Preservation is supported"); - } - if(ataReport.SATAFeatures.HasFlag(SATAFeaturesBit.NCQAutoSense)) - { - ataOneValue.Add("NCQ Autosense is supported"); - } - if(ataReport.EnabledSATAFeatures.HasFlag(SATAFeaturesBit.EnabledSlumber)) - { - ataOneValue.Add("Automatic Partial to Slumber transitions are enabled"); - } + if(ataReport.SATAFeatures.HasFlag(SATAFeaturesBit.NCQAutoSense)) ataOneValue.Add("NCQ Autosense is supported"); + if(ataReport.EnabledSATAFeatures.HasFlag(SATAFeaturesBit.EnabledSlumber)) ataOneValue.Add("Automatic Partial to Slumber transitions are enabled"); } - } - } - if((ataReport.RemovableStatusSet & 0x03) > 0) - { - ataOneValue.Add("Removable Media Status Notification feature set is supported"); } + if((ataReport.RemovableStatusSet & 0x03) > 0) ataOneValue.Add("Removable Media Status Notification feature set is supported"); - if(ataReport.FreeFallSensitivity != 0x00 && ataReport.FreeFallSensitivity != 0xFF) - { - ataOneValue.Add(string.Format("Free-fall sensitivity set to {0}", ataReport.FreeFallSensitivity)); - } + if(ataReport.FreeFallSensitivity != 0x00 && ataReport.FreeFallSensitivity != 0xFF) ataOneValue.Add(string.Format("Free-fall sensitivity set to {0}", ataReport.FreeFallSensitivity)); if(ataReport.DataSetMgmtSpecified && ataReport.DataSetMgmt.HasFlag(DataSetMgmtBit.Trim)) ataOneValue.Add("TRIM is supported"); if(ataReport.DataSetMgmtSizeSpecified && ataReport.DataSetMgmtSize > 0) - { ataOneValue.Add(string.Format("DATA SET MANAGEMENT can receive a maximum of {0} blocks of 512 bytes", ataReport.DataSetMgmtSize)); - } if(ataReport.SecurityStatusSpecified && ataReport.SecurityStatus.HasFlag(SecurityStatusBit.Supported)) { @@ -1630,13 +1372,11 @@ namespace DiscImageChef.Server.App_Start if(ataReport.ReadCapabilities.NominalRotationRateSpecified && ataReport.ReadCapabilities.NominalRotationRate != 0x0000 && ataReport.ReadCapabilities.NominalRotationRate != 0xFFFF) - { if(ataReport.ReadCapabilities.NominalRotationRate == 0x0001) ataOneValue.Add("Device does not rotate."); else ataOneValue.Add(string.Format("Device rotates at {0} rpm", ataReport.ReadCapabilities.NominalRotationRate)); - } if(!atapi) { @@ -1658,10 +1398,8 @@ namespace DiscImageChef.Server.App_Start ataReport.ReadCapabilities.BlockSize != ataReport.ReadCapabilities.PhysicalBlockSize && (ataReport.ReadCapabilities.LogicalAlignment & 0x8000) == 0x0000 && (ataReport.ReadCapabilities.LogicalAlignment & 0x4000) == 0x4000) - { ataOneValue.Add(string.Format("Logical sector starts at offset {0} from physical sector", ataReport.ReadCapabilities.LogicalAlignment & 0x3FFF)); - } if(ataReport.ReadCapabilities.CHS != null && ataReport.ReadCapabilities.CurrentCHS != null) { @@ -1713,7 +1451,6 @@ namespace DiscImageChef.Server.App_Start string.Format("{0}", ataReport.ReadCapabilities.LBASectors)); if((ulong)ataReport.ReadCapabilities.LBASectors * logicalsectorsize / 1024 / 1024 > 1000000) - { ataTwoValue.Add("Device size in 28-bit LBA mode", string.Format("{0} bytes, {1} Tb, {2:F2} TiB", (ulong)ataReport.ReadCapabilities.LBASectors * @@ -1722,10 +1459,8 @@ namespace DiscImageChef.Server.App_Start logicalsectorsize / 1000 / 1000 / 1000 / 1000, (double)((ulong)ataReport.ReadCapabilities.LBASectors * logicalsectorsize) / 1024 / 1024 / 1024 / 1024)); - } else if((ulong)ataReport.ReadCapabilities.LBASectors * logicalsectorsize / 1024 / 1024 > 1000) - { ataTwoValue.Add("Device size in 28-bit LBA mode", string.Format("{0} bytes, {1} Gb, {2:F2} GiB", (ulong)ataReport.ReadCapabilities.LBASectors * @@ -1734,9 +1469,7 @@ namespace DiscImageChef.Server.App_Start logicalsectorsize / 1000 / 1000 / 1000, (double)((ulong)ataReport.ReadCapabilities.LBASectors * logicalsectorsize) / 1024 / 1024 / 1024)); - } else - { ataTwoValue.Add("Device size in 28-bit LBA mode", string.Format("{0} bytes, {1} Mb, {2:F2} MiB", (ulong)ataReport.ReadCapabilities.LBASectors * @@ -1745,7 +1478,6 @@ namespace DiscImageChef.Server.App_Start logicalsectorsize / 1000 / 1000, (double)((ulong)ataReport.ReadCapabilities.LBASectors * logicalsectorsize) / 1024 / 1024)); - } } if(ataReport.ReadCapabilities.LBA48SectorsSpecified) @@ -1754,7 +1486,6 @@ namespace DiscImageChef.Server.App_Start string.Format("{0}", ataReport.ReadCapabilities.LBA48Sectors)); if(ataReport.ReadCapabilities.LBA48Sectors * logicalsectorsize / 1024 / 1024 > 1000000) - { ataTwoValue.Add("Device size in 48-bit LBA mode", string.Format("{0} bytes, {1} Tb, {2:F2} TiB", ataReport.ReadCapabilities.LBA48Sectors * logicalsectorsize, @@ -1762,9 +1493,7 @@ namespace DiscImageChef.Server.App_Start logicalsectorsize / 1000 / 1000 / 1000 / 1000, (double)(ataReport.ReadCapabilities.LBA48Sectors * logicalsectorsize) / 1024 / 1024 / 1024 / 1024)); - } else if(ataReport.ReadCapabilities.LBA48Sectors * logicalsectorsize / 1024 / 1024 > 1000) - { ataTwoValue.Add("Device size in 48-bit LBA mode", string.Format("{0} bytes, {1} Gb, {2:F2} GiB", ataReport.ReadCapabilities.LBA48Sectors * logicalsectorsize, @@ -1772,9 +1501,7 @@ namespace DiscImageChef.Server.App_Start logicalsectorsize / 1000 / 1000 / 1000, (double)(ataReport.ReadCapabilities.LBA48Sectors * logicalsectorsize) / 1024 / 1024 / 1024)); - } else - { ataTwoValue.Add("Device size in 48-bit LBA mode", string.Format("{0} bytes, {1} Mb, {2:F2} MiB", ataReport.ReadCapabilities.LBA48Sectors * logicalsectorsize, @@ -1782,7 +1509,6 @@ namespace DiscImageChef.Server.App_Start logicalsectorsize / 1000 / 1000, (double)(ataReport.ReadCapabilities.LBA48Sectors * logicalsectorsize) / 1024 / 1024)); - } } if(ata1 || cfa) diff --git a/DiscImageChef.Server/Controllers/UploadReportController.cs b/DiscImageChef.Server/Controllers/UploadReportController.cs index 02b8839c3..0bf6d886a 100644 --- a/DiscImageChef.Server/Controllers/UploadReportController.cs +++ b/DiscImageChef.Server/Controllers/UploadReportController.cs @@ -71,10 +71,7 @@ namespace DiscImageChef.Server.Controllers Random rng = new Random(); string filename = string.Format("NewReport_{0:yyyyMMddHHmmssfff}_{1}.xml", DateTime.UtcNow, rng.Next()); - while(File.Exists(Path.Combine(System.Web.Hosting.HostingEnvironment.MapPath("~"), "Upload", filename))) - { - filename = string.Format("NewReport_{0:yyyyMMddHHmmssfff}_{1}.xml", DateTime.UtcNow, rng.Next()); - } + while(File.Exists(Path.Combine(System.Web.Hosting.HostingEnvironment.MapPath("~"), "Upload", filename))) filename = string.Format("NewReport_{0:yyyyMMddHHmmssfff}_{1}.xml", DateTime.UtcNow, rng.Next()); FileStream newFile = new FileStream(Path.Combine(System.Web.Hosting.HostingEnvironment.MapPath("~"), "Upload", filename), diff --git a/DiscImageChef.Server/Controllers/UploadStatsController.cs b/DiscImageChef.Server/Controllers/UploadStatsController.cs index 3cdf098cf..efbe868d6 100644 --- a/DiscImageChef.Server/Controllers/UploadStatsController.cs +++ b/DiscImageChef.Server/Controllers/UploadStatsController.cs @@ -85,7 +85,6 @@ namespace DiscImageChef.Server.Controllers oldStats = (Stats)xs.Deserialize(fs); if(newStats.Commands != null) - { if(oldStats.Commands == null) oldStats.Commands = newStats.Commands; else { @@ -109,20 +108,16 @@ namespace DiscImageChef.Server.Controllers oldStats.Commands.ListDevices += newStats.Commands.ListDevices; oldStats.Commands.ListEncodings += newStats.Commands.ListEncodings; } - } if(newStats.OperatingSystems != null) - { if(oldStats.OperatingSystems == null) oldStats.OperatingSystems = newStats.OperatingSystems; else - { foreach(OsStats newNvs in newStats.OperatingSystems) { OsStats removeNvs = null; OsStats addNvs = null; foreach(OsStats oldNvs in oldStats.OperatingSystems) - { if(oldNvs.name == newNvs.name && oldNvs.version == newNvs.version) { addNvs = new OsStats @@ -134,7 +129,6 @@ namespace DiscImageChef.Server.Controllers removeNvs = oldNvs; break; } - } if(removeNvs != null && addNvs != null) { @@ -143,8 +137,6 @@ namespace DiscImageChef.Server.Controllers } else oldStats.OperatingSystems.Add(newNvs); } - } - } else { if(oldStats.OperatingSystems == null) @@ -156,7 +148,6 @@ namespace DiscImageChef.Server.Controllers OsStats addNvs = null; foreach(OsStats oldNvs in oldStats.OperatingSystems) - { if(oldNvs.name == "Linux") { addNvs = new OsStats @@ -168,7 +159,6 @@ namespace DiscImageChef.Server.Controllers removeNvs = oldNvs; break; } - } if(removeNvs != null && addNvs != null) { @@ -180,17 +170,14 @@ namespace DiscImageChef.Server.Controllers } if(newStats.Versions != null) - { if(oldStats.Versions == null) oldStats.Versions = newStats.Versions; else - { foreach(NameValueStats newNvs in newStats.Versions) { NameValueStats removeNvs = null; NameValueStats addNvs = null; foreach(NameValueStats oldNvs in oldStats.Versions) - { if(oldNvs.name == newNvs.name) { addNvs = new NameValueStats @@ -201,7 +188,6 @@ namespace DiscImageChef.Server.Controllers removeNvs = oldNvs; break; } - } if(removeNvs != null && addNvs != null) { @@ -210,8 +196,6 @@ namespace DiscImageChef.Server.Controllers } else oldStats.Versions.Add(newNvs); } - } - } else { if(oldStats.Versions == null) @@ -226,14 +210,12 @@ namespace DiscImageChef.Server.Controllers NameValueStats addNvs = null; foreach(NameValueStats oldNvs in oldStats.Versions) - { if(oldNvs.name == "previous") { addNvs = new NameValueStats {name = oldNvs.name, Value = oldNvs.Value + 1}; removeNvs = oldNvs; break; } - } if(removeNvs != null && addNvs != null) { @@ -245,17 +227,14 @@ namespace DiscImageChef.Server.Controllers } if(newStats.Filesystems != null) - { if(oldStats.Filesystems == null) oldStats.Filesystems = newStats.Filesystems; else - { foreach(NameValueStats newNvs in newStats.Filesystems) { NameValueStats removeNvs = null; NameValueStats addNvs = null; foreach(NameValueStats oldNvs in oldStats.Filesystems) - { if(oldNvs.name == newNvs.name) { addNvs = new NameValueStats @@ -266,7 +245,6 @@ namespace DiscImageChef.Server.Controllers removeNvs = oldNvs; break; } - } if(removeNvs != null && addNvs != null) { @@ -275,21 +253,16 @@ namespace DiscImageChef.Server.Controllers } else oldStats.Filesystems.Add(newNvs); } - } - } if(newStats.Partitions != null) - { if(oldStats.Partitions == null) oldStats.Partitions = newStats.Partitions; else - { foreach(NameValueStats newNvs in newStats.Partitions) { NameValueStats removeNvs = null; NameValueStats addNvs = null; foreach(NameValueStats oldNvs in oldStats.Partitions) - { if(oldNvs.name == newNvs.name) { addNvs = new NameValueStats @@ -300,7 +273,6 @@ namespace DiscImageChef.Server.Controllers removeNvs = oldNvs; break; } - } if(removeNvs != null && addNvs != null) { @@ -309,21 +281,16 @@ namespace DiscImageChef.Server.Controllers } else oldStats.Partitions.Add(newNvs); } - } - } if(newStats.MediaImages != null) - { if(oldStats.MediaImages == null) oldStats.MediaImages = newStats.MediaImages; else - { foreach(NameValueStats newNvs in newStats.MediaImages) { NameValueStats removeNvs = null; NameValueStats addNvs = null; foreach(NameValueStats oldNvs in oldStats.MediaImages) - { if(oldNvs.name == newNvs.name) { addNvs = new NameValueStats @@ -334,7 +301,6 @@ namespace DiscImageChef.Server.Controllers removeNvs = oldNvs; break; } - } if(removeNvs != null && addNvs != null) { @@ -343,21 +309,16 @@ namespace DiscImageChef.Server.Controllers } else oldStats.MediaImages.Add(newNvs); } - } - } if(newStats.Filters != null) - { if(oldStats.Filters == null) oldStats.Filters = newStats.Filters; else - { foreach(NameValueStats newNvs in newStats.Filters) { NameValueStats removeNvs = null; NameValueStats addNvs = null; foreach(NameValueStats oldNvs in oldStats.Filters) - { if(oldNvs.name == newNvs.name) { addNvs = new NameValueStats @@ -368,7 +329,6 @@ namespace DiscImageChef.Server.Controllers removeNvs = oldNvs; break; } - } if(removeNvs != null && addNvs != null) { @@ -377,45 +337,34 @@ namespace DiscImageChef.Server.Controllers } else oldStats.Filters.Add(newNvs); } - } - } if(newStats.Devices != null) - { if(oldStats.Devices == null) oldStats.Devices = newStats.Devices; else - { foreach(DeviceStats newDev in newStats.Devices) { bool found = false; foreach(DeviceStats oldDev in oldStats.Devices) - { if(oldDev.Manufacturer == newDev.Manufacturer && oldDev.Model == newDev.Model && oldDev.Revision == newDev.Revision && oldDev.Bus == newDev.Bus) { found = true; break; } - } if(!found) oldStats.Devices.Add(newDev); } - } - } if(newStats.Medias != null) - { if(oldStats.Medias == null) oldStats.Medias = newStats.Medias; else - { foreach(MediaStats newMstat in newStats.Medias) { MediaStats removeMstat = null; MediaStats addMstat = null; foreach(MediaStats oldMstat in oldStats.Medias) - { if(oldMstat.real == newMstat.real && oldMstat.type == newMstat.type) { addMstat = new MediaStats @@ -427,7 +376,6 @@ namespace DiscImageChef.Server.Controllers removeMstat = oldMstat; break; } - } if(removeMstat != null && addMstat != null) { @@ -436,11 +384,8 @@ namespace DiscImageChef.Server.Controllers } else oldStats.Medias.Add(newMstat); } - } - } if(newStats.MediaScan != null) - { if(oldStats.MediaScan == null) oldStats.MediaScan = newStats.MediaScan; else { @@ -464,10 +409,8 @@ namespace DiscImageChef.Server.Controllers oldStats.MediaScan.Times.MoreThan500ms = newStats.MediaScan.Times.MoreThan500ms; } } - } if(newStats.Verify != null) - { if(oldStats.Verify == null) oldStats.Verify = newStats.Verify; else { @@ -488,7 +431,6 @@ namespace DiscImageChef.Server.Controllers oldStats.Verify.MediaImages.Failed = newStats.Verify.MediaImages.Failed; } } - } if(oldStats.Devices != null) oldStats.Devices = oldStats.Devices.OrderBy(device => device.Manufacturer) @@ -499,10 +441,7 @@ namespace DiscImageChef.Server.Controllers string filename = string.Format("BackupStats_{0:yyyyMMddHHmmssfff}_{1}.xml", DateTime.UtcNow, rng.Next()); while(File.Exists(Path.Combine(System.Web.Hosting.HostingEnvironment.MapPath("~"), "Statistics", - filename))) - { - filename = string.Format("BackupStats_{0:yyyyMMddHHmmssfff}_{1}.xml", DateTime.UtcNow, rng.Next()); - } + filename))) filename = string.Format("BackupStats_{0:yyyyMMddHHmmssfff}_{1}.xml", DateTime.UtcNow, rng.Next()); FileStream backup = new @@ -544,7 +483,7 @@ namespace DiscImageChef.Server.Controllers } catch(IOException) { - if(fs != null) { fs.Dispose(); } + if(fs != null) fs.Dispose(); System.Threading.Thread.Sleep(50); } } diff --git a/DiscImageChef.Server/Statistics.aspx.cs b/DiscImageChef.Server/Statistics.aspx.cs index 1a91f0085..6008cbc4e 100644 --- a/DiscImageChef.Server/Statistics.aspx.cs +++ b/DiscImageChef.Server/Statistics.aspx.cs @@ -98,6 +98,7 @@ namespace DiscImageChef.Server { operatingSystems = new List(); foreach(OsStats nvs in statistics.OperatingSystems) + { operatingSystems.Add(new NameValueStats { name = string.Format("{0}{1}{2}", @@ -107,6 +108,7 @@ namespace DiscImageChef.Server string.IsNullOrEmpty(nvs.version) ? "" : " ", nvs.version), Value = nvs.Value }); + } repOperatingSystems.DataSource = operatingSystems.OrderBy(os => os.name).ToList(); repOperatingSystems.DataBind(); @@ -259,7 +261,7 @@ namespace DiscImageChef.Server xmlFile = xmlFile.Replace('/', '_').Replace('\\', '_').Replace('?', '_'); if(!File.Exists(Path.Combine(System.Web.Hosting.HostingEnvironment.MapPath("~"), "Reports", - xmlFile))) { url = null; } + xmlFile))) url = null; devices.Add(new DeviceItem() { @@ -300,7 +302,7 @@ namespace DiscImageChef.Server } catch(IOException) { - if(fs != null) { fs.Dispose(); } + if(fs != null) fs.Dispose(); System.Threading.Thread.Sleep(50); } } diff --git a/DiscImageChef.Server/ViewReport.aspx.cs b/DiscImageChef.Server/ViewReport.aspx.cs index 1b037726d..6a8ad5e94 100644 --- a/DiscImageChef.Server/ViewReport.aspx.cs +++ b/DiscImageChef.Server/ViewReport.aspx.cs @@ -54,19 +54,25 @@ namespace DiscImageChef.Server // Strip non-ascii, strip slashes and question marks if(manufacturer != null) + { manufacturer = Encoding .ASCII.GetString(Encoding.Convert(Encoding.UTF8, Encoding.ASCII, Encoding.UTF8.GetBytes(manufacturer))).Replace('/', '_') .Replace('\\', '_').Replace('?', '_'); + } if(model != null) + { model = Encoding .ASCII.GetString(Encoding.Convert(Encoding.UTF8, Encoding.ASCII, Encoding.UTF8.GetBytes(model))) .Replace('/', '_').Replace('\\', '_').Replace('?', '_'); + } if(revision != null) + { revision = Encoding .ASCII.GetString(Encoding.Convert(Encoding.UTF8, Encoding.ASCII, Encoding.UTF8.GetBytes(revision))).Replace('/', '_') .Replace('\\', '_').Replace('?', '_'); + } string xmlFile = null; if(!string.IsNullOrWhiteSpace(manufacturer) && !string.IsNullOrWhiteSpace(model) && @@ -107,12 +113,16 @@ namespace DiscImageChef.Server lblUsbProduct.Text = HttpUtility.HtmlEncode(report.USB.Product); lblUsbVendor.Text = string.Format("0x{0:x4}", report.USB.VendorID); if(usbVendorDescription != null) + { lblUsbVendorDescription.Text = string.Format("({0})", HttpUtility.HtmlEncode(usbVendorDescription)); + } lblUsbProductId.Text = string.Format("0x{0:x4}", report.USB.ProductID); if(usbProductDescription != null) + { lblUsbProductDescription.Text = string.Format("({0})", HttpUtility.HtmlEncode(usbProductDescription)); + } } else divUsb.Visible = false; @@ -273,9 +283,11 @@ namespace DiscImageChef.Server if(VendorString.Prettify(report.SCSI.Inquiry.VendorIdentification) != report.SCSI.Inquiry.VendorIdentification) + { lblScsiVendor.Text = string.Format("{0} ({1})", report.SCSI.Inquiry.VendorIdentification, VendorString.Prettify(report.SCSI.Inquiry .VendorIdentification)); + } else lblScsiVendor.Text = report.SCSI.Inquiry.VendorIdentification; lblScsiProduct.Text = report.SCSI.Inquiry.ProductIdentification; lblScsiRevision.Text = report.SCSI.Inquiry.ProductRevisionLevel; @@ -287,8 +299,10 @@ namespace DiscImageChef.Server if(report.SCSI.SupportsModeSubpages) scsiOneValue.Add("Device supports MODE SENSE subpages"); if(report.SCSI.ModeSense != null) + { ScsiModeSense.Report(report.SCSI.ModeSense, report.SCSI.Inquiry.VendorIdentification, report.SCSI.Inquiry.PeripheralDeviceType, ref scsiOneValue, ref modePages); + } if(modePages.Count > 0) { @@ -436,16 +450,22 @@ namespace DiscImageChef.Server } if(report.SCSI.ReadCapabilities.MediumTypeSpecified) + { scsiOneValue.Add(string.Format("Medium type code: {0:X2}h", report.SCSI.ReadCapabilities.MediumType)); + } if(report.SCSI.ReadCapabilities.DensitySpecified) + { scsiOneValue.Add(string.Format("Density code: {0:X2}h", report.SCSI.ReadCapabilities.Density)); + } if((report.SCSI.ReadCapabilities.SupportsReadLong || report.SCSI.ReadCapabilities.SupportsReadLong16) && report.SCSI.ReadCapabilities.LongBlockSizeSpecified) + { scsiOneValue.Add(string.Format("Long block size: {0} bytes", report.SCSI.ReadCapabilities.LongBlockSize)); + } if(report.SCSI.ReadCapabilities.SupportsReadCapacity) scsiOneValue.Add("Device supports READ CAPACITY (10) command."); if(report.SCSI.ReadCapabilities.SupportsReadCapacity16) diff --git a/DiscImageChef.Settings/Settings.cs b/DiscImageChef.Settings/Settings.cs index c749aa6f3..4ebb279bc 100644 --- a/DiscImageChef.Settings/Settings.cs +++ b/DiscImageChef.Settings/Settings.cs @@ -180,16 +180,10 @@ namespace DiscImageChef.Settings { NSObject obj; - if(parsedPreferences.TryGetValue("SaveReportsGlobally", out obj)) - { - Current.SaveReportsGlobally = ((NSNumber)obj).ToBool(); - } + if(parsedPreferences.TryGetValue("SaveReportsGlobally", out obj)) Current.SaveReportsGlobally = ((NSNumber)obj).ToBool(); else Current.SaveReportsGlobally = false; - if(parsedPreferences.TryGetValue("ShareReports", out obj)) - { - Current.ShareReports = ((NSNumber)obj).ToBool(); - } + if(parsedPreferences.TryGetValue("ShareReports", out obj)) Current.ShareReports = ((NSNumber)obj).ToBool(); else Current.ShareReports = false; NSDictionary stats; @@ -202,70 +196,37 @@ namespace DiscImageChef.Settings NSObject obj2; Current.Stats = new StatsSettings(); - if(stats.TryGetValue("ShareStats", out obj2)) - { - Current.Stats.ShareStats = ((NSNumber)obj2).ToBool(); - } + if(stats.TryGetValue("ShareStats", out obj2)) Current.Stats.ShareStats = ((NSNumber)obj2).ToBool(); else Current.Stats.ShareStats = false; - if(stats.TryGetValue("BenchmarkStats", out obj2)) - { - Current.Stats.BenchmarkStats = ((NSNumber)obj2).ToBool(); - } + if(stats.TryGetValue("BenchmarkStats", out obj2)) Current.Stats.BenchmarkStats = ((NSNumber)obj2).ToBool(); else Current.Stats.BenchmarkStats = false; - if(stats.TryGetValue("CommandStats", out obj2)) - { - Current.Stats.CommandStats = ((NSNumber)obj2).ToBool(); - } + if(stats.TryGetValue("CommandStats", out obj2)) Current.Stats.CommandStats = ((NSNumber)obj2).ToBool(); else Current.Stats.CommandStats = false; - if(stats.TryGetValue("DeviceStats", out obj2)) - { - Current.Stats.DeviceStats = ((NSNumber)obj2).ToBool(); - } + if(stats.TryGetValue("DeviceStats", out obj2)) Current.Stats.DeviceStats = ((NSNumber)obj2).ToBool(); else Current.Stats.DeviceStats = false; - if(stats.TryGetValue("FilesystemStats", out obj2)) - { - Current.Stats.FilesystemStats = ((NSNumber)obj2).ToBool(); - } + if(stats.TryGetValue("FilesystemStats", out obj2)) Current.Stats.FilesystemStats = ((NSNumber)obj2).ToBool(); else Current.Stats.FilesystemStats = false; - if(stats.TryGetValue("FilterStats", out obj2)) - { - Current.Stats.FilterStats = ((NSNumber)obj2).ToBool(); - } + if(stats.TryGetValue("FilterStats", out obj2)) Current.Stats.FilterStats = ((NSNumber)obj2).ToBool(); else Current.Stats.FilterStats = false; - if(stats.TryGetValue("MediaImageStats", out obj2)) - { - Current.Stats.MediaImageStats = ((NSNumber)obj2).ToBool(); - } + if(stats.TryGetValue("MediaImageStats", out obj2)) Current.Stats.MediaImageStats = ((NSNumber)obj2).ToBool(); else Current.Stats.MediaImageStats = false; - if(stats.TryGetValue("MediaScanStats", out obj2)) - { - Current.Stats.MediaScanStats = ((NSNumber)obj2).ToBool(); - } + if(stats.TryGetValue("MediaScanStats", out obj2)) Current.Stats.MediaScanStats = ((NSNumber)obj2).ToBool(); else Current.Stats.MediaScanStats = false; - if(stats.TryGetValue("PartitionStats", out obj2)) - { - Current.Stats.PartitionStats = ((NSNumber)obj2).ToBool(); - } + if(stats.TryGetValue("PartitionStats", out obj2)) Current.Stats.PartitionStats = ((NSNumber)obj2).ToBool(); else Current.Stats.PartitionStats = false; - if(stats.TryGetValue("MediaStats", out obj2)) - { - Current.Stats.MediaStats = ((NSNumber)obj2).ToBool(); - } + if(stats.TryGetValue("MediaStats", out obj2)) Current.Stats.MediaStats = ((NSNumber)obj2).ToBool(); else Current.Stats.MediaStats = false; - if(stats.TryGetValue("VerifyStats", out obj2)) - { - Current.Stats.VerifyStats = ((NSNumber)obj2).ToBool(); - } + if(stats.TryGetValue("VerifyStats", out obj2)) Current.Stats.VerifyStats = ((NSNumber)obj2).ToBool(); else Current.Stats.VerifyStats = false; } } diff --git a/DiscImageChef.Tests.Devices/Main.cs b/DiscImageChef.Tests.Devices/Main.cs index b6ce5f835..37cb33d00 100644 --- a/DiscImageChef.Tests.Devices/Main.cs +++ b/DiscImageChef.Tests.Devices/Main.cs @@ -67,9 +67,11 @@ namespace DiscImageChef.Tests.Devices "----------------", "------------------------", "------------------------", "----------", "----------", "--------"); for(int i = 0; i < devices.Length; i++) + { DicConsole.WriteLine("{6,-8}|{0,-22}|{1,-16}|{2,-24}|{3,-24}|{4,-10}|{5,-10}", devices[i].Path, devices[i].Vendor, devices[i].Model, devices[i].Serial, devices[i].Bus, devices[i].Supported, i + 1); + } DicConsole.Write("Please choose which drive to test (0 to exit): "); strDev = System.Console.ReadLine(); diff --git a/DiscImageChef/Commands/Analyze.cs b/DiscImageChef/Commands/Analyze.cs index e612bef5c..348192b31 100644 --- a/DiscImageChef/Commands/Analyze.cs +++ b/DiscImageChef/Commands/Analyze.cs @@ -99,8 +99,10 @@ namespace DiscImageChef.Commands else { if(options.Verbose) + { DicConsole.VerboseWriteLine("Image format identified by {0} ({1}).", imageFormat.Name, imageFormat.PluginUuid); + } else DicConsole.WriteLine("Image format identified by {0}.", imageFormat.Name); } diff --git a/DiscImageChef/Commands/Checksum.cs b/DiscImageChef/Commands/Checksum.cs index 6c8f66714..07f1d87ff 100644 --- a/DiscImageChef/Commands/Checksum.cs +++ b/DiscImageChef/Commands/Checksum.cs @@ -168,8 +168,10 @@ namespace DiscImageChef.Commands if(options.SeparatedTracks) { foreach(ChecksumType chk in trackChecksum.End()) + { DicConsole.WriteLine("Track {0}'s {1}: {2}", currentTrack.TrackSequence, chk.type, chk.Value); + } } previousTrackEnd = currentTrack.TrackEndSector; diff --git a/DiscImageChef/Commands/Compare.cs b/DiscImageChef/Commands/Compare.cs index a9c3d8827..589ef4118 100644 --- a/DiscImageChef/Commands/Compare.cs +++ b/DiscImageChef/Commands/Compare.cs @@ -77,8 +77,10 @@ namespace DiscImageChef.Commands else { if(options.Verbose) + { DicConsole.VerboseWriteLine("Input file 1 format identified by {0} ({1}).", input1Format.Name, input1Format.PluginUuid); + } else DicConsole.WriteLine("Input file 1 format identified by {0}.", input1Format.Name); } @@ -90,8 +92,10 @@ namespace DiscImageChef.Commands else { if(options.Verbose) + { DicConsole.VerboseWriteLine("Input file 2 format identified by {0} ({1}).", input2Format.Name, input2Format.PluginUuid); + } else DicConsole.WriteLine("Input file 2 format identified by {0}.", input2Format.Name); } diff --git a/DiscImageChef/Commands/CreateSidecar.cs b/DiscImageChef/Commands/CreateSidecar.cs index 45cd64f1c..c5a497284 100644 --- a/DiscImageChef/Commands/CreateSidecar.cs +++ b/DiscImageChef/Commands/CreateSidecar.cs @@ -102,8 +102,10 @@ namespace DiscImageChef.Commands else { if(options.Verbose) + { DicConsole.VerboseWriteLine("Image format identified by {0} ({1}).", imageFormat.Name, imageFormat.PluginUuid); + } else DicConsole.WriteLine("Image format identified by {0}.", imageFormat.Name); } @@ -162,10 +164,7 @@ namespace DiscImageChef.Commands string[] contents = Directory.GetFiles(options.InputFile, "*", SearchOption.TopDirectoryOnly); List files = new List(); - foreach(string file in contents) - { - if(new FileInfo(file).Length % options.BlockSize == 0) files.Add(file); - } + foreach(string file in contents) if(new FileInfo(file).Length % options.BlockSize == 0) files.Add(file); files.Sort(StringComparer.CurrentCultureIgnoreCase); diff --git a/DiscImageChef/Commands/Decode.cs b/DiscImageChef/Commands/Decode.cs index c3e815222..aefc9d7a5 100644 --- a/DiscImageChef/Commands/Decode.cs +++ b/DiscImageChef/Commands/Decode.cs @@ -117,8 +117,10 @@ 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"); + } else { DicConsole.WriteLine("ATA IDENTIFY PACKET DEVICE command response:"); diff --git a/DiscImageChef/Commands/DeviceInfo.cs b/DiscImageChef/Commands/DeviceInfo.cs index 94cfbcdc1..9fd8a19ba 100644 --- a/DiscImageChef/Commands/DeviceInfo.cs +++ b/DiscImageChef/Commands/DeviceInfo.cs @@ -48,10 +48,7 @@ namespace DiscImageChef.Commands DicConsole.DebugWriteLine("Device-Info command", "--output-prefix={0}", options.OutputPrefix); if(options.DevicePath.Length == 2 && options.DevicePath[1] == ':' && options.DevicePath[0] != '/' && - char.IsLetter(options.DevicePath[0])) - { - options.DevicePath = "\\\\.\\" + char.ToUpper(options.DevicePath[0]) + ':'; - } + char.IsLetter(options.DevicePath[0])) options.DevicePath = "\\\\.\\" + char.ToUpper(options.DevicePath[0]) + ':'; Device dev = new Device(options.DevicePath); @@ -605,8 +602,10 @@ namespace DiscImageChef.Commands sense = dev.ModeSense10(out modeBuf, out senseBuf, false, true, ScsiModeSensePageControl.Current, 0x3F, 0xFF, 5, out duration); if(sense || dev.Error) + { sense = dev.ModeSense10(out modeBuf, out senseBuf, false, true, ScsiModeSensePageControl.Current, 0x3F, 0x00, 5, out duration); + } if(!sense && !dev.Error) decMode = Decoders.SCSI.Modes.DecodeMode10(modeBuf, devType); @@ -615,16 +614,20 @@ namespace DiscImageChef.Commands sense = dev.ModeSense6(out modeBuf, out senseBuf, false, ScsiModeSensePageControl.Current, 0x3F, 0xFF, 5, out duration); if(sense || dev.Error) + { sense = dev.ModeSense6(out modeBuf, out senseBuf, false, ScsiModeSensePageControl.Current, 0x3F, 0x00, 5, out duration); + } if(sense || dev.Error) sense = dev.ModeSense(out modeBuf, out senseBuf, 5, out duration); if(!sense && !dev.Error) decMode = Decoders.SCSI.Modes.DecodeMode6(modeBuf, devType); } if(!sense) + { DataFile.WriteTo("Device-Info command", options.OutputPrefix, "_scsi_modesense.bin", "SCSI MODE SENSE", modeBuf); + } if(decMode.HasValue) { @@ -641,17 +644,23 @@ namespace DiscImageChef.Commands { if(devType == Decoders.SCSI.PeripheralDeviceTypes.MultiMediaDevice && page.Subpage == 0) + { DicConsole.WriteLine(Decoders.SCSI.Modes .PrettifyModePage_00_SFF(page.PageResponse)); + } else { if(page.Subpage != 0) + { DicConsole .WriteLine("Found unknown vendor mode page {0:X2}h subpage {1:X2}h", page.Page, page.Subpage); + } else + { DicConsole.WriteLine("Found unknown vendor mode page {0:X2}h", page.Page); + } } break; } @@ -660,12 +669,16 @@ namespace DiscImageChef.Commands if(page.Subpage == 0) { if(devType == Decoders.SCSI.PeripheralDeviceTypes.MultiMediaDevice) + { DicConsole.WriteLine(Decoders.SCSI.Modes .PrettifyModePage_01_MMC(page .PageResponse)); + } else + { DicConsole.WriteLine(Decoders.SCSI.Modes .PrettifyModePage_01(page.PageResponse)); + } } else goto default; @@ -674,8 +687,10 @@ namespace DiscImageChef.Commands case 0x02: { if(page.Subpage == 0) + { DicConsole.WriteLine(Decoders.SCSI.Modes .PrettifyModePage_02(page.PageResponse)); + } else goto default; break; @@ -683,8 +698,10 @@ namespace DiscImageChef.Commands case 0x03: { if(page.Subpage == 0) + { DicConsole.WriteLine(Decoders.SCSI.Modes .PrettifyModePage_03(page.PageResponse)); + } else goto default; break; @@ -692,8 +709,10 @@ namespace DiscImageChef.Commands case 0x04: { if(page.Subpage == 0) + { DicConsole.WriteLine(Decoders.SCSI.Modes .PrettifyModePage_04(page.PageResponse)); + } else goto default; break; @@ -701,8 +720,10 @@ namespace DiscImageChef.Commands case 0x05: { if(page.Subpage == 0) + { DicConsole.WriteLine(Decoders.SCSI.Modes .PrettifyModePage_05(page.PageResponse)); + } else goto default; break; @@ -710,8 +731,10 @@ namespace DiscImageChef.Commands case 0x06: { if(page.Subpage == 0) + { DicConsole.WriteLine(Decoders.SCSI.Modes .PrettifyModePage_06(page.PageResponse)); + } else goto default; break; @@ -721,12 +744,16 @@ namespace DiscImageChef.Commands if(page.Subpage == 0) { if(devType == Decoders.SCSI.PeripheralDeviceTypes.MultiMediaDevice) + { DicConsole.WriteLine(Decoders.SCSI.Modes .PrettifyModePage_07_MMC(page .PageResponse)); + } else + { DicConsole.WriteLine(Decoders.SCSI.Modes .PrettifyModePage_07(page.PageResponse)); + } } else goto default; @@ -735,8 +762,10 @@ namespace DiscImageChef.Commands case 0x08: { if(page.Subpage == 0) + { DicConsole.WriteLine(Decoders.SCSI.Modes .PrettifyModePage_08(page.PageResponse)); + } else goto default; break; @@ -744,11 +773,15 @@ namespace DiscImageChef.Commands case 0x0A: { if(page.Subpage == 0) + { DicConsole.WriteLine(Decoders.SCSI.Modes .PrettifyModePage_0A(page.PageResponse)); + } else if(page.Subpage == 1) + { DicConsole.WriteLine(Decoders.SCSI.Modes .PrettifyModePage_0A_S01(page.PageResponse)); + } else goto default; break; @@ -756,8 +789,10 @@ namespace DiscImageChef.Commands case 0x0B: { if(page.Subpage == 0) + { DicConsole.WriteLine(Decoders.SCSI.Modes .PrettifyModePage_0B(page.PageResponse)); + } else goto default; break; @@ -765,8 +800,10 @@ namespace DiscImageChef.Commands case 0x0D: { if(page.Subpage == 0) + { DicConsole.WriteLine(Decoders.SCSI.Modes .PrettifyModePage_0D(page.PageResponse)); + } else goto default; break; @@ -774,8 +811,10 @@ namespace DiscImageChef.Commands case 0x0E: { if(page.Subpage == 0) + { DicConsole.WriteLine(Decoders.SCSI.Modes .PrettifyModePage_0E(page.PageResponse)); + } else goto default; break; @@ -783,8 +822,10 @@ namespace DiscImageChef.Commands case 0x0F: { if(page.Subpage == 0) + { DicConsole.WriteLine(Decoders.SCSI.Modes .PrettifyModePage_0F(page.PageResponse)); + } else goto default; break; @@ -794,12 +835,16 @@ namespace DiscImageChef.Commands if(page.Subpage == 0) { if(devType == Decoders.SCSI.PeripheralDeviceTypes.SequentialAccess) + { DicConsole.WriteLine(Decoders.SCSI.Modes .PrettifyModePage_10_SSC(page .PageResponse)); + } else + { DicConsole.WriteLine(Decoders.SCSI.Modes .PrettifyModePage_10(page.PageResponse)); + } } else goto default; @@ -808,8 +853,10 @@ namespace DiscImageChef.Commands case 0x11: { if(page.Subpage == 0) + { DicConsole.WriteLine(Decoders.SCSI.Modes .PrettifyModePage_11(page.PageResponse)); + } else goto default; break; @@ -819,9 +866,11 @@ namespace DiscImageChef.Commands case 0x14: { if(page.Subpage == 0) + { DicConsole.WriteLine(Decoders.SCSI.Modes .PrettifyModePage_12_13_14(page .PageResponse)); + } else goto default; break; @@ -829,11 +878,15 @@ namespace DiscImageChef.Commands case 0x1A: { if(page.Subpage == 0) + { DicConsole.WriteLine(Decoders.SCSI.Modes .PrettifyModePage_1A(page.PageResponse)); + } else if(page.Subpage == 1) + { DicConsole.WriteLine(Decoders.SCSI.Modes .PrettifyModePage_1A_S01(page.PageResponse)); + } else goto default; break; @@ -841,8 +894,10 @@ namespace DiscImageChef.Commands case 0x1B: { if(page.Subpage == 0) + { DicConsole.WriteLine(Decoders.SCSI.Modes .PrettifyModePage_1B(page.PageResponse)); + } else goto default; break; @@ -852,16 +907,22 @@ namespace DiscImageChef.Commands if(page.Subpage == 0) { if(devType == Decoders.SCSI.PeripheralDeviceTypes.MultiMediaDevice) + { DicConsole.WriteLine(Decoders.SCSI.Modes .PrettifyModePage_1C_SFF(page .PageResponse)); + } else + { DicConsole.WriteLine(Decoders.SCSI.Modes .PrettifyModePage_1C(page.PageResponse)); + } } else if(page.Subpage == 1) + { DicConsole.WriteLine(Decoders.SCSI.Modes .PrettifyModePage_1C_S01(page.PageResponse)); + } else goto default; break; @@ -869,8 +930,10 @@ namespace DiscImageChef.Commands case 0x1D: { if(page.Subpage == 0) + { DicConsole.WriteLine(Decoders.SCSI.Modes .PrettifyModePage_1D(page.PageResponse)); + } else goto default; break; @@ -879,9 +942,11 @@ namespace DiscImageChef.Commands { if(StringHandlers.CToString(inq.Value.VendorIdentification).Trim() == "CERTANCE" ) + { DicConsole.WriteLine(Decoders.SCSI.Modes .PrettifyCertanceModePage_21(page .PageResponse)); + } else goto default; break; @@ -890,9 +955,11 @@ namespace DiscImageChef.Commands { if(StringHandlers.CToString(inq.Value.VendorIdentification).Trim() == "CERTANCE" ) + { DicConsole.WriteLine(Decoders.SCSI.Modes .PrettifyCertanceModePage_22(page .PageResponse)); + } else goto default; break; @@ -900,8 +967,10 @@ namespace DiscImageChef.Commands case 0x24: { if(StringHandlers.CToString(inq.Value.VendorIdentification).Trim() == "IBM") + { DicConsole.WriteLine(Decoders.SCSI.Modes .PrettifyIBMModePage_24(page.PageResponse)); + } else goto default; break; @@ -909,8 +978,10 @@ namespace DiscImageChef.Commands case 0x2A: { if(page.Subpage == 0) + { DicConsole.WriteLine(Decoders.SCSI.Modes .PrettifyModePage_2A(page.PageResponse)); + } else goto default; break; @@ -918,8 +989,10 @@ namespace DiscImageChef.Commands case 0x2F: { if(StringHandlers.CToString(inq.Value.VendorIdentification).Trim() == "IBM") + { DicConsole.WriteLine(Decoders.SCSI.Modes .PrettifyIBMModePage_2F(page.PageResponse)); + } else goto default; break; @@ -935,8 +1008,10 @@ namespace DiscImageChef.Commands case 0x3B: { if(StringHandlers.CToString(inq.Value.VendorIdentification).Trim() == "HP") + { DicConsole.WriteLine(Decoders.SCSI.Modes .PrettifyHPModePage_3B(page.PageResponse)); + } else goto default; break; @@ -944,8 +1019,10 @@ namespace DiscImageChef.Commands case 0x3C: { if(StringHandlers.CToString(inq.Value.VendorIdentification).Trim() == "HP") + { DicConsole.WriteLine(Decoders.SCSI.Modes .PrettifyHPModePage_3C(page.PageResponse)); + } else goto default; break; @@ -953,11 +1030,15 @@ namespace DiscImageChef.Commands case 0x3D: { if(StringHandlers.CToString(inq.Value.VendorIdentification).Trim() == "IBM") + { DicConsole.WriteLine(Decoders.SCSI.Modes .PrettifyIBMModePage_3D(page.PageResponse)); + } else if(StringHandlers.CToString(inq.Value.VendorIdentification).Trim() == "HP") + { DicConsole.WriteLine(Decoders.SCSI.Modes .PrettifyHPModePage_3D(page.PageResponse)); + } else goto default; break; @@ -965,12 +1046,16 @@ namespace DiscImageChef.Commands case 0x3E: { if(StringHandlers.CToString(inq.Value.VendorIdentification).Trim() == "FUJITSU") + { DicConsole.WriteLine(Decoders.SCSI.Modes .PrettifyFujitsuModePage_3E(page .PageResponse)); + } else if(StringHandlers.CToString(inq.Value.VendorIdentification).Trim() == "HP") + { DicConsole.WriteLine(Decoders.SCSI.Modes .PrettifyHPModePage_3E(page.PageResponse)); + } else goto default; break; @@ -978,8 +1063,10 @@ namespace DiscImageChef.Commands default: { if(page.Subpage != 0) + { DicConsole.WriteLine("Found unknown mode page {0:X2}h subpage {1:X2}h", page.Page, page.Subpage); + } else DicConsole.WriteLine("Found unknown mode page {0:X2}h", page.Page); break; } @@ -1196,8 +1283,10 @@ namespace DiscImageChef.Commands } } else + { DicConsole.DebugWriteLine("Device-Info command", "GET CONFIGURATION returned no feature descriptors"); + } } // TODO: DVD drives respond correctly to BD status. @@ -1357,16 +1446,22 @@ namespace DiscImageChef.Commands if(!plxtSense) { if(plxtPwrRecSelected > 0) + { DicConsole .WriteLine("Selected PoweRec speed for currently inserted media is {0} Kb/sec ({1}x)", plxtPwrRecSelected, plxtPwrRecSelected / 177); + } if(plxtPwrRecMax > 0) + { DicConsole .WriteLine("Maximum PoweRec speed for currently inserted media is {0} Kb/sec ({1}x)", plxtPwrRecMax, plxtPwrRecMax / 177); + } if(plxtPwrRecLast > 0) + { DicConsole.WriteLine("Last used PoweRec was {0} Kb/sec ({1}x)", plxtPwrRecLast, plxtPwrRecLast / 177); + } } } else DicConsole.WriteLine("PoweRec is disabled"); @@ -1495,8 +1590,10 @@ namespace DiscImageChef.Commands sense = dev.ReadBlockLimits(out seqBuf, out senseBuf, dev.Timeout, out duration); if(sense) + { DicConsole.ErrorWriteLine("READ BLOCK LIMITS:\n{0}", Decoders.SCSI.Sense.PrettifySense(senseBuf)); + } else { DataFile.WriteTo("Device-Info command", options.OutputPrefix, "_ssc_readblocklimits.bin", @@ -1507,8 +1604,10 @@ namespace DiscImageChef.Commands sense = dev.ReportDensitySupport(out seqBuf, out senseBuf, dev.Timeout, out duration); if(sense) + { DicConsole.ErrorWriteLine("REPORT DENSITY SUPPORT:\n{0}", Decoders.SCSI.Sense.PrettifySense(senseBuf)); + } else { DataFile.WriteTo("Device-Info command", options.OutputPrefix, @@ -1525,8 +1624,10 @@ namespace DiscImageChef.Commands sense = dev.ReportDensitySupport(out seqBuf, out senseBuf, true, false, dev.Timeout, out duration); if(sense) + { DicConsole.ErrorWriteLine("REPORT DENSITY SUPPORT (MEDIUM):\n{0}", Decoders.SCSI.Sense.PrettifySense(senseBuf)); + } else { DataFile.WriteTo("Device-Info command", options.OutputPrefix, diff --git a/DiscImageChef/Commands/DeviceReport.cs b/DiscImageChef/Commands/DeviceReport.cs index 25e9a1579..89855e6bc 100644 --- a/DiscImageChef/Commands/DeviceReport.cs +++ b/DiscImageChef/Commands/DeviceReport.cs @@ -47,10 +47,7 @@ namespace DiscImageChef.Commands 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])) - { - options.DevicePath = "\\\\.\\" + char.ToUpper(options.DevicePath[0]) + ':'; - } + char.IsLetter(options.DevicePath[0])) options.DevicePath = "\\\\.\\" + char.ToUpper(options.DevicePath[0]) + ':'; Device dev = new Device(options.DevicePath); @@ -100,7 +97,7 @@ namespace DiscImageChef.Commands xmlFs.Close(); Core.Statistics.AddCommand("device-report"); - if(Settings.Settings.Current.ShareReports) { Remote.SubmitReport(report); } + if(Settings.Settings.Current.ShareReports) Remote.SubmitReport(report); } } } \ No newline at end of file diff --git a/DiscImageChef/Commands/DumpMedia.cs b/DiscImageChef/Commands/DumpMedia.cs index 21edb1ed6..13edd99c5 100644 --- a/DiscImageChef/Commands/DumpMedia.cs +++ b/DiscImageChef/Commands/DumpMedia.cs @@ -78,10 +78,7 @@ namespace DiscImageChef.Commands } if(options.DevicePath.Length == 2 && options.DevicePath[1] == ':' && options.DevicePath[0] != '/' && - char.IsLetter(options.DevicePath[0])) - { - options.DevicePath = "\\\\.\\" + char.ToUpper(options.DevicePath[0]) + ':'; - } + char.IsLetter(options.DevicePath[0])) options.DevicePath = "\\\\.\\" + char.ToUpper(options.DevicePath[0]) + ':'; Device dev = new Device(options.DevicePath); diff --git a/DiscImageChef/Commands/Entropy.cs b/DiscImageChef/Commands/Entropy.cs index 086d2429a..d088a4a61 100644 --- a/DiscImageChef/Commands/Entropy.cs +++ b/DiscImageChef/Commands/Entropy.cs @@ -119,9 +119,11 @@ namespace DiscImageChef.Commands #pragma warning disable IDE0004 // Cast is necessary, otherwise incorrect value is created if(options.DuplicatedSectors) + { DicConsole.WriteLine("Track {0} has {1} unique sectors ({1:P3})", currentTrack.TrackSequence, uniqueSectorsPerTrack.Count, (double)uniqueSectorsPerTrack.Count / (double)sectors); + } #pragma warning restore IDE0004 // Cast is necessary, otherwise incorrect value is created DicConsole.WriteLine(); @@ -178,8 +180,10 @@ namespace DiscImageChef.Commands if(options.DuplicatedSectors) #pragma warning disable IDE0004 // Cast is necessary, otherwise incorrect value is created + { DicConsole.WriteLine("Disk has {0} unique sectors ({1:P3})", uniqueSectors.Count, (double)uniqueSectors.Count / (double)sectors); + } #pragma warning restore IDE0004 // Cast is necessary, otherwise incorrect value is created Core.Statistics.AddCommand("entropy"); diff --git a/DiscImageChef/Commands/ExtractFiles.cs b/DiscImageChef/Commands/ExtractFiles.cs index fda637384..64b951b11 100644 --- a/DiscImageChef/Commands/ExtractFiles.cs +++ b/DiscImageChef/Commands/ExtractFiles.cs @@ -100,8 +100,10 @@ namespace DiscImageChef.Commands else { if(options.Verbose) + { DicConsole.VerboseWriteLine("Image format identified by {0} ({1}).", imageFormat.Name, imageFormat.PluginUuid); + } else DicConsole.WriteLine("Image format identified by {0}.", imageFormat.Name); } @@ -252,9 +254,11 @@ namespace DiscImageChef.Commands outputPath); } else + { DicConsole .ErrorWriteLine("Cannot write xattr {0} for {1}, output exists", xattr, entry); + } } } } @@ -294,26 +298,34 @@ namespace DiscImageChef.Commands outBuf.Length, entry, outputPath); } else + { DicConsole.ErrorWriteLine("Error {0} reading file {1}", error, entry); + } } else + { DicConsole .ErrorWriteLine("Cannot write file {0}, output exists", entry); + } } else DicConsole.ErrorWriteLine("Error reading file {0}", entry); } } else + { DicConsole.ErrorWriteLine("Error {0} reading root directory {0}", error.ToString()); + } Core.Statistics.AddFilesystem(fs.XmlFSType.Type); } else + { DicConsole.ErrorWriteLine("Unable to mount device, error {0}", error.ToString()); + } } } } @@ -391,9 +403,11 @@ namespace DiscImageChef.Commands outputPath); } else + { DicConsole .ErrorWriteLine("Cannot write xattr {0} for {1}, output exists", xattr, entry); + } } } } @@ -431,12 +445,16 @@ namespace DiscImageChef.Commands outBuf.Length, entry, outputPath); } else + { DicConsole.ErrorWriteLine("Error {0} reading file {1}", error, entry); + } } else + { DicConsole.ErrorWriteLine("Cannot write file {0}, output exists", entry); + } } else DicConsole.ErrorWriteLine("Error reading file {0}", entry); } @@ -539,9 +557,11 @@ namespace DiscImageChef.Commands outputPath); } else + { DicConsole .ErrorWriteLine("Cannot write xattr {0} for {1}, output exists", xattr, entry); + } } } } @@ -579,12 +599,16 @@ namespace DiscImageChef.Commands outBuf.Length, entry, outputPath); } else + { DicConsole.ErrorWriteLine("Error {0} reading file {1}", error, entry); + } } else + { DicConsole.ErrorWriteLine("Cannot write file {0}, output exists", entry); + } } else DicConsole.ErrorWriteLine("Error reading file {0}", entry); } @@ -670,9 +694,11 @@ namespace DiscImageChef.Commands xattrBuf.Length, xattr, entry, outputPath); } else + { DicConsole .ErrorWriteLine("Cannot write xattr {0} for {1}, output exists", xattr, entry); + } } } } diff --git a/DiscImageChef/Commands/Ls.cs b/DiscImageChef/Commands/Ls.cs index 8f10f332a..08bd885ea 100644 --- a/DiscImageChef/Commands/Ls.cs +++ b/DiscImageChef/Commands/Ls.cs @@ -96,8 +96,10 @@ namespace DiscImageChef.Commands else { if(options.Verbose) + { DicConsole.VerboseWriteLine("Image format identified by {0} ({1}).", imageFormat.Name, imageFormat.PluginUuid); + } else DicConsole.WriteLine("Image format identified by {0}.", imageFormat.Name); } @@ -165,19 +167,20 @@ namespace DiscImageChef.Commands { List rootDir = new List(); error = fs.ReadDir("/", ref rootDir); - if(error == Errno.NoError) - { - foreach(string entry in rootDir) DicConsole.WriteLine("{0}", entry); - } + if(error == Errno.NoError) foreach(string entry in rootDir) DicConsole.WriteLine("{0}", entry); else + { DicConsole.ErrorWriteLine("Error {0} reading root directory {0}", error.ToString()); + } Core.Statistics.AddFilesystem(fs.XmlFSType.Type); } else + { DicConsole.ErrorWriteLine("Unable to mount device, error {0}", error.ToString()); + } } } } @@ -195,10 +198,7 @@ namespace DiscImageChef.Commands { List rootDir = new List(); error = fs.ReadDir("/", ref rootDir); - if(error == Errno.NoError) - { - foreach(string entry in rootDir) DicConsole.WriteLine("{0}", entry); - } + if(error == Errno.NoError) foreach(string entry in rootDir) DicConsole.WriteLine("{0}", entry); else DicConsole.ErrorWriteLine("Error {0} reading root directory {0}", error.ToString()); @@ -237,10 +237,7 @@ namespace DiscImageChef.Commands { List rootDir = new List(); error = fs.ReadDir("/", ref rootDir); - if(error == Errno.NoError) - { - foreach(string entry in rootDir) DicConsole.WriteLine("{0}", entry); - } + if(error == Errno.NoError) foreach(string entry in rootDir) DicConsole.WriteLine("{0}", entry); else DicConsole.ErrorWriteLine("Error {0} reading root directory {0}", error.ToString()); @@ -286,10 +283,7 @@ namespace DiscImageChef.Commands { byte[] xattrBuf = new byte[0]; error = fs.GetXattr(entry, xattr, ref xattrBuf); - if(error == Errno.NoError) - { - DicConsole.WriteLine("\t\t{0}\t{1} bytes", xattr, xattrBuf.Length); - } + if(error == Errno.NoError) DicConsole.WriteLine("\t\t{0}\t{1} bytes", xattr, xattrBuf.Length); } } } diff --git a/DiscImageChef/Commands/MediaInfo.cs b/DiscImageChef/Commands/MediaInfo.cs index 720b34e1f..3f6b63b69 100644 --- a/DiscImageChef/Commands/MediaInfo.cs +++ b/DiscImageChef/Commands/MediaInfo.cs @@ -49,10 +49,7 @@ namespace DiscImageChef.Commands DicConsole.DebugWriteLine("Media-Info command", "--output-prefix={0}", options.OutputPrefix); if(options.DevicePath.Length == 2 && options.DevicePath[1] == ':' && options.DevicePath[0] != '/' && - char.IsLetter(options.DevicePath[0])) - { - options.DevicePath = "\\\\.\\" + char.ToUpper(options.DevicePath[0]) + ':'; - } + char.IsLetter(options.DevicePath[0])) options.DevicePath = "\\\\.\\" + char.ToUpper(options.DevicePath[0]) + ':'; Device dev = new Device(options.DevicePath); @@ -194,15 +191,17 @@ namespace DiscImageChef.Commands 0x00, 5, out duration); } - if(!sense && !dev.Error) { decMode = Decoders.SCSI.Modes.DecodeMode10(modeBuf, devType); } + if(!sense && !dev.Error) decMode = Decoders.SCSI.Modes.DecodeMode10(modeBuf, devType); if(sense || dev.Error || !decMode.HasValue) { sense = dev.ModeSense6(out modeBuf, out senseBuf, false, ScsiModeSensePageControl.Current, 0x3F, 0x00, 5, out duration); if(sense || dev.Error) + { sense = dev.ModeSense6(out modeBuf, out senseBuf, false, ScsiModeSensePageControl.Current, 0x3F, 0x00, 5, out duration); + } if(sense || dev.Error) sense = dev.ModeSense(out modeBuf, out senseBuf, 5, out duration); if(!sense && !dev.Error) decMode = Decoders.SCSI.Modes.DecodeMode6(modeBuf, devType); @@ -338,8 +337,10 @@ namespace DiscImageChef.Commands sense = dev.GetConfiguration(out cmdBuf, out senseBuf, 0, MmcGetConfigurationRt.Current, dev.Timeout, out duration); if(sense) + { DicConsole.DebugWriteLine("Media-Info command", "READ GET CONFIGURATION:\n{0}", Decoders.SCSI.Sense.PrettifySense(senseBuf)); + } else { DataFile.WriteTo("Media-Info command", outputPrefix, "_getconfiguration_current.bin", @@ -446,21 +447,29 @@ namespace DiscImageChef.Commands MmcDiscStructureFormat.RecognizedFormatLayers, 0, dev.Timeout, out duration); if(sense) + { DicConsole.DebugWriteLine("Media-Info command", "READ DISC STRUCTURE: Recognized Format Layers\n{0}", Decoders.SCSI.Sense.PrettifySense(senseBuf)); + } else + { DataFile.WriteTo("Media-Info command", outputPrefix, "_readdiscstructure_formatlayers.bin", "SCSI READ DISC STRUCTURE", cmdBuf); + } sense = dev.ReadDiscStructure(out cmdBuf, out senseBuf, MmcDiscStructureMediaType.Dvd, 0, 0, MmcDiscStructureFormat.WriteProtectionStatus, 0, dev.Timeout, out duration); if(sense) + { DicConsole.DebugWriteLine("Media-Info command", "READ DISC STRUCTURE: Write Protection Status\n{0}", Decoders.SCSI.Sense.PrettifySense(senseBuf)); + } else + { DataFile.WriteTo("Media-Info command", outputPrefix, "_readdiscstructure_writeprotection.bin", "SCSI READ DISC STRUCTURE", cmdBuf); + } // More like a drive information /* @@ -483,8 +492,10 @@ namespace DiscImageChef.Commands MmcDiscStructureFormat.PhysicalInformation, 0, dev.Timeout, out duration); if(sense) + { DicConsole.DebugWriteLine("Media-Info command", "READ DISC STRUCTURE: PFI\n{0}", Decoders.SCSI.Sense.PrettifySense(senseBuf)); + } else { DataFile.WriteTo("Media-Info command", outputPrefix, "_readdiscstructure_dvd_pfi.bin", @@ -554,8 +565,10 @@ namespace DiscImageChef.Commands MmcDiscStructureFormat.DiscManufacturingInformation, 0, dev.Timeout, out duration); if(sense) + { DicConsole.DebugWriteLine("Media-Info command", "READ DISC STRUCTURE: DMI\n{0}", Decoders.SCSI.Sense.PrettifySense(senseBuf)); + } else { DataFile.WriteTo("Media-Info command", outputPrefix, "_readdiscstructure_dvd_dmi.bin", @@ -587,8 +600,10 @@ namespace DiscImageChef.Commands MmcDiscStructureFormat.CopyrightInformation, 0, dev.Timeout, out duration); if(sense) + { DicConsole.DebugWriteLine("Media-Info command", "READ DISC STRUCTURE: CMI\n{0}", Decoders.SCSI.Sense.PrettifySense(senseBuf)); + } else { DataFile.WriteTo("Media-Info command", outputPrefix, "_readdiscstructure_dvd_cmi.bin", @@ -606,19 +621,27 @@ namespace DiscImageChef.Commands MmcDiscStructureFormat.BurstCuttingArea, 0, dev.Timeout, out duration); if(sense) + { DicConsole.DebugWriteLine("Media-Info command", "READ DISC STRUCTURE: BCA\n{0}", Decoders.SCSI.Sense.PrettifySense(senseBuf)); + } else + { DataFile.WriteTo("Media-Info command", outputPrefix, "_readdiscstructure_dvd_bca.bin", "SCSI READ DISC STRUCTURE", cmdBuf); + } sense = dev.ReadDiscStructure(out cmdBuf, out senseBuf, MmcDiscStructureMediaType.Dvd, 0, 0, MmcDiscStructureFormat.DvdAacs, 0, dev.Timeout, out duration); if(sense) + { DicConsole.DebugWriteLine("Media-Info command", "READ DISC STRUCTURE: DVD AACS\n{0}", Decoders.SCSI.Sense.PrettifySense(senseBuf)); + } else + { DataFile.WriteTo("Media-Info command", outputPrefix, "_readdiscstructure_dvd_aacs.bin", "SCSI READ DISC STRUCTURE", cmdBuf); + } } #endregion DVD-ROM and HD DVD-ROM @@ -688,8 +711,10 @@ namespace DiscImageChef.Commands sense = dev.ReadDiscStructure(out cmdBuf, out senseBuf, MmcDiscStructureMediaType.Dvd, 0, 0, MmcDiscStructureFormat.DvdramDds, 0, dev.Timeout, out duration); if(sense) + { DicConsole.DebugWriteLine("Media-Info command", "READ DISC STRUCTURE: DDS\n{0}", Decoders.SCSI.Sense.PrettifySense(senseBuf)); + } else { DataFile.WriteTo("Media-Info command", outputPrefix, "_readdiscstructure_dvdram_dds.bin", @@ -700,8 +725,10 @@ namespace DiscImageChef.Commands MmcDiscStructureFormat.DvdramMediumStatus, 0, dev.Timeout, out duration); if(sense) + { DicConsole.DebugWriteLine("Media-Info command", "READ DISC STRUCTURE: Medium Status\n{0}", Decoders.SCSI.Sense.PrettifySense(senseBuf)); + } else { DataFile.WriteTo("Media-Info command", outputPrefix, "_readdiscstructure_dvdram_status.bin", @@ -712,8 +739,10 @@ namespace DiscImageChef.Commands MmcDiscStructureFormat.DvdramSpareAreaInformation, 0, dev.Timeout, out duration); if(sense) + { DicConsole.DebugWriteLine("Media-Info command", "READ DISC STRUCTURE: SAI\n{0}", Decoders.SCSI.Sense.PrettifySense(senseBuf)); + } else { DataFile.WriteTo("Media-Info command", outputPrefix, "_readdiscstructure_dvdram_spare.bin", @@ -730,11 +759,15 @@ namespace DiscImageChef.Commands MmcDiscStructureFormat.LastBorderOutRmd, 0, dev.Timeout, out duration); if(sense) + { DicConsole.DebugWriteLine("Media-Info command", "READ DISC STRUCTURE: Last-Out Border RMD\n{0}", Decoders.SCSI.Sense.PrettifySense(senseBuf)); + } else + { DataFile.WriteTo("Media-Info command", outputPrefix, "_readdiscstructure_dvd_lastrmd.bin", "SCSI READ DISC STRUCTURE", cmdBuf); + } } #endregion DVD-R and HD DVD-R @@ -744,11 +777,15 @@ namespace DiscImageChef.Commands sense = dev.ReadDiscStructure(out cmdBuf, out senseBuf, MmcDiscStructureMediaType.Dvd, 0, 0, MmcDiscStructureFormat.PreRecordedInfo, 0, dev.Timeout, out duration); if(sense) + { DicConsole.DebugWriteLine("Media-Info command", "READ DISC STRUCTURE: Pre-Recorded Info\n{0}", Decoders.SCSI.Sense.PrettifySense(senseBuf)); + } else + { DataFile.WriteTo("Media-Info command", outputPrefix, "_readdiscstructure_dvd_pri.bin", "SCSI READ DISC STRUCTURE", cmdBuf); + } } #endregion DVD-R and DVD-RW @@ -759,20 +796,28 @@ namespace DiscImageChef.Commands MmcDiscStructureFormat.DvdrMediaIdentifier, 0, dev.Timeout, out duration); if(sense) + { DicConsole.DebugWriteLine("Media-Info command", "READ DISC STRUCTURE: DVD-R Media ID\n{0}", Decoders.SCSI.Sense.PrettifySense(senseBuf)); + } else + { DataFile.WriteTo("Media-Info command", outputPrefix, "_readdiscstructure_dvdr_mediaid.bin", "SCSI READ DISC STRUCTURE", cmdBuf); + } sense = dev.ReadDiscStructure(out cmdBuf, out senseBuf, MmcDiscStructureMediaType.Dvd, 0, 0, MmcDiscStructureFormat.DvdrPhysicalInformation, 0, dev.Timeout, out duration); if(sense) + { DicConsole.DebugWriteLine("Media-Info command", "READ DISC STRUCTURE: DVD-R PFI\n{0}", Decoders.SCSI.Sense.PrettifySense(senseBuf)); + } else + { DataFile.WriteTo("Media-Info command", outputPrefix, "_readdiscstructure_dvdr_pfi.bin", "SCSI READ DISC STRUCTURE", cmdBuf); + } } #endregion DVD-R, DVD-RW and HD DVD-R @@ -783,20 +828,28 @@ namespace DiscImageChef.Commands sense = dev.ReadDiscStructure(out cmdBuf, out senseBuf, MmcDiscStructureMediaType.Dvd, 0, 0, MmcDiscStructureFormat.Adip, 0, dev.Timeout, out duration); if(sense) + { DicConsole.DebugWriteLine("Media-Info command", "READ DISC STRUCTURE: ADIP\n{0}", Decoders.SCSI.Sense.PrettifySense(senseBuf)); + } else + { DataFile.WriteTo("Media-Info command", outputPrefix, "_readdiscstructure_dvd+_adip.bin", "SCSI READ DISC STRUCTURE", cmdBuf); + } sense = dev.ReadDiscStructure(out cmdBuf, out senseBuf, MmcDiscStructureMediaType.Dvd, 0, 0, MmcDiscStructureFormat.Dcb, 0, dev.Timeout, out duration); if(sense) + { DicConsole.DebugWriteLine("Media-Info command", "READ DISC STRUCTURE: DCB\n{0}", Decoders.SCSI.Sense.PrettifySense(senseBuf)); + } else + { DataFile.WriteTo("Media-Info command", outputPrefix, "_readdiscstructure_dvd+_dcb.bin", "SCSI READ DISC STRUCTURE", cmdBuf); + } } #endregion All DVD+ @@ -807,11 +860,15 @@ namespace DiscImageChef.Commands MmcDiscStructureFormat.HddvdCopyrightInformation, 0, dev.Timeout, out duration); if(sense) + { DicConsole.DebugWriteLine("Media-Info command", "READ DISC STRUCTURE: HDDVD CMI\n{0}", Decoders.SCSI.Sense.PrettifySense(senseBuf)); + } else + { DataFile.WriteTo("Media-Info command", outputPrefix, "_readdiscstructure_hddvd_cmi.bin", "SCSI READ DISC STRUCTURE", cmdBuf); + } } #endregion HD DVD-ROM @@ -822,20 +879,28 @@ namespace DiscImageChef.Commands MmcDiscStructureFormat.HddvdrMediumStatus, 0, dev.Timeout, out duration); if(sense) + { DicConsole.DebugWriteLine("Media-Info command", "READ DISC STRUCTURE: HDDVD-R Medium Status\n{0}", Decoders.SCSI.Sense.PrettifySense(senseBuf)); + } else + { DataFile.WriteTo("Media-Info command", outputPrefix, "_readdiscstructure_hddvdr_status.bin", "SCSI READ DISC STRUCTURE", cmdBuf); + } sense = dev.ReadDiscStructure(out cmdBuf, out senseBuf, MmcDiscStructureMediaType.Dvd, 0, 0, MmcDiscStructureFormat.HddvdrLastRmd, 0, dev.Timeout, out duration); if(sense) + { DicConsole.DebugWriteLine("Media-Info command", "READ DISC STRUCTURE: Last RMD\n{0}", Decoders.SCSI.Sense.PrettifySense(senseBuf)); + } else + { DataFile.WriteTo("Media-Info command", outputPrefix, "_readdiscstructure_hddvdr_lastrmd.bin", "SCSI READ DISC STRUCTURE", cmdBuf); + } } #endregion HD DVD-R @@ -847,11 +912,15 @@ namespace DiscImageChef.Commands MmcDiscStructureFormat.DvdrLayerCapacity, 0, dev.Timeout, out duration); if(sense) + { DicConsole.DebugWriteLine("Media-Info command", "READ DISC STRUCTURE: Layer Capacity\n{0}", Decoders.SCSI.Sense.PrettifySense(senseBuf)); + } else + { DataFile.WriteTo("Media-Info command", outputPrefix, "_readdiscstructure_dvdr_layercap.bin", "SCSI READ DISC STRUCTURE", cmdBuf); + } } #endregion DVD-R DL, DVD-RW DL, DVD+R DL, DVD+RW DL @@ -861,39 +930,55 @@ namespace DiscImageChef.Commands sense = dev.ReadDiscStructure(out cmdBuf, out senseBuf, MmcDiscStructureMediaType.Dvd, 0, 0, MmcDiscStructureFormat.MiddleZoneStart, 0, dev.Timeout, out duration); if(sense) + { DicConsole.DebugWriteLine("Media-Info command", "READ DISC STRUCTURE: Middle Zone Start\n{0}", Decoders.SCSI.Sense.PrettifySense(senseBuf)); + } else + { DataFile.WriteTo("Media-Info command", outputPrefix, "_readdiscstructure_dvd_mzs.bin", "SCSI READ DISC STRUCTURE", cmdBuf); + } sense = dev.ReadDiscStructure(out cmdBuf, out senseBuf, MmcDiscStructureMediaType.Dvd, 0, 0, MmcDiscStructureFormat.JumpIntervalSize, 0, dev.Timeout, out duration); if(sense) + { DicConsole.DebugWriteLine("Media-Info command", "READ DISC STRUCTURE: Jump Interval Size\n{0}", Decoders.SCSI.Sense.PrettifySense(senseBuf)); + } else + { DataFile.WriteTo("Media-Info command", outputPrefix, "_readdiscstructure_dvd_jis.bin", "SCSI READ DISC STRUCTURE", cmdBuf); + } sense = dev.ReadDiscStructure(out cmdBuf, out senseBuf, MmcDiscStructureMediaType.Dvd, 0, 0, MmcDiscStructureFormat.ManualLayerJumpStartLba, 0, dev.Timeout, out duration); if(sense) + { DicConsole.DebugWriteLine("Media-Info command", "READ DISC STRUCTURE: Manual Layer Jump Start LBA\n{0}", Decoders.SCSI.Sense.PrettifySense(senseBuf)); + } else + { DataFile.WriteTo("Media-Info command", outputPrefix, "_readdiscstructure_dvd_manuallj.bin", "SCSI READ DISC STRUCTURE", cmdBuf); + } sense = dev.ReadDiscStructure(out cmdBuf, out senseBuf, MmcDiscStructureMediaType.Dvd, 0, 0, MmcDiscStructureFormat.RemapAnchorPoint, 0, dev.Timeout, out duration); if(sense) + { DicConsole.DebugWriteLine("Media-Info command", "READ DISC STRUCTURE: Remap Anchor Point\n{0}", Decoders.SCSI.Sense.PrettifySense(senseBuf)); + } else + { DataFile.WriteTo("Media-Info command", outputPrefix, "_readdiscstructure_dvd_remapanchor.bin", "SCSI READ DISC STRUCTURE", cmdBuf); + } } #endregion DVD-R DL @@ -904,8 +989,10 @@ namespace DiscImageChef.Commands sense = dev.ReadDiscStructure(out cmdBuf, out senseBuf, MmcDiscStructureMediaType.Bd, 0, 0, MmcDiscStructureFormat.DiscInformation, 0, dev.Timeout, out duration); if(sense) + { DicConsole.DebugWriteLine("Media-Info command", "READ DISC STRUCTURE: DI\n{0}", Decoders.SCSI.Sense.PrettifySense(senseBuf)); + } else { DataFile.WriteTo("Media-Info command", outputPrefix, "_readdiscstructure_bd_di.bin", @@ -915,11 +1002,15 @@ namespace DiscImageChef.Commands sense = dev.ReadDiscStructure(out cmdBuf, out senseBuf, MmcDiscStructureMediaType.Bd, 0, 0, MmcDiscStructureFormat.Pac, 0, dev.Timeout, out duration); if(sense) + { DicConsole.DebugWriteLine("Media-Info command", "READ DISC STRUCTURE: PAC\n{0}", Decoders.SCSI.Sense.PrettifySense(senseBuf)); + } else + { DataFile.WriteTo("Media-Info command", outputPrefix, "_readdiscstructure_bd_pac.bin", "SCSI READ DISC STRUCTURE", cmdBuf); + } } #endregion All Blu-ray @@ -930,8 +1021,10 @@ namespace DiscImageChef.Commands MmcDiscStructureFormat.BdBurstCuttingArea, 0, dev.Timeout, out duration); if(sense) + { DicConsole.DebugWriteLine("Media-Info command", "READ DISC STRUCTURE: BCA\n{0}", Decoders.SCSI.Sense.PrettifySense(senseBuf)); + } else { DataFile.WriteTo("Media-Info command", outputPrefix, "_readdiscstructure_bd_bca.bin", @@ -948,8 +1041,10 @@ namespace DiscImageChef.Commands sense = dev.ReadDiscStructure(out cmdBuf, out senseBuf, MmcDiscStructureMediaType.Bd, 0, 0, MmcDiscStructureFormat.BdDds, 0, dev.Timeout, out duration); if(sense) + { DicConsole.DebugWriteLine("Media-Info command", "READ DISC STRUCTURE: DDS\n{0}", Decoders.SCSI.Sense.PrettifySense(senseBuf)); + } else { DataFile.WriteTo("Media-Info command", outputPrefix, "_readdiscstructure_bd_dds.bin", @@ -960,8 +1055,10 @@ namespace DiscImageChef.Commands sense = dev.ReadDiscStructure(out cmdBuf, out senseBuf, MmcDiscStructureMediaType.Bd, 0, 0, MmcDiscStructureFormat.CartridgeStatus, 0, dev.Timeout, out duration); if(sense) + { DicConsole.DebugWriteLine("Media-Info command", "READ DISC STRUCTURE: Cartridge Status\n{0}", Decoders.SCSI.Sense.PrettifySense(senseBuf)); + } else { DataFile.WriteTo("Media-Info command", outputPrefix, "_readdiscstructure_bd_cartstatus.bin", @@ -972,9 +1069,11 @@ namespace DiscImageChef.Commands MmcDiscStructureFormat.BdSpareAreaInformation, 0, dev.Timeout, out duration); if(sense) + { DicConsole.DebugWriteLine("Media-Info command", "READ DISC STRUCTURE: Spare Area Information\n{0}", Decoders.SCSI.Sense.PrettifySense(senseBuf)); + } else { DataFile.WriteTo("Media-Info command", outputPrefix, "_readdiscstructure_bd_spare.bin", @@ -985,17 +1084,23 @@ namespace DiscImageChef.Commands sense = dev.ReadDiscStructure(out cmdBuf, out senseBuf, MmcDiscStructureMediaType.Bd, 0, 0, MmcDiscStructureFormat.RawDfl, 0, dev.Timeout, out duration); if(sense) + { DicConsole.DebugWriteLine("Media-Info command", "READ DISC STRUCTURE: Raw DFL\n{0}", Decoders.SCSI.Sense.PrettifySense(senseBuf)); + } else + { DataFile.WriteTo("Media-Info command", outputPrefix, "_readdiscstructure_bd_dfl.bin", "SCSI READ DISC STRUCTURE", cmdBuf); + } sense = dev.ReadDiscInformation(out cmdBuf, out senseBuf, MmcDiscInformationDataTypes.TrackResources, dev.Timeout, out duration); if(sense) + { DicConsole.DebugWriteLine("Media-Info command", "READ DISC INFORMATION 001b\n{0}", Decoders.SCSI.Sense.PrettifySense(senseBuf)); + } else { DicConsole.WriteLine("Track Resources Information:\n{0}", @@ -1006,8 +1111,10 @@ namespace DiscImageChef.Commands sense = dev.ReadDiscInformation(out cmdBuf, out senseBuf, MmcDiscInformationDataTypes.PowResources, dev.Timeout, out duration); if(sense) + { DicConsole.DebugWriteLine("Media-Info command", "READ DISC INFORMATION 010b\n{0}", Decoders.SCSI.Sense.PrettifySense(senseBuf)); + } else { DicConsole.WriteLine("POW Resources Information:\n{0}", @@ -1029,8 +1136,10 @@ namespace DiscImageChef.Commands bool tocSense = dev.ReadTocPmaAtip(out cmdBuf, out senseBuf, false, 0, 0, dev.Timeout, out duration); if(tocSense) + { DicConsole.DebugWriteLine("Media-Info command", "READ TOC/PMA/ATIP: TOC\n{0}", Decoders.SCSI.Sense.PrettifySense(senseBuf)); + } else { toc = Decoders.CD.TOC.Decode(cmdBuf); @@ -1045,8 +1154,10 @@ namespace DiscImageChef.Commands // ATIP exists on blank CDs sense = dev.ReadAtip(out cmdBuf, out senseBuf, dev.Timeout, out duration); if(sense) + { DicConsole.DebugWriteLine("Media-Info command", "READ TOC/PMA/ATIP: ATIP\n{0}", Decoders.SCSI.Sense.PrettifySense(senseBuf)); + } else { DataFile.WriteTo("Media-Info command", outputPrefix, "_atip.bin", "SCSI READ TOC/PMA/ATIP", @@ -1067,8 +1178,10 @@ namespace DiscImageChef.Commands MmcDiscInformationDataTypes.DiscInformation, dev.Timeout, out duration); if(sense) + { DicConsole.DebugWriteLine("Media-Info command", "READ DISC INFORMATION 000b\n{0}", Decoders.SCSI.Sense.PrettifySense(senseBuf)); + } else { Decoders.SCSI.MMC.DiscInformation.StandardDiscInformation? discInfo = @@ -1101,8 +1214,10 @@ namespace DiscImageChef.Commands sense = dev.ReadSessionInfo(out cmdBuf, out senseBuf, dev.Timeout, out duration); if(sense) + { DicConsole.DebugWriteLine("Media-Info command", "READ TOC/PMA/ATIP: Session info\n{0}", Decoders.SCSI.Sense.PrettifySense(senseBuf)); + } else { DataFile.WriteTo("Media-Info command", outputPrefix, "_session.bin", @@ -1131,10 +1246,7 @@ namespace DiscImageChef.Commands ((Decoders.CD.TOC_CONTROL)(track.CONTROL & 0x0D) == Decoders.CD.TOC_CONTROL.DataTrack || (Decoders.CD.TOC_CONTROL)(track.CONTROL & 0x0D) == - Decoders.CD.TOC_CONTROL.DataTrackIncremental)) - { - allFirstSessionTracksAreAudio &= firstTrackLastSession != 1; - } + Decoders.CD.TOC_CONTROL.DataTrackIncremental)) allFirstSessionTracksAreAudio &= firstTrackLastSession != 1; if((Decoders.CD.TOC_CONTROL)(track.CONTROL & 0x0D) == Decoders.CD.TOC_CONTROL.DataTrack || @@ -1159,8 +1271,10 @@ namespace DiscImageChef.Commands sense = dev.ReadRawToc(out cmdBuf, out senseBuf, 1, dev.Timeout, out duration); if(sense) + { DicConsole.DebugWriteLine("Media-Info command", "READ TOC/PMA/ATIP: Raw TOC\n{0}", Decoders.SCSI.Sense.PrettifySense(senseBuf)); + } else { DataFile.WriteTo("Media-Info command", outputPrefix, "_rawtoc.bin", @@ -1169,8 +1283,10 @@ namespace DiscImageChef.Commands } sense = dev.ReadPma(out cmdBuf, out senseBuf, dev.Timeout, out duration); if(sense) + { DicConsole.DebugWriteLine("Media-Info command", "READ TOC/PMA/ATIP: PMA\n{0}", Decoders.SCSI.Sense.PrettifySense(senseBuf)); + } else { DataFile.WriteTo("Media-Info command", outputPrefix, "_pma.bin", "SCSI READ TOC/PMA/ATIP", @@ -1180,15 +1296,19 @@ namespace DiscImageChef.Commands sense = dev.ReadCdText(out cmdBuf, out senseBuf, dev.Timeout, out duration); if(sense) + { DicConsole.DebugWriteLine("Media-Info command", "READ TOC/PMA/ATIP: CD-TEXT\n{0}", Decoders.SCSI.Sense.PrettifySense(senseBuf)); + } else { DataFile.WriteTo("Media-Info command", outputPrefix, "_cdtext.bin", "SCSI READ TOC/PMA/ATIP", cmdBuf); if(Decoders.CD.CDTextOnLeadIn.Decode(cmdBuf).HasValue) + { DicConsole.WriteLine("CD-TEXT on Lead-In:\n{0}", Decoders.CD.CDTextOnLeadIn.Prettify(cmdBuf)); + } } } } @@ -1201,8 +1321,10 @@ namespace DiscImageChef.Commands MmcDiscStructureFormat.PhysicalInformation, 0, dev.Timeout, out duration); if(sense) + { DicConsole.DebugWriteLine("Media-Info command", "READ DISC STRUCTURE: PFI\n{0}", Decoders.SCSI.Sense.PrettifySense(senseBuf)); + } else { DataFile.WriteTo("Media-Info command", outputPrefix, "_readdiscstructure_dvd_pfi.bin", @@ -1224,11 +1346,15 @@ namespace DiscImageChef.Commands MmcDiscStructureFormat.DiscManufacturingInformation, 0, dev.Timeout, out duration); if(sense) + { DicConsole.DebugWriteLine("Media-Info command", "READ DISC STRUCTURE: DMI\n{0}", Decoders.SCSI.Sense.PrettifySense(senseBuf)); + } else + { DataFile.WriteTo("Media-Info command", outputPrefix, "_readdiscstructure_dvd_dmi.bin", "SCSI READ DISC STRUCTURE", cmdBuf); + } } #endregion Nintendo } @@ -1248,11 +1374,15 @@ namespace DiscImageChef.Commands { sense = dev.KreonExtractSs(out cmdBuf, out senseBuf, dev.Timeout, out duration); if(sense) + { DicConsole.DebugWriteLine("Media-Info command", "KREON EXTRACT SS:\n{0}", Decoders.SCSI.Sense.PrettifySense(senseBuf)); + } else + { DataFile.WriteTo("Media-Info command", outputPrefix, "_xbox_ss.bin", "KREON EXTRACT SS", cmdBuf); + } if(Decoders.Xbox.SS.Decode(cmdBuf).HasValue) DicConsole.WriteLine("Xbox Security Sector:\n{0}", Decoders.Xbox.SS.Prettify(cmdBuf)); @@ -1356,8 +1486,10 @@ namespace DiscImageChef.Commands #endregion Xbox if(dskType == MediaType.Unknown) + { dskType = MediaTypeFromScsi.Get((byte)dev.ScsiType, dev.Manufacturer, dev.Model, scsiMediumType, scsiDensityCode, blocks, blockSize); + } if(dskType == MediaType.Unknown && dev.IsUsb && containsFloppyPage) dskType = MediaType.FlashDrive; @@ -1366,8 +1498,10 @@ namespace DiscImageChef.Commands sense = dev.ReadMediaSerialNumber(out cmdBuf, out senseBuf, dev.Timeout, out duration); if(sense) + { DicConsole.DebugWriteLine("Media-Info command", "READ MEDIA SERIAL NUMBER\n{0}", Decoders.SCSI.Sense.PrettifySense(senseBuf)); + } else { DataFile.WriteTo("Media-Info command", outputPrefix, "_mediaserialnumber.bin", diff --git a/DiscImageChef/Commands/MediaScan.cs b/DiscImageChef/Commands/MediaScan.cs index f2f5117d7..59f734e74 100644 --- a/DiscImageChef/Commands/MediaScan.cs +++ b/DiscImageChef/Commands/MediaScan.cs @@ -48,10 +48,7 @@ namespace DiscImageChef.Commands 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])) - { - options.DevicePath = "\\\\.\\" + char.ToUpper(options.DevicePath[0]) + ':'; - } + char.IsLetter(options.DevicePath[0])) options.DevicePath = "\\\\.\\" + char.ToUpper(options.DevicePath[0]) + ':'; Device dev = new Device(options.DevicePath); @@ -108,8 +105,10 @@ namespace DiscImageChef.Commands #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 + { 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); + } Core.Statistics.AddMediaScan((long)results.A, (long)results.B, (long)results.C, (long)results.D, (long)results.E, (long)results.F, (long)results.Blocks, (long)results.Errored, diff --git a/DiscImageChef/Commands/Statistics.cs b/DiscImageChef/Commands/Statistics.cs index ac6b29c07..e00e76f5b 100644 --- a/DiscImageChef/Commands/Statistics.cs +++ b/DiscImageChef/Commands/Statistics.cs @@ -52,50 +52,80 @@ namespace DiscImageChef.Commands DicConsole.WriteLine("Commands statistics"); DicConsole.WriteLine("==================="); if(Core.Statistics.AllStats.Commands.Analyze > 0) + { DicConsole.WriteLine("You have called the Analyze command {0} times", Core.Statistics.AllStats.Commands.Analyze); + } if(Core.Statistics.AllStats.Commands.Benchmark > 0) + { DicConsole.WriteLine("You have called the Benchmark command {0} times", Core.Statistics.AllStats.Commands.Benchmark); + } if(Core.Statistics.AllStats.Commands.Checksum > 0) + { DicConsole.WriteLine("You have called the Checksum command {0} times", Core.Statistics.AllStats.Commands.Checksum); + } if(Core.Statistics.AllStats.Commands.Compare > 0) + { DicConsole.WriteLine("You have called the Compare command {0} times", Core.Statistics.AllStats.Commands.Compare); + } if(Core.Statistics.AllStats.Commands.CreateSidecar > 0) + { DicConsole.WriteLine("You have called the Create-Sidecar command {0} times", Core.Statistics.AllStats.Commands.CreateSidecar); + } if(Core.Statistics.AllStats.Commands.Decode > 0) + { DicConsole.WriteLine("You have called the Decode command {0} times", Core.Statistics.AllStats.Commands.Decode); + } if(Core.Statistics.AllStats.Commands.DeviceInfo > 0) + { DicConsole.WriteLine("You have called the Device-Info command {0} times", Core.Statistics.AllStats.Commands.DeviceInfo); + } if(Core.Statistics.AllStats.Commands.DeviceReport > 0) + { DicConsole.WriteLine("You have called the Device-Report command {0} times", Core.Statistics.AllStats.Commands.DeviceReport); + } if(Core.Statistics.AllStats.Commands.DumpMedia > 0) + { DicConsole.WriteLine("You have called the Dump-Media command {0} times", Core.Statistics.AllStats.Commands.DumpMedia); + } if(Core.Statistics.AllStats.Commands.Entropy > 0) + { DicConsole.WriteLine("You have called the Entropy command {0} times", Core.Statistics.AllStats.Commands.Entropy); + } if(Core.Statistics.AllStats.Commands.Formats > 0) + { DicConsole.WriteLine("You have called the Formats command {0} times", Core.Statistics.AllStats.Commands.Formats); + } if(Core.Statistics.AllStats.Commands.MediaInfo > 0) + { DicConsole.WriteLine("You have called the Media-Info command {0} times", Core.Statistics.AllStats.Commands.MediaInfo); + } if(Core.Statistics.AllStats.Commands.MediaScan > 0) + { DicConsole.WriteLine("You have called the Media-Scan command {0} times", Core.Statistics.AllStats.Commands.MediaScan); + } if(Core.Statistics.AllStats.Commands.PrintHex > 0) + { DicConsole.WriteLine("You have called the Print-Hex command {0} times", Core.Statistics.AllStats.Commands.PrintHex); + } if(Core.Statistics.AllStats.Commands.Verify > 0) + { DicConsole.WriteLine("You have called the Verify command {0} times", Core.Statistics.AllStats.Commands.Verify); + } DicConsole.WriteLine(); thereAreStats = true; } @@ -104,10 +134,7 @@ namespace DiscImageChef.Commands { DicConsole.WriteLine("Benchmark statistics"); DicConsole.WriteLine("===================="); - foreach(ChecksumStats chk in Core.Statistics.AllStats.Benchmark.Checksum) - { - DicConsole.WriteLine("Took {0} seconds to calculate {1} algorithm", chk.Value, chk.algorithm); - } + foreach(ChecksumStats chk in Core.Statistics.AllStats.Benchmark.Checksum) DicConsole.WriteLine("Took {0} seconds to calculate {1} algorithm", chk.Value, chk.algorithm); DicConsole.WriteLine("Took {0} seconds to calculate all algorithms sequentially", Core.Statistics.AllStats.Benchmark.Sequential); @@ -172,9 +199,11 @@ namespace DiscImageChef.Commands DicConsole.WriteLine("Device statistics"); DicConsole.WriteLine("================="); foreach(DeviceStats ds in Core.Statistics.AllStats.Devices) + { DicConsole .WriteLine("Device model {0}, manufactured by {1}, with revision {2} and attached via {3}.", ds.Model, ds.Manufacturer, ds.Revision, ds.Bus); + } DicConsole.WriteLine(); thereAreStats = true; @@ -187,11 +216,15 @@ namespace DiscImageChef.Commands foreach(MediaStats ms in Core.Statistics.AllStats.Medias) { if(ms.real) + { DicConsole.WriteLine("Media type {0} has been found {1} times in a real device.", ms.type, ms.Value); + } else + { DicConsole.WriteLine("Media type {0} has been found {1} times in a media image.", ms.type, ms.Value); + } } DicConsole.WriteLine(); diff --git a/DiscImageChef/Commands/Verify.cs b/DiscImageChef/Commands/Verify.cs index 9c307c7e3..169f7a508 100644 --- a/DiscImageChef/Commands/Verify.cs +++ b/DiscImageChef/Commands/Verify.cs @@ -140,12 +140,16 @@ namespace DiscImageChef.Commands bool? tempStatus; if(remainingSectors < 512) + { tempStatus = inputFormat.VerifySectors(currentSector, (uint)remainingSectors, currentTrack.TrackSequence, out tempfailingLbas, out tempunknownLbas); + } else + { tempStatus = inputFormat.VerifySectors(currentSector, 512, currentTrack.TrackSequence, out tempfailingLbas, out tempunknownLbas); + } if(checkStatus == null || tempStatus == null) checkStatus = null; else if(checkStatus == false || tempStatus == false) checkStatus = false; @@ -188,11 +192,15 @@ namespace DiscImageChef.Commands bool? tempStatus; if(remainingSectors < 512) + { tempStatus = inputFormat.VerifySectors(currentSector, (uint)remainingSectors, out tempfailingLbas, out tempunknownLbas); + } else + { tempStatus = inputFormat.VerifySectors(currentSector, 512, out tempfailingLbas, out tempunknownLbas); + } if(checkStatus == null || tempStatus == null) checkStatus = null; else if(checkStatus == false || tempStatus == false) checkStatus = false;